Configure heartbeat high-availability cluster In Debian Linux

Source: Internet
Author: User
In Debian Linux, configure the heartbeat high-availability cluster-Linux Enterprise Application-Linux server application information. The following is a detailed description. Here, heartbeat is a linux-ha project, which is used by many high-availability systems. The configuration information of heartbeat is very complex, but the key is the several items.

1. Prepare the environment
Prepare two Debian Linux instances. The hostname and ip addresses are ha (192.168.0.167) and ha2 (192.168.0.139 ).

2. Install heartbeat
Use apt-get install heartbeat to install heartbeat for ha and ha2, saving you the need to install the dependent library libnet in other Linux environments.

3. Configure heartbeat
Three configuration files are required: authkeys, haresources, and ha. cf. These three configuration files need to be under the/etc/ha. d directory, but they are not available by default, so you can create them by yourself. simple configuration is simple:
Configure the same authkeys and haresources on ha and ha2 as follows:
# Cat authkeys
--------------
Auth 3
#1 crc
#2 sha1 HI!
3 md5 Hello!
--------------
1, 2, 3 indicates the authentication algorithm selection. The md5 algorithm is selected here.
And the authkeys File Permission must be 0600, so
# Chmod 0600 authkeys

# Cat haresources
--------------
Ha 192.168.0.2/24/eth0 apache
--------------
Ha is the master node name, 192.168.0.2/24/eth0 is the external virtual service IP Address/mask/NIC interface, apache indicates the resource Name, used to start and stop the apache service script, need in resource. create the apache script under the d directory and support the start and stop operations.

Ha. cf is slightly different on the two nodes,
The configuration of ha (192.168.0.167) is as follows:
# Cat ha. cf
--------------
Auto_failback off
# Note: after the master node is restarted successfully, will the resources be automatically retrieved back to the master node or the resources will be retrieved after the slave node is down?
Node ha
Node ha2
# Description: node name, And uname? N is consistent. Whether the master node is irrelevant to the order of its location. Specify in haresources
# Bcast eth0
# Note: The eth0 udp broadcast is used to send heartbeat information. We recommend that you use it when there are more than one secondary node.
Ucast eth0 192.168.0.139
# Note: Use the udp Unicast Network Card eth0 to notify the heartbeat. The ip address should be the peer IP address (not verified)
# Mcast eth0 225.0.0.1 694 1 0
# Note: udp multicast is used to notify heartbeat. We recommend that you use it when there are more than one slave node.
# Note: either broadcast, unicast, or multicasting is required.
--------------
Ha2 (192.168.0.139) is configured as follows:
# Cat ha. cf
--------------
Auto_failback off
# Note: after the master node is restarted successfully, will the resources be automatically retrieved back to the master node or the resources will be retrieved after the slave node is down?
Node ha
Node ha2
# Description: node name, And uname? N is consistent. Whether the master node is irrelevant to the order of its location. Specify in haresources
# Bcast eth0
# Note: The eth0 udp broadcast is used to send heartbeat information. We recommend that you use it when there are more than one secondary node.
Ucast eth0 192.168.0.167
# Note: Use the udp Unicast Network Card eth0 to notify the heartbeat. The ip address should be the peer IP address (not verified)
# Mcast eth0 225.0.0.1 694 1 0
# Note: udp multicast is used to notify heartbeat. We recommend that you use it when there are more than one slave node.
# Note: either broadcast, unicast, or multicasting is required.
--------------

4. Verify
Start heartbeat of ha and ha2:
#/Etc/init. d/heartbeat start
If you use ifconfig to check whether 192.168.0.2 of eth0: 0 is allocated to a server, it indicates that this server is currently active and the other server is not allocated.
When the browser accesses http: // 192.168.0.2, the apache service response on the active server is returned.

5. Common Errors:
Ifconfig finds that both machines are allocated with the virtual IP address 192.168.0.2 of eth0: 0, and generate a large number of logs in/var/log/syslog:
WARN: nodename ha uuid changed to ha2
ERROR: should_drop_message: attempted replay attack
Possible cause: the uuid of ha and ha2 is changed. ha2 is generated by means of VMware clone replication or the hostname is set after heartbeat is installed.
Solution: Let the uuid be regenerated. You can uninstall heartbeat and delete the/var/lib/heartbeat directory (the uuid file is under this directory and will not be deleted during uninstallation, you need to manually delete it. If you do not delete it manually, the original uuid will be used for re-installation)
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.