标签:ha群集配置
heartbeat主机配置
第一步关闭防火墙及selinux
iptables -F
service iptables save
vim /etc/selinux/config
reboot
添加host文件内容
vim /etc/hosts
192.168.238.132 linux-server
192.168.238.133 linux-client
下载扩展源安装包
wget www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm
安装扩展源安装包
rpm -ivh epel-release-6-8_64.noarch.rpm
yum安装heartbeat及libnet
yum install -y heartbeat libnet
切换到安装目录拷贝文件到/etc/ha.d下
cd /usr/share/doc/heartbeat-3.0.4/
cp authkeys ha.cf haresources /etc/ha.d/
切换目录到/etc/ha.d编辑配置
cd /etc/ha.d/
vim authkeys
auth 3
3 md5 Hello!
并且赋予600读写权限给root
chmod 600 authkeys
vim haresources
linux-server 192.168.238.100/24/eth0:0 nginx
vim 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.238.133
auto_failback on
node linux-server
node linux-client
ping 192.168.238.1
respawn hacluster /usr/lib64/heartbeat/ipfail
拷贝编辑的此三个文件到第二台服务器的/etc/ha.d目录下
scp authkeys ha.cf haresources linux-client:/etc/ha.d/
安装nginx服务
yum install -y nginx
启动heartbeat服务
/etc/init.d/heartbeat start
heartbeat备机配置
关闭防火墙及selinux
iptables -F
service iptables save
vim /etc/selinux/config
reboot
配置host文件
vim /etc/hosts
192.168.238.132 linux-server
192.168.238.133 linux-client
下载epel扩展源
wget www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm
安装epel扩展源
rpm -ivh epel-release-6-8_64.noarch.rpm
yum install -y heartbeat libnet
切换到/etc/ha.d目录下编辑ha.cf文件,authkeys和haresources文件不用更改
cd /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 694
ucast eth0 192.168.238.133
auto_failback on
node linux-server
node linux-client
ping 192.168.238.1
respawn hacluster /usr/lib64/heartbeat/ipfail
yum install -y nginx
/etc/init.d/heartbeat start
环境测试
echo "this is heartbeat server11111111111111111111111111" > /usr/share/nginx/html/index.html 主机
echo "this is heartbeat server22222222222222222222222222" > /usr/share/nginx/html/index.html 备机
客户端浏览器访问192.168.238.100
出现“this is heartbeat server11111111111111111111111111" 正常
在服务器主机上添加一条防火墙规则,拒绝ping
iptables -A INPUT -p icmp -j DROP
客户端浏览器访问192.168.238.100
出现“this is heartbeat server22222222222222222222222222" 正常
删除刚才添加的防火墙规则
iptables -D INPUT -p icmp -j DROP
客户端浏览器访问192.168.238.100
出现“this is heartbeat server11111111111111111111111111" 正常
本文出自 “百闻世界” 博客,请务必保留此出处http://anson12315.blog.51cto.com/2441584/1914623
标签:ha群集配置
原文地址:http://anson12315.blog.51cto.com/2441584/1914623