实验平台:virtualbox 4.12
- heartbeat-2.1.4-9.el5.i386.rpm
- heartbeat-devel-2.1.4-9.el5.i386.rpm
- heartbeat-gui-2.1.4-9.el5.i386.rpm
- heartbeat-pils-2.1.4-10.el5.i386.rpm
- heartbeat-stonith-2.1.4-10.el5.i386.rpm
- libnet-1.1.4-3.el5.i386.rpm
- [root@DIR ~]# yum localinstall *.rpm --nogpgcheck -y
- 192.168.56.10 node1.a.org node1
- 192.168.56.30 node2.a.org node2
- [root@DIR ~]# ssh-keygen -t rsa
- [root@DIR ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node2
- [root@DIR2 ~]# ssh-keygen -t rsa
- [root@DIR2 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node1
- [root@DIR2 ~]# yum localinstall -y *.rpm –nogpgcheck
- [root@node1 ~]# cp /usr/share/doc/heartbeat-2.1.4/{ha.cf,haresources,authkeys} /etc/ha.d/
- [root@node1 ha.d]# cd /etc/ha.d/
- [root@node1 ha.d]# vim ha.cf
- logfile /var/log/ha-log //打开日志
- bcast eth1 //监测心跳的网卡
- node node1.a.org
- node node2.a.org //定义集群节点
- respawn hacluster /usr/local/lib64/heartbeat/ipfail
- apiauth ipfail gid=haclient uid=hacluster //定义随heartbeat一起启动的进程
- [root@node1 ha.d]# vim authkeys
- auth 2 //这里是用来指定认证方式的
- 2 sha1 e781edf0090887bee14405fd48768ac6(随机数)
- //随机数可以用下面的命令生成
- [root@node1 ~]# dd if=/dev//urandom bs=512 count=1 | md5sum
- [root@node1 ha.d]# chmod 400 authkeys //修改该文件的权限为400或600
- [root@node1 ha.d]# vim haresources
- //在其中写入:
- node1.a.org 192.168.56.20/24/eth0/192.168.56.255 httpd
- [root@node1 ha.d]# scp ha.cf haresources authkeys node2:/etc/ha.d
- [root@node1 ~]# /etc/init.d/heartbeat start
- [root@node1 ~]# ssh node2 -- `/etc/init.d/heartbeat start`
- [root@node1 ~]# service heartbeat status //查看一下heartbeat运行状态
- [root@node1 ~]# service heartbeat stop
- [root@node2 ha.d]# service heartbeat status
- [root@node1 ~]# ifconfig