ycycoco 发表于 2019-1-3 12:57:41

heartbeat LVS高可用集群配置,

  VIP 192.168.3.240
DR1 192.168.3.128/4.128
DR2 192.168.3.129/4.129
realserver 192.168.3.130
realserver 192.168.3.131



tar -xf heartbeat-2.1.3.tar.gz

   11cd heartbeat-2.1.3
   12ls
   13./ConfigureMe configure --disable-swig --disable-snmp-subagent
   14make
   15make install
   16cp doc/ha.cf doc/haresources doc/authkeys /etc/ha.d/
   17cp ldirectord/ldirectord.cf /etc/ha.d/
   18groupadd -g 694 haclient
   19useradd -u 694 -g haclient hacluster
yum install perl-MailTools
yum install libnet
yum install ipvsadm


# grep -v -E '^#|^$' /etc/ha.d/ldirectord.cf
checktimeout=20
checkinterval=10
fallback=127.0.0.1:80
autoreload=yes
logfile="/var/log/ldirectord.log"
quiescent=yes
virtual=192.168.3.240:80
      real=192.168.3.130:80 gate
      real=192.168.3.131:80 gate
      fallback=127.0.0.1:80 gate
      service=http
      request="index.html"
      scheduler=rr
      protocol=tcp
# grep -v -E '^#|^$' /etc/ha.d/authkeys权限600 DR2一样
auth 1
1 crc
# grep -v -E '^#|^$' /etc/ha.d/ha.cf
logfile /var/log/ha-log
bcast   eth1
logfacility   local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
auto_failback on
node    DR1
node    DR2
ping 192.168.1.7# grep -v -E '^#|^$' /etc/ha.d/haresources
DR1 IPaddr::192.168.3.240/24/eth0 ldirectord
--------------------------------------------------------------------------------

# grep -v -E '^#|^$' /etc/ha.d/ldirectord.cf
checktimeout=20
checkinterval=10
fallback=127.0.0.1:80
autoreload=yes
logfile="/var/log/ldirectord.log"
quiescent=yes
virtual=192.168.3.240:80
      real=192.168.3.130:80 gate
      real=192.168.3.131:80 gate
      fallback=127.0.0.1:80 gate
      service=http
      request="index.html"
      scheduler=rr
      protocol=tcp
# grep -v -E '^#|^$' /etc/ha.d/authkeys
auth 1
1 crc
# grep -v -E '^#|^$' /etc/ha.d/ha.cf
logfile /var/log/ha-log
bcast   eth1
logfacility   local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
auto_failback on
node    DR1
node    DR2
ping 192.168.1.7
# grep -v -E '^#|^$' /etc/ha.d/haresources
DR1 IPaddr::192.168.3.240/24/eth0 ldirectord

---------------------------------------------------------------------------
# cat /etc/init.d/lvsrs
#!/bin/bash
VIP=192.168.3.240
./etc/init.d/functions
case "$1" in
start)
echo "start lvs of real server"
/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
echo "1" > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" > /proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" > /proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" > /proc/sys/net/ipv4/conf/all/arp_announce
;;
stop)
/sbin/ifconfig lo:0 down
echo "shutdown lvs firector server"
echo "0" > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo "0" > /proc/sys/net/ipv4/conf/lo/arp_announce
echo "0" > /proc/sys/net/ipv4/conf/all/arp_ignore
echo "0" > /proc/sys/net/ipv4/conf/all/arp_announce
;;
*)
echo "USage:$0 {start|stop}"
exit 1
esac


# cat /etc/init.d/lvsrs
#!/bin/bash
VIP=192.168.3.240
./etc/init.d/functions
case "$1" in
start)
echo "start lvs of real server"
/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
echo "1" > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" > /proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" > /proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" > /proc/sys/net/ipv4/conf/all/arp_announce
;;
stop)
/sbin/ifconfig lo:0 down
echo "shutdown lvs firector server"
echo "0" > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo "0" > /proc/sys/net/ipv4/conf/lo/arp_announce
echo "0" > /proc/sys/net/ipv4/conf/all/arp_ignore
echo "0" > /proc/sys/net/ipv4/conf/all/arp_announce
;;
*)
echo "USage:$0 {start|stop}"
exit 1
esac


