天天看點

heartbeat部署指南

兩台機器的環境:

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         localhost localhost.localdomain 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   互相添加路由

[root@data-1-2 ~]# route add -host 10.0.10.7 dev eth2   互相添加路由

更新yum源:

[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        檢查是否已安裝上

epel-release-6-8.noarch

[root@data-1-2 yum.repos.d]# sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf  是否留下軟體包

[root@data-1-2 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配置檔案:

[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

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配置檔案

[root@data-1-2 html]# echo chenjisong|sha1sum    

8e901fca8d58aa2e2b315b4af1769ffe54e5257a  -

[root@data-1-2 ha.d]# cat authkeys 

auth 1

1 sha1 8e901fca8d58aa2e2b315b4af1769ffe54e5257a

[root@data-1-1 ha.d]# chmod 600 authkeys

haresources 配置檔案

[root@data-1-2 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

[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

兩台機器上面安裝httpd

然後啟停heartbeat服務,檢視ip漂移過程

heartbeat的使用場景:

<a href="http://s5.51cto.com/wyfs02/M01/76/D2/wKiom1ZdNJXQYfXqAAEfjs0eARs109.png" target="_blank"></a>

     本文轉自陳繼松 51CTO部落格,原文連結:http://blog.51cto.com/chenjisong/1718480,如需轉載請自行聯系原作者

繼續閱讀