Corosync, Pacemaker and Ldirectord. HA Load balancer

lb01-pco
apt-get install ldirectord corosync pacemaker sysv-rc-conf
lb02-pco
apt-get install ldirectord corosync pacemaker sysv-rc-conf
lb01-pco and lb02-pco
First make sure /etc/init.d/pacemaker has “# Required-Stop: corosync
#!/bin/bash”
### BEGIN INIT INFO
# Provides: pacemaker
# Required-Start: $network corosync
# Should-Start: $syslog
# Required-Stop: corosync $network
# Default-Start: 2 3 4 5 ########### This is also important
# Default-Stop: 0 1 6 ########### This is also important
# Short-Description: Starts and stops Pacemaker Cluster Manager.
# Description: Starts and stops Pacemaker Cluster Manager.
### END INIT INFO
After this make sure you:
insserv -vr pacemaker
insserv -vr corosync
insserv -v pacemaker
insserv -v corosync
lb01-pco /etc/network/interfaces
allow-hotplug eth0
iface eth0 inet static
address 10.70.5.210
netmask 255.255.255.0
network 10.70.5.0
broadcast 10.70.5.255
#gateway 10.70.5.254
dns-nameservers 88.11.42.40 72.11.200.205
dns-search easydns.vpn
up ip r add 10.70.0.0/8 via 10.70.5.254
up ip r add 192.168.1.0/24 via 10.70.5.254
allow-hotplug eth1
iface eth1 inet static
address 72.11.198.210
netmask 255.255.255.0
network 72.11.198.0
broadcast 72.11.198.255
gateway 72.11.198.254
dns-nameservers 88.11.42.40 72.11.200.205
dns-search easydns.com
lb02-pco /etc/network/interfaces
iface eth0 inet static
address 10.70.5.211
netmask 255.255.255.0
network 10.70.5.0
broadcast 10.70.5.255
# gateway 10.70.5.254
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 88.11.42.40 72.11.200.205
dns-search easydns.vpn
up ip r add 10.70.0.0/8 via 10.70.5.254
up ip r add 192.168.1.0/24 via 10.70.5.254
allow-hotplug eth1
iface eth1 inet static
address 72.11.198.211
netmask 255.255.255.0
network 72.11.198.0
broadcast 72.11.198.255
gateway 72.11.198.254
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 88.11.42.40 72.11.200.205
dns-search easydns.com
root@lb01-pco:~# nano /etc/hosts
10.70.5.210 lb01-pco.easydns.vpn lb01-pco
10.70.5.211 lb02-pco.easydns.vpn lb02-pco
root@lb02-pco:~# nano /etc/hosts
10.70.5.210 lb01-pco.easydns.vpn lb01-pco
10.70.5.211 lb02-pco.easydns.vpn lb02-pco
root@lb01-pco:~# nano /etc/default/corosync
# start corosync at boot [yes|no]
START=yes
root@lb02-pco:~# nano /etc/default/corosync
# start corosync at boot [yes|no]
START=yes
root@lb01-pco:~# nano /etc/corosync/corosync.conf
totem {
version: 2
token: 3000
token_retransmits_before_loss_const: 10
join: 60
consensus: 3600
vsftype: none
max_messages: 20
clear_node_high_bit: yes
secauth: off
threads: 0
rrp_mode: none
interface {
# The following values need to be set based on your environment
ringnumber: 0
bindnetaddr: 10.70.5.210
mcastaddr: 226.94.1.1
mcastport: 5405
}
}
amf {
mode: disabled
}
quorum {
provider: corosync_votequorum
expected_votes: 1
}
aisexec {
user: root
group: root
}
logging {
fileline: off
to_stderr: yes
to_logfile: yes
logfile: /var/log/corosync/corosync.log
to_syslog: yes
syslog_facility: daemon
debug: off
timestamp: on
logger_subsys {
subsys: AMF
debug: off
tags: enter|leave|trace1|trace2|trace3|trace4|trace6
}
}
root@lb02-pco:~# nano /etc/corosync/corosync.conf
totem {
version: 2
token: 3000
token_retransmits_before_loss_const: 10
join: 60
consensus: 3600
vsftype: none
max_messages: 20
clear_node_high_bit: yes
secauth: off
threads: 0
rrp_mode: none
interface {
# The following values need to be set based on your environment
ringnumber: 0
bindnetaddr: 10.70.5.211
mcastaddr: 226.94.1.1
mcastport: 5405
}
}
amf {
mode: disabled
}
quorum {
provider: corosync_votequorum
expected_votes: 1
}
aisexec {
user: root
group: root
}
logging {
fileline: off
to_stderr: yes
to_logfile: yes
logfile: /var/log/corosync/corosync.log
to_syslog: yes
syslog_facility: daemon
debug: off
timestamp: on
logger_subsys {
subsys: AMF
debug: off
tags: enter|leave|trace1|trace2|trace3|trace4|trace6
}
}
root@lb01-pco:~# nano /etc/corosync/service.d/pcmk
service {
name: pacemaker
ver: 1
}
root@lb02-pco:~# nano /etc/corosync/service.d/pcmk
service {
name: pacemaker
ver: 1
}
root@lb01-pco:~# nano /etc/sysctl.conf
net.ipv4.ip_forward=1
sysctl -p
root@lb02-pco:~# nano /etc/sysctl.conf
net.ipv4.ip_forward=1
sysctl -p
root@lb01-pco:~# sysv-rc-conf
Make sure you start pacemaker and corosync at boot
root@lb02-pco:~# sysv-rc-conf
Make sure you start pacemaker and corosync at boot
root@lb01-pco:~# nano /etc/default/ldirectord
CONFIG_FILE=/etc/ha.d/ldirectord.cf
root@lb02-pco:~# nano /etc/default/ldirectord
CONFIG_FILE=/etc/ha.d/ldirectord.cf
lb01-pco and root@lb01-pco nano /etc/ha.d/ldirectord.cf
# Global Directives
checktimeout=3
checkinterval=1
#fallback=127.0.0.1:80
autoreload=yes
logfile=”/var/log/ldirectord.log”
logfile=”local0″
#emailalert=”admin@x.y.z”
#emailalertfreq=3600
#emailalertstatus=all
quiescent=yes
# Sample for an http virtual service
virtual=72.11.198.212:80
real=72.11.198.213:80 gate
real=72.11.198.214:80 gate
fallback=127.0.0.1:80 gate
service=http
request=”index.html”
receive=”It works!”
virtualhost=lbtest.easydns.vpn
scheduler=rr
#persistent=600
#netmask=255.255.255.255
protocol=tcp
checktype=negotiate
checkport=80
request=”index.html”
receive=”It works!”
virtualhost=lbtest.easydns.vpn
root@lb01-pco:~# crm config
node lb01-pco \
attributes standby=”off”
node lb02-pco
primitive VIP ocf:heartbeat:IPaddr2 \
params ip=”72.11.198.212″ nic=”eth1″ \
op monitor interval=”10s”
primitive lvs ocf:heartbeat:ldirectord \
op monitor interval=”20″ timeout=”10″
group lvs-system VIP lvs
location cli-prefer-VIP VIP \
rule $id=”cli-prefer-rule-VIP” inf: #uname eq lb01-pco
location cli-prefer-lvs lvs \
rule $id=”cli-prefer-rule-lvs” inf: #uname eq lb01-pco
location cli-prefer-lvs-system lvs-system \
rule $id=”cli-prefer-rule-lvs-system” inf: #uname eq lb01-pco
property $id=”cib-bootstrap-options” \
dc-version=”1.1.7-ee0730e13d124c3d58f00016c3376a1de5323cff” \
cluster-infrastructure=”openais” \
expected-quorum-votes=”2″ \
stonith-enabled=”false” \
no-quorum-policy=”ignore”
Callback option for syncing conf files ———-
nano /etc/ha.d/ldirectord.cf
add callback=”/usr/local/bin/sync_ldirectord”
nano /usr/local/bin/sync_ldirectord
#!/bin/bash
# This script maintains an up to date configuration file for ldirectord, everytime the server ‘autoreload’, the ldirectord.cf is synced.
rsync -aq /etc/ha.d/ldirectord.cf lb02-pco:/etc/ha.d/ldirectord.cf
chmod +x /usr/local/bin/sync_ldirectord
Dont forget to setup ssh keys from lb01-pco to lb02-pco
————————-
Add your comment

Your email address will not be published. Required fields are marked *