HA高可用集羣

 準備2臺機器:
主:master:192.168.254.140
從:slave:192.168.254.141
vim /etc/hosts
主、從:
192.168.254.140 master
192.168.254.141 slave


1.主和從上安裝:
wget www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm
rpm -ivh epel-release-6-8_64.noarch.rpm
yum install -y libnet
yum install -y heartbeat

2.主上編輯HA的3個配置文件
cd /usr/share/doc/heartbeat-3.0.4/
cp authkeys ha.cf haresources /etc/ha.d/
cd /etc/ha.d/

vim authkeys


chmod 600 authkeys

vim haresources
這裏的ip是vip:

 
主從不同的就是下面這個配置文件:
vim ha.cf

debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility      local0
keepalive 2
deadtime 30
warntime 10
initdead 60
udpport 649
ucast eth0 192.168.254.141   #這裏ip是對方ip,如果從就是140
auto_failback on
node  master
node  slave
ping 192.168.1.1
respawn hacluster /usr/lib64/heartbeat/ipfail

3.拷貝3個配置到從上
yum install openssh-clients    #scp的安裝包
scp authkeys haresources ha.cf  slave:/etc/ha.d/    #三個配置都是從主上覆制過來的
vim ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility      local0
keepalive 2
deadtime 30
warntime 10
initdead 60
udpport 649
ucast eth0 192.168.254.140   #這裏ip對方ip,如果從就是140
auto_failback on
node  master
node  slave
ping 192.168.1.1
respawn hacluster /usr/lib64/heartbeat/ipfail
4.啓動(先主後從)
/etc/init.d/heartbeat start

5.測試
主:
echo "11111111111111111master" > /usr/share/nginx/html/index.html
iptables -A INPUT -p icmp -j DROP
iptables -D INPUT -p icmp -j DROP
/etc/init.d/heartbeat stop
從:
echo "2222222222222slave" > /usr/share/nginx/html/index.html



 

相關文章
相關標籤/搜索