三、安装与配置heartbrat
1.heartbeat v2安装与配置
(1).安装heartbrat
node1:
[root@node ~]# yum -y install heartbeat*
node2:
[root@node ~]# yum -y install heartbeat*
(2).配置heartbeat
说明:默认安装好heartbeat没有配置文件,但是样例文件
root@node1 ~]# cd /usr/share/doc/heartbeat-2.1.4/
[root@node1 heartbeat-2.1.4]# ls
apphbd.cf COPYING faqntips.txt HardwareGuide.html hb_report.txt README rsync.txt
authkeys COPYING.LGPL GettingStarted.html HardwareGuide.txt heartbeat_api.html Requirements.html startstop
AUTHORS DirectoryMap.txt GettingStarted.txt haresources heartbeat_api.txt Requirements.txt
ChangeLog faqntips.html ha.cf hb_report.html logd.cf rsync.html
注:这里我们只需要两个文件,ha.cf 与 authkeys
[root@node1 ha.d]# dd if=/dev/random bs=512count=1| openssl md5 #生成密钥随机数
0+1records in
0+1records out
128bytes (128B) copied, 0.000214seconds, 598kB/s
a4d20b0dd3d5e35e0f87ce4266d1dd64
[root@node1 ~]# vim /etc/ha.d/authkeys
auth 1
1 md5 a4d20b0dd3d5e35e0f87ce4266d1dd64
[root@node1 ha.d]# chmod 600 authkeys #修改密钥文件的权限为600
[root@node1 ha.d]# vim ha.cf
主要修改两处(其它都可以默认):
(1).修改心跳信息的传播方式(这里是组播)
mcast eth0 225.100.100.100 694 1 0
(2).配置集群中的节点数
node node1.test.com
node node2.test.com
(3).启用crm
crm on
2.复制以上两个配置文件到node2上
[root@node1 ha.d]# scp authkeys ha.cf node2:/etc/ha.d/
3.启动节点
[root@node1 ha.d]# ssh node2 "service heartbeat start"
Strting High-Availability services:
[确定]
logd is already stopped
[root@node1 ha.d]# service heartbeat start
Starting High-Availability services:
2013/08/07_17:19:22 INFO: Resource is stopped
[确定]
4.查看一下端口
node1:
[root@node1 ~]# netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:616 0.0.0.0:* LISTEN 2554/rpc.statd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2515/portmap
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2850/cupsd
tcp 0 0 0.0.0.0:5560 0.0.0.0:* LISTEN 3170/mgmtd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2940/sendmail: acce
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 17808/0
tcp 0 0 :::22 :::* LISTEN 2837/sshd
tcp 0 0 ::1:6010 :::* LISTEN 17808/0
udp 0 0 0.0.0.0:50185 0.0.0.0:* 2925/heartbeat: wri
udp 0 0 0.0.0.0:47376 0.0.0.0:* 3069/avahi-daemon:
udp 0 0 0.0.0.0:694 0.0.0.0:* 2925/heartbeat: wri
udp 0 0 0.0.0.0:610 0.0.0.0:* 2554/rpc.statd
udp 0 0 0.0.0.0:613 0.0.0.0:* 2554/rpc.statd
udp 0 0 0.0.0.0:5353 0.0.0.0:* 3069/avahi-daemon:
udp 0 0 0.0.0.0:111 0.0.0.0:* 2515/portmap
udp 0 0 0.0.0.0:631 0.0.0.0:* 2850/cupsd
udp 0 0 :::5353 :::* 3069/avahi-daemon:
udp 0 0 :::46332 :::* 3069/avahi-daemon:
node2:
[root@node1 ~]# netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:616 0.0.0.0:* LISTEN 2554/rpc.statd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2515/portmap
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2850/cupsd
tcp 0 0 0.0.0.0:5560 0.0.0.0:* LISTEN 3170/mgmtd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2940/sendmail: acce
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 17808/0
tcp 0 0 :::22 :::* LISTEN 2837/sshd
tcp 0 0 ::1:6010 :::* LISTEN 17808/0
udp 0 0 0.0.0.0:50185 0.0.0.0:* 2925/heartbeat: wri
udp 0 0 0.0.0.0:47376 0.0.0.0:* 3069/avahi-daemon:
udp 0 0 0.0.0.0:694 0.0.0.0:* 2925/heartbeat: wri
udp 0 0 0.0.0.0:610 0.0.0.0:* 2554/rpc.statd
udp 0 0 0.0.0.0:613 0.0.0.0:* 2554/rpc.statd
udp 0 0 0.0.0.0:5353 0.0.0.0:* 3069/avahi-daemon:
udp 0 0 0.0.0.0:111 0.0.0.0:* 2515/portmap
udp 0 0 0.0.0.0:631 0.0.0.0:* 2850/cupsd
udp 0 0 :::5353 :::* 3069/avahi-daemon:
udp 0 0 :::46332 :::* 3069/avahi-daemon:
注:上面端口号可以看出,heartbeat已经正常启动。
5.查看一下集群状态
注:两个节点都在线,资源暂时还没有配置。
6.测试一下hb_gui图形配置界面
[root@node1 ~]# hb_gui &
[1] 20377