hostname 设置好,分别为master 和 slave
关闭防火墙 iptables -F;
关闭selinux: setenforce 0vi /etc/hosts // 增加内容如下:
192.168.100.5 master
192.168.100.13 slave主上(master)配置
cp authkeys ha.cf haresources /etc/ha.d/
cd /etc/ha.d
vi authkeys //加入
3 md5 Hello!chmod 600 authkeys
vi haresources //加入
master 192.168.100.110/24/eth0:0 nginx //VIP
vi ha.cf //改为如下内容:
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 60
udpport 694
ucast eth0 192.168.100.13 //这里写对方ip
auto_failback on
node master //两个主机名
node slave
ping 192.168.100.1 //仲裁
respawn hacluster /usr/lib64/heartbeat/ipfail //64位要写lib64
5.把主上的三个配置拷贝到从上:
cd /etc/ha.d/
scp authkeys ha.cf haresources aming1:/etc/ha.d/
6.到从上(slave) 编辑ha.cf
vi /etc/ha.d/ha.cf //只需要更改一个地方
ucast eth1 192.168.100.13 改为 ucast eth1 192.168.100.5
7.启动heartbeat :
先主,后从
service heartbeat start