Heartbeat-based high-availability server configuration in Linux

Source: Internet
Author: User
As the data center only has one reverse proxy server to support all its services, all backend services are unavailable considering the downtime of its servers, this will lead to unnecessary accidents because the data center has only one reverse proxy server to support all its services. considering that its servers are down, all the backend services are unavailable, therefore, unnecessary accidents may occur. in order to ensure high availability of the reverse proxy server, an slave server is added for mutual heartbeat detection, when the master server is down or related application services are stopped, the slave server is automatically taken over. when the master server is restored, the slave server is no longer hosted, so as to avoid the loss caused by single point of failure.
Currently, the most popular server high availability detection systems are Heartbeat and Keepalived. Among them, Heartbeat is a high-availability mode based on host or network services; the purpose of Keepalived is to simulate the dual-host router. You have to decide which solution to choose. A few years ago, because there was no related device support in the work environment, these operations were all performed on virtual machines. Although the test was successful, they were not as exciting as they were used in the production environment. However, all the operations are implemented in the production environment step by step.
The following is an example of Linux Heartbeat-based installation:
1. master/slave servers must follow Heartbeat.
Yum-y install heratbeat
2. each master/slave server has two NICs, one for daily Internet data service communication and one for heartbeat detection. heartbeat virtualizes a public ip address (VIP) for external use)
Vip-server1 eth0 192.168.0.1 eth1 10.2.5.1 heartbeat detection VIP192.168.0.3
Vip-server2 eth0 192.168.0.2 eth1 10.2.5.2 heartbeat detection VIP192.168.0.3
Master server:
# Rpm-q heartbeat-d find the heartbeat installation directory
# Cp/usr/share/heartbeat-2.1.3/authkeys/etc/ha. d/
# Cp/usr/share/heartbeat-2.1.3/ha. cf/etc/ha. d/
# Cp/usr/share/heartbeat-2.1.3/haresources/etc/ha. d/
# Cd/etc/ha. d/
# Vi authkeys remove annotation auth 1 remove Annotation 1 crc
# Chmod 600 authkeys change authkeys permissions
# Vi ha. cf remove annotation deadtime 20 remove annotation warntime 5 remove annotation initdead 120 remove annotation udpport 694 remove annotation bcast eth1 heartbeat Nic remove annotation ucast eth1 (10.2.5.2) remove annotation node vip-server1 master node machine name remove annotation node vip-server2 Slave node machine name
# Vi haresources find # Line nod-name resource1
Add under this row
Vip-server1 192.168.0.3 # master node machine name Virtual ip start server
# Modify the master/slave servers of vi/etc/hosts
Vip-server1 192.168.0.1 # eth0 10.2.5.1 server1 # eth1
192.168.0.2 vip-server2 # eth0 10.2.5.2 server2 # eth1
Slave server:
# Sftp 192.168.0.1 logon to the master node
# Cd/etc/ha. d
# Get authkeys
# Get ha. cf
# Get haresources
# Bye
# Cd/etc/ha. d
# Vi ha. cf modify the heartbeat Nic address of the ucast eth1 (10.2.5.1) master node
Heartbeat uses/usr/share/heartbeat/hb_standby to switch nodes and/usr/share/heartbeat/hb_takeover to replace the nodes in use, you can switch nodes based on whether your applications are normal. For example
If [-f/usr/local/nginx/logs/nginx. pid];
Then/usr/share/heartbeat/hb_takeover
Else/usr/share/heartbeat/hb_standby fi # This shell script has not been tested. it is just about how it works ..
The master and slave servers have been configured here. it is worth noting that heartbeat is based on udp port 694. to enable iptables, SElinux should also be disabled.
Start heartbeat and service heartbeat start on the master and slave servers. OK...

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.