两台机器的环境:
data-1-1 eth0 10.0.0.7 eth1 172.16.1.7 eth2 10.0.10.7
data-1-2 eth0 10.0.0.8 eth1 172.16.1.8 eth2 10.0.10.8
[[email protected] ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.10.7 data-1-1
10.0.10.8 data-1-2
[[email protected] ~]# route add -host 10.0.10.8 dev eth2 互相添加路由
[[email protected] ~]# route add -host 10.0.10.7 dev eth2 互相添加路由
更新yum源:
[[email protected] ~]# mkdir /home/oldboy/tools -p
[[email protected] ~]# cd /home/oldboy/tools
[[email protected] tools]# wget http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
[[email protected] tools]# rpm -ivh epel-release-6-8.noarch.rpm
[[email protected] yum.repos.d]# rpm -qa|grep epel 检查是否已安装上
epel-release-6-8.noarch
[[email protected] yum.repos.d]# sed -i ‘s#keepcache=0#keepcache=1#g‘ /etc/yum.conf 是否留下软件包
[[email protected] yum.repos.d]# yum install heartbeat* -y 都需要安装heartbeat软件及其依赖
启动脚本:/etc/init.d/heartbeat
配置文件目录:/etc/ha.d
资源控制目录:/etc/ha.d/resource.d
核心的配置文件:authkey haresource ha.cf
配置文件模版放置目录:/usr/share/doc/heartbaeat-3.0.4
ha.cf配置文件:
[[email protected] ha.d]# cat /etc/ha.d/ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 60
udpport 694
mcast eth0 225.0.0.1 694 1 0
auto_failback on
node data-1-1
node data-1-2
crm no
authkeys配置文件
[[email protected] html]# echo chenjisong|sha1sum
8e901fca8d58aa2e2b315b4af1769ffe54e5257a -
[[email protected] ha.d]# cat authkeys
auth 1
1 sha1 8e901fca8d58aa2e2b315b4af1769ffe54e5257a
[[email protected] ha.d]# chmod 600 authkeys
haresources 配置文件
[[email protected] ha.d]# cat haresources
data-1-1 IPaddr::10.0.0.17/24/eth0 ====虚拟IP
data-1-2 IPaddr::10.0.0.18/24/eth0 ====虚拟IP
[[email protected] ha.d]# /etc/ha.d/resource.d/IPaddr 10.0.0.17/24/eth0 start
[[email protected] ha.d]# ip a|grep 10.0.0.17
inet 10.0.0.17/24 brd 10.0.0.255 scope global secondary eth0
[[email protected] ha.d]# /etc/ha.d/resource.d/IPaddr 10.0.0.18/24/eth0 start
[[email protected] ha.d]# ip a|grep 10.0.0.18
inet 10.0.0.18/24 brd 10.0.0.255 scope global secondary eth0
两台机器上面安装httpd
然后启停heartbeat服务,查看ip漂移过程
heartbeat的使用场景: