共计 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/
![HA 高可用集群搭建 HA 高可用集群搭建](https://s.xgss.net/sky/2022-01-21/d577c59f370b288b70fe2d333c77ced8.png)
chmod 600 authkeys
![HA 高可用集群搭建 HA 高可用集群搭建](https://s.xgss.net/sky/2022-01-21/a12c1099b4d26ade561b0be42a6ddfd7.png)
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
![post-qrcode](https://www.xgss.net/wp-content/uploads/2023/07/二维码-微信公众号256x256.jpg)