集群基础------(heartbeat心跳组件)

集群间心跳(heartbeat)

1.下载安装心跳组件&—两个节点均要安装

    heartbeat-3.0.4-2.el6.x86_64.rpm
    heartbeat-devel-3.0.4-2.el6.x86_64.rpm
    heartbeat-libs-3.0.4-2.el6.x86_64.rpm
yum install -y heartbeat-*

2.修改heartbeat配置文件(heartbeat没有健康检查)
cd /etc/ha.d/

1)查看配置定义:
[root@server1 ha.d]# cat README.config
You need three configuration files to make heartbeat happy,
and they all go in this directory.

They are:
    ha.cf       Main configuration file(主配置文件)
    haresources Resource configuration file(资源定义文件)
    authkeys    Authentication information(认证文件)

These first two may be readable by everyone, but the authkeys file
must not be.

The good news is that sample versions of these files may be found in
the documentation directory (providing you installed the documentation).

If you installed heartbeat using rpm packages then
this command will show you where they are on your system:
        rpm -q heartbeat -d

If you installed heartbeat using Debian packages then
the documentation should be located in /usr/share/doc/heartbeat

[root@server1 ha.d]# cd /usr/share/doc/heartbeat-3.0.4/
[root@server1 heartbeat-3.0.4]# ls
apphbd.cf  ChangeLog     ha.cf
authkeys   COPYING       haresources
AUTHORS    COPYING.LGPL  README

2)复制主配置文件到/etc/ha.d/才能生效

 cd /usr/share/doc/heartbeat-3.0.4/
 cp ha.cf authkeys haresources /etc/ha.d/

3)修改主配置文件(在主节点修改)
cd /etc/ha.d/

    vim ha.cf   (调用ipfaill插件用于主备切换,实现高可用)

34 logfacility     local0
48 keepalive 2      心跳频率
56 deadtime 30      多久一次判断是否挂了
61 warntime 10      多久警告一次
71 initdead 60      初始化时间
76 udpport 733      端口连接(局域网不能冲突了)
91 bcast   eth0     广播发送
157 auto_failback on    自动回切
211 node    server1
212 node    server4
220 ping 172.25.39.250(和227行的ping群设定一个即可)
253 respawn hacluster /usr/lib64/heartbeat/ipfail(64位)
259 apiauth ipfail gid=haclient uid=hacluster(api认证,在装rpm包时候,用户已经被创建)

4)修改认证文件
cd /etc/ha.d/

    vim authkeys
23 auth 1
24 1 crc

       chmod 600 authkeys (认证key必须600权限,不然访问不了)*

5)修改资源定义文件
cd /etc/ha.d/(可以自动搜索这三个地方的脚本/etc/ha.d/rc.d/、/etc/ha.d/resourced)

    vim haresources
151 server1 IPaddr::172.25.39.100/24/eth0 httpd(IPaddr:资源脚本名;后面传参)(eth0:vip生效的地方)【主节点的主机名、vip、需要维护的服务】

3.发送相同的三个文件到server4

    scp ha.cf authkeys haresources server4:/etc/ha.d/

4.
1)/etc/init.d/heartbeat start(server1)
tail -f /var/log/messages(查看是否有错误)
2)开启server4上的心跳

5.测试:

编写测试页:/var/www/html/index.html
    (/etc/init.d/heartbeat stop
    /etc/init.d/heartbeat start)
可以在网页上测试172.25.78.100或者在主机上 curl 172.25.78.100
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章