Environment of two machines:
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
[root@data-1-2 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost6 localhost6.localdomain6
10.0.10.7 data-1-1
10.0.10.8 data-1-2
[root@data-1-1 ~]# route add -host 10.0.10.8 dev eth2 Add routes to each other< /p>
[root@data-1-2 ~]# route add -host 10.0.10.7 dev eth2 Add routes to each other
Update yum source:
[root@data-1-1 ~]# mkdir /home/oldboy/tools -p
[root@data-1-1 ~]# cd/home/oldboy /tools
[root@data-1-1 tools]# wget http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch .rpm
[root@data-1-1 tools]# rpm -ivh epel-release-6-8.noarch.rpm
[root@data-1-2 yum.repos.d]# rpm -qa|grep epel Check if it is installed
epel-release-6-8.n oarch
[root@data-1-2 yum.repos.d]# sed -i’s#keepcache=0#keepcache=1#g’ / etc/yum.conf Whether to leave the software package
[root@data-1-2 yum.repos.d]# yum install heartbeat* -y Requires Install the heartbeat software and its dependencies
Startup script: /etc/init.d/heartbeat
Configuration file directory: /etc/ha. d
Resource control directory: /etc/ha.d/resource.d
Core configuration file: authkey haresource ha.cf
Configuration file template placement Directory: /usr/share/doc/heartbaeat-3.0.4
ha.cf configuration file:
[root@data-1 -1 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
< p>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 configuration file
[root@data-1-2 html] # echo chenjisong|sha1sum
8e901fca8d58aa2e2b315b4af1769ffe54e5257a
[root@data-1-2 ha.d]# cat authkeys
aut h 1
1 sha1 8e901fca8d58aa2e2b315b4af1769ffe54e5257a
[root@data-1-1 ha.d]# chmod 600 authkeys
< p>haresources configuration file
[root@data-1-2 ha.d]# cat haresources
data-1-1 IPaddr::10.0.0.17/24/eth0 = ===Virtual IP
data-1-2 IPaddr::10.0.0.18/24/eth0 ====Virtual IP
[root@data-1-1 ha.d]# /etc/ha.d/resource.d/IPaddr 10.0.0.17/24/eth0 start
[root@data-1-1 ha. d]# ip a|grep 10.0.0.17
inet 10.0.0.17/24 brd 10.0.0.255 scope global secondary eth0
[root@data-1-2 ha.d]# /etc/ha.d/resource.d/IPaddr 10.0.0.18/ 24/eth0 start
[root@data-1-2 ha.d]# ip a|grep 10.0.0.18
inet 10.0.0.18/24 brd 10.0.0.255 scope global secondary eth0
Install httpd on both machines
p>
Then start and stop the heartbeat service and check the ip drift process
h Use scenarios of eartbeat: