System centos6.0
Objective: The httpd service of two machines provides the same service and uses heartbeat to implement hot backup of httpd. to manage resources in a unified manner, the configuration must be written to both services, provides the nfs service for convenient management.
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G33223-0.jpg "title =" Photo 1.jpg "/>
Lv1: 192.168.182.130
Lv2: 192.168.182.129
Vip: 192.168.182.200
Nfsserver: 192.168.182.131
1. First on lv1 and lv2:
Configure hosts
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G34N3-1.jpg "title =" 2.jpg"/>
When the httpdservice is started, the index.html of the two machines is differentiated, for example, lv1 and lv2 are displayed respectively.
2. Install heartbeat;
Yum install heartbeat libnet
1> cp/usr/share/doc/heartbeat-3.0.4/authkeys ha. cf haresources/etc/ha. d/
Configure ha. cf
Logfile/var/log/ha-log
Logfacility local0
Keepalive 2
Deadtime 10
Warntime 5
Initdead 120
Udpport 694
Bcast eth0
Auto_failback on
Node lv1
Node lv2
Ping 192.168.182.2 # Gateway
Ping_group group1 192.168.182.130 192.168.182.129
Respawn hacluster/usr/lib/heartbeat/ipfail
Configure authkeys
Auth 1
1 crc
#2 sha1 HI!
#3 md5 Hello!
Configure haresources
Lv1 IPaddr: 192.168.182.200/32/eth0: 0 httpd
2> scp to lv2.
Chmod 600 authkeys
Scp ha. cf haresources authkeys root @ lv2:/etc/ha. d/
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G36132-2.jpg "title =" 2.jpg"/>
3> Start httpd for verification;
Lv1:/etc/init. d/httpd start
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G343E-3.jpg "title =" 2.jpg"/>
Lv2:/etc/init. d/httpd start
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G34044-4.jpg "title =" 2.jpg"/>
Start heartbeat
Lv1:/etc/init. d/heartbeat start
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G31S9-5.jpg "title =" 2.jpg"/>
Lv2: Same as above
Then you will find the eth0: 0 Nic of lv1
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G3I16-6.jpg "title =" 2.jpg"/>
Httpd and heartbeat service status
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G32X9-7.jpg "title =" 2.jpg"/>
Access 192.168.182.200
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G32238-8.jpg "title =" 2.jpg"/>
It turns out that lv1 is a service provider.
We stopped the heartbeat service on lv1.
You will find that the eth0: 0 Nic on lv1 is gone, and it is drifting to lv2.
When you access 192.168.182.200
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G3BY-9.jpg "title =" 2.jpg"/>
Prove that lv2 is currently providing services
3. Enable nfs on the third machine nfsserver
1> yum install nfs rpcbind
/Etc/init. d/nfs start
Mkdir/root/data
Vim/etc/exports
/Root/data * (rw)
Exportfs-r
2. test whether the mount is normal on any machine.
Lv1 test:
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G354K-10.jpg "title =" 2.jpg"/>
The test is normal.
Umount out umount/mnt
Modify haresources on lv1 and lv2 respectively.
Lv1 IPaddr: 192.168.182.200/32/eth0: 0 Filesystem: 192.168.182.131:/root/data:/var/www/html: nfs httpd
Start httpd and heartbeat on lv1 and lv2 respectively.
Found in mount on lv1
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G36222-11.jpg "title =" 2.jpg"/>
2> Create a test file under/root/data on nfsserver
Vim index.html
Test
Open the browser http: // 192.168.182.200
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G35F3-12.jpg "title =" 2.jpg"/>
Test normal
4. test whether the link between nfs and the lv server is normal.
Stop heartbeat/etc/init. d/heartbeat stop on lv1.
Found under mount on lv2
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G33302-13.jpg "title =" 2.jpg"/>
The link is normal.
Lv2 ifconfig eth0: 0
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G31056-14.jpg "title =" 2.jpg"/>
Nfsserver
Vim index.html
Test \ test
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/013G34V2-15.jpg "title =" 2.jpg"/>
Test found OK !!!
So far, everything is OK
Only index.html on nfsservercan be modified to facilitate management;
This article is from the Coffee _ Blue Mountains blog, please be sure to keep this source http://lansgg.blog.51cto.com/5675165/1203542