共计 1442 个字符,预计需要花费 4 分钟才能阅读完成。
准备 2 台机器:
主:master:192.168.254.140
从:slave:192.168.254.141
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
cd /usr/share/doc/heartbeat-3.0.4/
cp authkeys ha.cf haresources /etc/ha.d/
cd /etc/ha.d/
chmod 600 authkeys
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 的安装包
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
本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-03/141524.htm