1. experiment environment
HA1: 192.168.1.17RHEL5.8 _ 32bit, web server)
HA2: 192.168.1.18RHEL5.8 _ 32bit, web server)
NFS: 192.168.1.19RHEL5.8 _ 32bit, nfs server)
VIP: 192.168.1.20
2. Preparations
<1> Configure the Host Name
The node name is parsed using/etc/hosts. The node name must be consistent with the execution result of the uname-n command.
HA1:
# hostname node1.ikki.com# vim /etc/sysconfig/networkHOSTNAME=node1.ikki.com
HA2:
# hostname node1.ikki.com# vim /etc/sysconfig/networkHOSTNAME=node2.ikki.com
<2> Configure nodes for ssh key-based communication
HA1:
# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.18
HA2:
# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.17
<3> Configure Communication Between Nodes Based on host names
HA1 & HA2:
# vim /etc/hosts192.168.1.17 node1.ikki.com node1192.168.1.18 node2.ikki.com node2
<4> Configure Time Synchronization for each node
HA1 & HA2:
# crontab -e*/5 * * * * /sbin/ntpdate 202.120.2.101 &> /dev/null
3. Install Heartbeat v2
# yum --nogpgcheck localinstall perl-MailTools-1.77-1.el5.noarch.rpm#yum--nogpgchecklocalinstall heartbeat-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
4. Configure Heartbeat v2 nodes)
# cd /etc/ha.d/# cp /usr/share/doc/heartbeat-2.1.4/{authkeys,ha.cf,haresources} ./# chmod 600 authkeys
<1> Configure authkeys
Generate random number:
# dd if=/dev/random count=1 bs=512 | md5sum# vim authkeysauth 11 md5 cbe6411e54d9bfbeef9cc1c48c7234fa
<2> Configure ha. cf
# Vim ha. cfkeepalive 1 # Set 1 second to detect a heartbeat mcast eth0 225.0.100.19 694 1 0 # Set the heartbeat information transmission mode to multicast node node1.ikki.com # Set each node Name node node2.ikki. comping 192.168.1.1 # Use ping gateway to determine survival status
<3> Configure haresources to set VIP and master node Services)
# vim haresourcesnode1.ikki.com IPaddr::192.168.1.20/24/eth0 httpd
Note that the following resources are arranged in sequence: VIP and httpd)
5. Configure each node of the WEB service)
# echo "
6. Start the Heartbeat v2 service to start the service on the master node HA1 and remotely start the service on HA2)
HA1:
# service heartbeat start# ssh node2 'service heartbeat start'
7. Test
Access http: // 192.168.1.20/
Use hb_standby to set HA1 as a slave node for debugging:
# /usr/lib/heartbeat/hb_standby
8. Set up the NFS service to mount the web directory on each node)
NFS:
# vim /etc/exports/web/htdocs 192.168.1.0/24(ro)# service nfs start# showmount -e 192.168.1.19# mkdir -p /web/htdocs# echo "
9. Stop the Heartbeat v2 service and configure each haresources node)
# service heartbeat stop# ssh node2 'service heartbeat stop'# vim /etc/ha.d/haresourcesnode1.ikki.com IPaddr::192.168.1.20/24/eth0 Filesystem::192.168.1.19:/web/htdocs::/var/www/html::nfs httpd
Note that the following resources are arranged in sequence: VIP, Filesystem, and httpd)
10. Start Heartbeat v2 and Test
HA1:
# service heartbeat start# ssh node2 'service heartbeat start'
Access http: // 192.168.1.20/
This article from the "Don't dead birds a Hui" blog, please be sure to keep this source http://phenixikki.blog.51cto.com/7572938/1304459