$ while true ; do curl 192.168.3.240 `sleep 1`; done
130
131
130
131
130
131
130


# /etc/init.d/httpd stop
停止 httpd:                                             [确定]
$ while true ; do curl 192.168.3.240 `sleep 1`; done
131
131
131
131
131
131
131
131
# /etc/init.d/httpd start
启动 httpd:                                             [确定]
$ while true ; do curl 192.168.3.240 `sleep 1`; done
130
131
130
131
130
131
130
131
130
--------------------------------------------------------------------------

# /etc/init.d/heartbeat stop
Stopping High-Availability services:
                                                         [确定]
heartbeat: 2012/03/20_04:26:26 WARN: node dr2: is dead
heartbeat: 2012/03/20_04:26:26 info: Dead node dr2 gave up resources.
heartbeat: 2012/03/20_04:26:26 info: Link dr2:eth1 dead
------------------------------

# /etc/init.d/heartbeat start
Starting High-Availability services:
                                                         [确定]
# tail -f /var/log/ha-log

heartbeat: 2012/03/20_04:28:06 info: Heartbeat restart on node dr2
heartbeat: 2012/03/20_04:28:06 info: Link dr2:eth1 up.
heartbeat: 2012/03/20_04:28:06 info: Status update for node dr2: status init
heartbeat: 2012/03/20_04:28:06 info: Status update for node dr2: status up
harc:   2012/03/20_04:28:06 info: Running /etc/ha.d/rc.d/status status
harc:   2012/03/20_04:28:06 info: Running /etc/ha.d/rc.d/status status
heartbeat: 2012/03/20_04:28:07 info: Status update for node dr2: status active
harc:   2012/03/20_04:28:07 info: Running /etc/ha.d/rc.d/status status
heartbeat: 2012/03/20_04:28:08 info: remote resource transition completed.
heartbeat: 2012/03/20_04:28:08 info: dr1 wants to go standby
heartbeat: 2012/03/20_04:28:08 info: standby: dr2 can take our foreign resources
heartbeat: 2012/03/20_04:28:08 info: give up foreign HA resources (standby).
heartbeat: 2012/03/20_04:28:08 info: foreign HA resource release completed (standby).
heartbeat: 2012/03/20_04:28:08 info: Local standby process completed .
heartbeat: 2012/03/20_04:28:09 WARN: 1 lost packet(s) for
heartbeat: 2012/03/20_04:28:09 info: remote resource transition completed.
heartbeat: 2012/03/20_04:28:09 info: No pkts missing from dr2!
heartbeat: 2012/03/20_04:28:09 info: Other node completed standby takeover of foreign resources.


DR2上heartbeat: 2012/03/20_04:28:07 info: Status update for node dr1: status active
heartbeat: 2012/03/20_04:28:07 info: Link 192.168.1.7:192.168.1.7 up.
heartbeat: 2012/03/20_04:28:07 info: Status update for node 192.168.1.7: status ping
harc:   2012/03/20_04:28:07 info: Running /etc/ha.d/rc.d/status status
heartbeat: 2012/03/20_04:28:07 info: Comm_now_up(): updating status to active
heartbeat: 2012/03/20_04:28:07 info: Local status now set to: 'active'
heartbeat: 2012/03/20_04:28:08 info: remote resource transition completed.
heartbeat: 2012/03/20_04:28:08 info: remote resource transition completed.
heartbeat: 2012/03/20_04:28:08 info: Local Resource acquisition completed. (none)
heartbeat: 2012/03/20_04:28:08 info: dr1 wants to go standby
heartbeat: 2012/03/20_04:28:09 info: standby: acquire resources from dr1
heartbeat: 2012/03/20_04:28:09 info: acquire local HA resources (standby).
heartbeat: 2012/03/20_04:28:09 info: local HA resource acquisition completed (standby).
heartbeat: 2012/03/20_04:28:09 info: Standby resource acquisition done .
heartbeat: 2012/03/20_04:28:09 info: Initial resource acquisition complete (auto_failback)
heartbeat: 2012/03/20_04:28:09 info: remote resource transition completed.





页: [1]
查看完整版本: heartbeat LVS高可用集群配置,