How To Create A High Availability Setup With Corosync Pacemaker and Reserved Ips On Ubuntu 14 04
How To Create A High Availability Setup With Corosync Pacemaker and Reserved Ips On Ubuntu 14 04
/bin/bash
apt-get -y update
apt-get -y install nginx
export HOSTNAME=$(curl -s http://169.254.169.254/metadata/v1/hostname)
export PUBLIC_IPV4=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/add
echo Droplet: $HOSTNAME, IP Address: $PUBLIC_IPV4 > /usr/share/nginx/html/index.html
index.html
http:// your_reserved_ip
example.com
$ sudo dpkg-reconfigure tzdata
America/New_York
ntp
5404 5406
iptables eth1
haveged
corosync-keygen
corosync-keygen
/etc/corosync
/authkey
haveged
authkey
/etc/corosync
/authkey
corosync.conf
vi
$ sudo vi /etc/corosync/corosync.conf
bindnetaddr
bindnetaddr
corosync.conf
1 totem {
2 version: 2
3 cluster_name: lbcluster
4 transport: udpu
5 interface {
6 ringnumber: 0
7 bindnetaddr: server_private_IP_address
8 broadcast: yes
9 mcastport: 5405
10 }
11 }
12
13 quorum {
14 provider: corosync_votequorum
15 two_node: 1
16 }
17
18 nodelist {
19 node {
20 ring0_addr: primary_private_IP_address
21 name: primary
22 nodeid: 1
23 }
24 node {
25 ring0_addr: secondary_private_IP_address
26 name: secondary
27 nodeid: 2
28 }
29 }
30
31 logging {
32 to_logfile: yes
33 logfile: /var/log/corosync/corosync.log
34 to_syslog: yes
35 timestamp: on
36 }
transport: udpu
bindnetaddr
two_node: 1
/var/log/corosync/corosync.log
pcmk
vi
$ sudo vi /etc/corosync/service.d/pcmk
service {
name: pacemaker
ver: 1
}
/etc/default/corosync
$ sudo vi /etc/default/corosync
START yes
START= yes
corosync-cmapctl output:
runtime.totem.pg.mrp.srp.members.1.config_version (u64) = 0
runtime.totem.pg.mrp.srp.members.1.ip (str) = r(0) ip( primary_private_IP_address )
runtime.totem.pg.mrp.srp.members.1.join_count (u32) = 1
runtime.totem.pg.mrp.srp.members.1.status (str) = joined
runtime.totem.pg.mrp.srp.members.2.config_version (u64) = 0
runtime.totem.pg.mrp.srp.members.2.ip (str) = r(0) ip( secondary_private_IP_address
runtime.totem.pg.mrp.srp.members.2.join_count (u32) = 1
runtime.totem.pg.mrp.srp.members.2.status (str) = joined
20
19
crm
crm
crm status:
Last updated: Fri Oct 16 14:38:36 2015
Last change: Fri Oct 16 14:36:01 2015 via crmd on primary
Stack: corosync
Current DC: primary (1) - partition with quorum
Version: 1.1.10-42f2063
2 Nodes configured
0 Resources configured
$ sudo crm_mon
crm status
Ctrl-C
crm
FloatIP
FloatIP
assign-ip
assign-ip
DO_TOKEN
digitalocean
start
status monitor
FloatIP
FloatIP
FloatIP
crm_mon:
...
2 Nodes configured
1 Resource configured
FloatIP standby
FloatIP
Reserved IP is pointing to primary server:
Droplet: primary , IP Address: primary_ip_address
curl
standby
$ sudo reboot
curl
Connection refused
FloatIP
OFFLINE Online
crm_mon
$ sudo crm_mon
crm
standby online
crm crm
$ crm
crm
crm
crm_mon:
...
Online: [ primary secondary ]
Nginx FloatIP
Nginx
crm_mon:
Online: [ primary secondary ]
Nginx-clone
FloatIP
Nginx-clone
$ sudo crm configure colocation FloatIP-Nginx inf: FloatIP Nginx-clone
crm status
FloatIP
sudo crm status
Cluster Summary:
* Stack: corosync
* Current DC: ip-<private ip of primary server> (version 2.1.2-ada5c3b36e2) - partitio
* Last updated: Wed Jul 20 10:56:41 2022
* Last change: Wed Jul 20 10:40:16 2022 by hacluster via crmd on ip-<private ip of pr
* 1 node configured
* 0 resource instances configured
Node List:
* Online: [ ip-<private ip of primary server> ]
Stack: corosync
Current DC: secondary (version 1.1.14-70404b0) - partition with quorum
2 nodes and 1 resource configured
while
true; do curl my.floating.ipaddress; sleep 1; done
crm status
Stack: corosync
Current DC: secondary (version 1.1.14-70404b0) - partition with quorum
2 nodes and 1 resource configured