192.168.164.116 主机
192.168.164.117 备份机
192.168.164.118 虚拟ip
1、配置主机名:
第一步:
hostname node1
第二步:
修改/etc/sysconfig/network中的hostname
第三步:
修改/etc/hosts文件
192.168.164.116 node1
192.168.164.117 node2
2、安装heartbeat:
运行一下命令:
wget
rpm -ivh epel-release-6-8.noarch.rpm
yum install heartbeat
3、配置ha.cf文件:
运行以下命令:
cp /usr/share/doc/heartbeat-3.0.4/ha.cf /etc/ha.d/
cd /etc/ha.d
vim /etc/ha.d/ha.cf
然后编辑ha.cf文件,内容如下:
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 5
udpport 694
bcast eth0
auto_failback on
node node1
node node2
4、配置authkeys文件:
运行如下命令:
vim /etc/ha.d/authkeys
然后修改authkeys中的内容:
auth 1
1 sha1 HI!
chmod 600 /etc/ha.d/authkeys
5、配置haresources文件:
vim /etc/ha.d/haresources
然后修改haresources的内容:
node1 IPaddr::192.168.18.118/24/eth0
6、测试
在node1和node2中分别运行一下命令:
/etc/init.d/heartbeat start
关闭node1 /etc/init.d/heartbeat stop
看看是否正常切换
阅读(466) | 评论(0) | 转发(0) |