Heartbeat simple high-availability cluster setup under Linux

Source: Internet
Author: User

The Heartbeat project is an integral part of the LINUX-HA project, which implements a highly available cluster system. With heartbeat we can implement dual-machine hot-standby to achieve the continuity of service.

High-availability cluster construction based on heartbeat simple Web service under Linux

First of all, the planning of two hosts as heartbeat of the dual-machine hot standby, named node1.lvni.cc (master); node2.lvni.cc,

Node1 's eth0ip:192.168.157.148 Vip eth0:0:192.168.157.149

Node2 's eth0ip:192.168.157.150

When planning is complete, prepare for the two node

1, change the host name, so that the two hosts can parse each other

Execute command hostname node1.lvni.cc/node2.lvni.cc (temporary) on both hosts

Modify the primary configuration file to be modified (permanent)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/5D/wKiom1Uruc6S9EECAAB0GBIZcKk934.jpg "title=" 27.PNG "alt=" Wkiom1uruc6s9eecaab0gbizckk934.jpg "/>

Note Uname-n (be sure to sync)


2. Generate the key through SSH, build up the trust of the machine

Generate a key file on two nodes to copy to the other node separately

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/59/wKioL1UrvHuDXGDeAAFWGdNiU_o294.jpg "style=" float: none; "title=" 2.PNG "alt=" Wkiol1urvhudxgdeaafwgdniu_o294.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6B/5E/wKiom1UruzritssuAAHKsk9ny70494.jpg "style=" float: none; "title=" 3.PNG "alt=" Wkiom1uruzritssuaahksk9ny70494.jpg "/>


Free login after completion of execution

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/5A/wKioL1UrvXDx4Dc6AABh943Z82k294.jpg "title=" 5.PNG " alt= "Wkiol1urvxdx4dc6aabh943z82k294.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/5A/wKioL1Urva2DcSH4AAB5Neruf20634.jpg "title=" 6.PNG " alt= "Wkiol1urva2dcsh4aab5neruf20634.jpg"/>


3. Synchronize the two nodes with time

The NTP server can be easily built on the Node1 node, and Node2 can be synchronized by crontab every five minutes.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/5F/wKiom1UrvXPCuyNNAABfWYG78-A186.jpg "title=" 28.PNG "alt=" Wkiom1urvxpcuynnaabfwyg78-a186.jpg "/>


After everything is ready, install heartbeat

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/5A/wKioL1Urv47iKsQLAAI7wR43U88262.jpg "style=" float: none; "title=" 10.PNG "alt=" Wkiol1urv47iksqlaai7wr43u88262.jpg "/>


To resolve dependencies, install with Yum

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6B/5A/wKioL1Urv5-x9y53AALeKJGckmI390.jpg "style=" float: none; "title=" 11.PNG "alt=" Wkiol1urv5-x9y53aalekjgckmi390.jpg "/>


Installation is complete.

Configuring the Heartbeat

Copy the Authkey ha.cf haresources file under the/usr/share/doc/heartbeat-2.1.4 directory to the/ETC/HA.D directory

Note Authkey permissions are 600 other permissions are not changed

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/5A/wKioL1UrwUWxzBZ_AAF0Slix9fM022.jpg "title=" 25.PNG "alt=" Wkiol1urwuwxzbz_aaf0slix9fm022.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/5F/wKiom1UrwDugpkpbAAFJOfiyPZk063.jpg "title=" 29.PNG "alt=" Wkiom1urwdugpkpbaafjofiypzk063.jpg "/>

Configure when you are done

Authkey three kinds of encryption

Here for a simple CRC encryption

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/5A/wKioL1Urwg7BtGAgAACePxf4ZPI889.jpg "title=" 14.PNG "alt=" Wkiol1urwg7btgagaacepxf4zpi889.jpg "/>


HA.CF file, primary definition node

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/5A/wKioL1UrwkLCRR3uAADQPBKhgJs338.jpg "title=" 15.PNG "alt=" Wkiol1urwklcrr3uaadqpbkhgjs338.jpg "/>


Important: The configuration of the Haresources resource file.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/5A/wKioL1Urwr_SzgFIAAElHvFlbiE109.jpg "title=" 16.PNG "alt=" Wkiol1urwr_szgfiaaelhvflbie109.jpg "/>

Defines the virtual IP httpd


The configuration of the main two nodes is exactly the same!


After completion, install the HTTPD service on both nodes

First Test the HTTPD service

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/5F/wKiom1UrwxnyfYmrAAB2NKly0lA864.jpg "style=" float: none; "title=" 30.PNG "alt=" Wkiom1urwxnyfymraab2nkly0la864.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6B/5F/wKiom1UrwyqylR3jAACEhSLJKrM411.jpg "style=" float: none; "title=" 31.PNG "alt=" Wkiom1urwyqylr3jaacehsljkrm411.jpg "/>


When you are done, start heartbeat

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6B/5B/wKioL1UrxPKDhHTWAAEYKB6iiSA707.jpg "title=" 17.PNG "alt=" Wkiol1urxpkdhhtwaaeykb6iisa707.jpg "/>

View Node IP

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/5F/wKiom1Urw_CiLdupAAMKlDXOL60494.jpg "style=" float: none; "title=" 19.PNG "alt=" Wkiom1urw_cildupaamkldxol60494.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/5B/wKioL1UrxVDjW1HMAAKcZCSCxaU298.jpg "style=" float: none; "title=" 18.PNG "alt=" Wkiol1urxvdjw1hmaakczcscxau298.jpg "/>

Perform initial testing

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/5F/wKiom1Urw_CiLdupAAMKlDXOL60494.jpg "style=" float: none; "title=" 19.PNG "alt=" Wkiom1urw_cildupaamkldxol60494.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/5B/wKioL1UrxVDjW1HMAAKcZCSCxaU298.jpg "style=" float: none; "title=" 18.PNG "alt=" Wkiol1urxvdjw1hmaakczcscxau298.jpg "/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/5B/wKioL1UrxffgMT_TAAB7Olu2yI8659.jpg "title=" 32.PNG "alt=" Wkiol1urxffgmt_taab7olu2yi8659.jpg "/>


Now standby stop node1 with heartbeat script

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/5F/wKiom1UrxSLCnVa0AAE5_Mpog30475.jpg "title=" 20.PNG "alt=" Wkiom1urxslcnva0aae5_mpog30475.jpg "/>


View site

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6B/5F/wKiom1UrxU2wdvVEAAB6cFfOCc0195.jpg "title=" 21.PNG "alt=" Wkiom1urxu2wdvveaab6cffocc0195.jpg "/>

View IP

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/5B/wKioL1UrxtHxOryFAAKHwwc2POM869.jpg "style=" float: none; "title=" 22.PNG "alt=" Wkiol1urxthxoryfaakhwwc2pom869.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/5F/wKiom1UrxYLy775dAAJcE_03v-8858.jpg "style=" float: none; "title=" 23.PNG "alt=" Wkiom1urxyly775daajce_03v-8858.jpg "/>

Success! And you can view the log information through Tail-f/var/log/message.


This article is from the "Filter New" blog, please be sure to keep this source http://wahehe.blog.51cto.com/8935316/1632016

Heartbeat simple high-availability cluster setup under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.