阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

HA高可用集群搭建

211次阅读
没有评论

共计 1442 个字符,预计需要花费 4 分钟才能阅读完成。

准备 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
HA 高可用集群搭建
HA 高可用集群搭建
chmod 600 authkeys
vim haresources
这里的 ip 是 vip:
HA 高可用集群搭建
HA 高可用集群搭建
 
主从不一样的就是下面这个配置文件:
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

HA 高可用集群搭建
HA 高可用集群搭建

 

HA 高可用集群搭建

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-03/141524.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计1442字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中