Linux集群VS/DR + Heartbeat
192.168.58.128|192.168.58.131作为Heartbeat 主从服务器
##########配置###############
LVS:eth0: 192.168.58.128 #Real IP
eth0:0 192.168.58.88 #VIP
# vi /etc/init.d/iplvs.sh #将iplvs.sh些到/etc/init.d/ 以便haresources调用
ifconfig eth0:0 192.168.58.88 broadcast 192.168.58.255 netmask 255.255.255 up
route add -host 192.168.58.88 dev eht0:0
ipvsadm -C
ipvsadm -A -t 192.168.58.88:80 -s rr
ipvsadm -a -t 192.168.58.88:80 -r 192.168.58.133:80 -g #Real Server
ipvsadm -a -t 192.168.58.88:80 -r 192.168.58.132:80 -g #Real Server
#Real Server 配置 (两台都一样配置)
# vi ipvs.sh
ifconfig lo:0 192.168.58.88 broadcast 192.168.58.255 netmask 255.255.255.255 up
route add -host 192.168.58.88 dev lo:0
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
sysctl -p
# chmod u+x iplvs.sh
# ./lvs.sh
# vi /etc/rc.local
if [ -x /etc/init.d/iplvs.sh ];then
echo "Starting Real Server.............";
/etc/init.d/iplvs.sh
fi
#############配置Heartbeat################
##这里两台服务器可以各自只用一块网卡##
rpm -ivh libnet-1.1.4-3.el5.i386.rpm
rpm -ivh libtool-libs-1.5.6-4.i386.rpm
rpm -ivh heartbeat-pils-2.1.4-9.el5.i386.rpm
rpm -ivh heartbeat-stonith-2.1.4-9.el5.i386.rpm
rpm -ivh heartbeat-2.1.4-9.el5.i386.rpm
rpm -q heartbeat -d
# cd /etc/ra.d
# cp /usr/share/doc/heartbeat-2.1.4/ha.cf .
# cp /usr/share/doc/heartbeat-2.1.4/authkeys .
# cp /usr/share/doc/heartbeat-2.1.4/haresources .
# vi /etc/hosts
192.168.58.128 server1.localdomain.com server1
192.168.58.131 server2.localdomain.com server2
# service network restart
# uname -n server1.localdomain.com
# vi ha.cf
logfile
keepalive 2
deadtime 30
initdead 120
udpport 694
bcast eth0
ucast eth0 192.168.58.128 | ucast eth0 192.168.58.131 #这里填写做相应的改变 两块网卡可些eth1
node server1.localdomain.com #主
node server2.localdomain.com #从
ping 192.168.58.1 (Internet)
# vi authkeys
auth 1
1 crc
# vi haresources
server1.localdomain 192.168.58.88 iplvs.sh #系统到/etc/init.d/下去找iplvs.sh脚本(ipvsadm)
# chmod 600 authkeys
# service heartbeat start
- 最新评论