In the previous deployment process, heartbeat was successfully deployed and configured, and the high availability of VIPs between two nodes was achieved, where the high availability of the HTTPD service was configured and implemented.
First, install Apache
Both heartbeat node servers stop the heartbeat service first.
/etc/init.d/heartbeat stop
Install the HTTPD service on heartbeat01 and heartbeat02 respectively
Yum-y Install httpd
Execute on two nodes, respectively
Echo $HOSTNAME >>/var/www/html/index.html
Chown-r apache:apache/var/www/html
/ETC/INIT.D/HTTPD start
View Web Services in a browser
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/87/F8/wKiom1fk9o7CGDRHAAB2xla7bsM134.png-wh_500x0-wm_3 -wmp_4-s_1879953107.png "style=" Float:none; "title=" 0001.png "alt=" Wkiom1fk9o7cgdrhaab2xla7bsm134.png-wh_50 "/>
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/87/F8/wKiom1fk9o6ALLBVAABvqvTxR00451.png-wh_500x0-wm_3 -wmp_4-s_4236257510.png "style=" Float:none; "title=" 0002.png "alt=" Wkiom1fk9o6allbvaabvqvtxr00451.png-wh_50 "/>
Ii. Configuration of Heartbeat resources
Define resources: defined in the configuration file of the resource manager,/etc/ha.d/haresources, there are various resource types under/ETC/HA.D/RESOURCE.D, and when defined in the resource configuration file, the resource types are called to run the corresponding programs;
Script Requirements for heartbeat control:
1) The script path should be placed in the/etc/init.d/or/etc/ha.d/resource.d/directory.
2) script execution requires the/etc/init.d/script name Stop|start mode.
3) scripts need to have executable permissions
4) The name of the script should match the name in haresources (e.g. heartbeat01.contoso.com ipaddr::172.16.49.100/24/eth1 httpd)
Here, the haresources of the two nodes are modified to read as follows:
Heartbeat01.contoso.com ipaddr::172.16.49.100/24/eth1 httpd
Third, start heartbeat and test failover
Execute on two nodes, respectively
Echo $HOSTNAME >>/var/www/html/index.html
Then, because the DNS server is not configured, in the Hosts file of the client Windows, add the following:
172.16.49.100 www.contoso.com
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/87/F5/wKioL1fk-BjDhl57AACBZrO4qco056.png-wh_500x0-wm_3 -wmp_4-s_558871368.png "title=" 0004.png "alt=" Wkiol1fk-bjdhl57aacbzro4qco056.png-wh_50 "/>
The following operations need to be performed on two heartbeat nodes at the same time:
/ETC/INIT.D/HTTPD stop
/etc/init.d/heartbeat stop
Check the status of the service:
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/87/F5/wKioL1fk9uOzNOdiAAAc7_yQ9nk494.png-wh_500x0-wm_3 -wmp_4-s_166335717.png "style=" Float:none; "title=" 0006.png "alt=" Wkiol1fk9uoznodiaaac7_yq9nk494.png-wh_50 "/>
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/87/F8/wKiom1fk9uPh1lPXAAAZhIBk5yk825.png-wh_500x0-wm_3 -wmp_4-s_2461467958.png "style=" Float:none; "title=" 0007.png "alt=" Wkiom1fk9uph1lpxaaazhibk5yk825.png-wh_50 "/>
As you can see, both the httpd service and the heartbeat service on the two nodes are in a stopped state.
Then execute the/etc/init.d/heartbeat Start command at the same time to start the heartbeat service on two nodes.
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/87/F5/wKioL1fk9w2grN8uAAAtgGOCnHc781.png-wh_500x0-wm_3 -wmp_4-s_4178055204.png "style=" Float:none; "title=" 0008.png "alt=" Wkiol1fk9w2grn8uaaatggocnhc781.png-wh_50 "/>
Here you can see that the VIP is on Node 1 heartbeat01, and the httpd service on heartbeat01 has been started.
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/87/F8/wKiom1fk9w3jUg2VAAAfBpmeF7I375.png-wh_500x0-wm_3 -wmp_4-s_2728530989.png "style=" Float:none; "title=" 0009.png "alt=" Wkiom1fk9w3jug2vaaafbpmef7i375.png-wh_50 "/>
There is no VIP on the heartbeat02 and the httpd service is off.
Windows Client Access:
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/87/F5/wKioL1fk-GWRTwVIAACKToh2vJM617.png-wh_500x0-wm_3 -wmp_4-s_1002673800.png "title=" 0005.png "alt=" Wkiol1fk-gwrtwviaacktoh2vjm617.png-wh_50 "/>
At this point I manually shut down the heartbeat service on heartbeat01 and see the status of the two nodes again:
Node 1:
[[email protected] ~]#/etc/init.d/heartbeat stop
Stopping high-availability Services:done.
[[Email protected] ~]# IP addr |grep 172.16.49
inet 172.16.49.133/24 BRD 172.16.49.255 Scope Global eth1
[[Email protected] ~]# service httpd status
HTTPD is stopped
Node 2:
[[Email protected] ha.d]# IP a|grep 172.16.49
inet 172.16.49.134/24 BRD 172.16.49.255 Scope Global eth1
inet 172.16.49.100/24 BRD 172.16.49.255 scope Global Secondary eth1
[[Email protected] ha.d]# service httpd status
HTTPD (PID 13469) is running ...
[Email protected] ha.d]#
Windows Client Access:
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/87/F8/wKiom1fk9kjiE09SAABymRSQhf8612.png-wh_500x0-wm_3 -wmp_4-s_2330188371.png "title=" 0010.png "alt=" Wkiom1fk9kjie09saabymrsqhf8612.png-wh_50 "/>
After heartbeat01 stopped the service, heartbeat02 successfully took over the resources and was able to provide services.
Then restart the heartbeat service on heartbeat01, and look at the status of the two nodes separately:
Node 1:
[Email protected] ~]#/etc/init.d/heartbeat status
Heartbeat is stopped. No process
[[email protected] ~]#/etc/init.d/heartbeat start
Starting high-availability Services:INFO:Resource is stopped
Done.
[[Email protected] ~]# IP addr |grep 172.16.49
inet 172.16.49.133/24 BRD 172.16.49.255 Scope Global eth1
inet 172.16.49.100/24 BRD 172.16.49.255 scope Global Secondary eth1
[[Email protected] ~]# service httpd status
HTTPD (PID 15545) is running ...
Node 2:
[[Email protected] ha.d]# IP a|grep 172.16.49
inet 172.16.49.134/24 BRD 172.16.49.255 Scope Global eth1
[[Email protected] ha.d]# service httpd status
HTTPD is stopped
Windows Client Access:
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/87/F8/wKiom1fk-YnC3TYPAABuzrTskEA833.png-wh_500x0-wm_3 -wmp_4-s_1064086107.png "title=" 0011.png "alt=" Wkiom1fk-ync3typaabuzrtskea833.png-wh_50 "/>
After the heartbeat01 resumes, it takes over the original service, heartbeat02 the resource back to heartbeat01, and closes the Web service at the same time. At this point, heartbeat implements high availability of Web services.
This article is from "it Little two lang" blog, please make sure to keep this source http://jerry12356.blog.51cto.com/4308715/1855918
Heartbeat enabling high availability of Web services