Heartbeat implements Nginx Hot Backup

Source: Internet
Author: User

Heartbeat implements Nginx Hot Backup

How Heartbeat implements Hot Standby:

Unlike keepalived's vrrp protocol, heartbeat uses the serial port and ip address for heartbeat monitoring. The Node checks the network connectivity in the configuration file. If the network is disconnected, the ipfail of the master node performs a switchover, disable Nginx on the master node and release the virtual ip address. At this time, the slave node takes over the virtual ip address and starts nginx on this node. This enables nginx hot backup.

Virtual ip Address: 192.168.3.233

Master node:

Hostname usvr-124

Eth0: 192.168.3.124

Eth0: 0: 192.168.8.124 for heartbeat monitoring

/Etc/hosts

1921383.126 usvr-126

Slave node:

Hostname usvr-126

Eth0: 192.168.3.126

Eth0: 0: 192.168.8.126 is used to monitor heartbeat

/Etc/hosts

1921383.124 usvr-124

Note:

1. You need to add the host of each other on the two machines.

2. Time Synchronization is required for the master and slave nodes.

-------------------------------------- Split line --------------------------------------

Hot Standby for Web Services Based on Heartbeat V1

Heartbeat enables high-availability clusters of Web Services

Heartbeat + LVS + Ldirectord high-availability Load Balancing Solution

DRBD + Heartbeat + NFS High Availability Configuration notes

Heartbeat high availability for MySQL using NFS based on CRM

Heartbeat high-availability httpd simple configuration based on Resources

-------------------------------------- Split line --------------------------------------

1. Install heartbeat:

Wget http://mirrors.sohu.com/Fedora-epel/6/i386/epel-release-6-8.noarch.rpm

Rpm-ivh epel-release-6-8.noarch.rpm

Yum-y install heartbeat *

After the installation is complete, related directories will be created in/etc/ha. d.

[Root @ usvr-124 ha. d] # rpm-q heartbeat-d
/Usr/share/doc/heartbeat-3.0.4/AUTHORS
/Usr/share/doc/heartbeat-3.0.4/COPYING
/Usr/share/doc/heartbeat-3.0.4/COPYING. LGPL
/Usr/share/doc/heartbeat-3.0.4/ChangeLog
/Usr/share/doc/heartbeat-3.0.4/README
/Usr/share/doc/heartbeat-3.0.4/apphbd. cf
/Usr/share/doc/heartbeat-3.0.4/authkeys
/Usr/share/doc/heartbeat-3.0.4/ha. cf
/Usr/share/doc/heartbeat-3.0.4/haresources
/Usr/share/man/man1/cl_status.1.gz
/Usr/share/man/man1/hb_addnode.1.gz
/Usr/share/man/man1/hb_delnode.1.gz
/Usr/share/man/man1/hb_standby.1.gz
/Usr/share/man/man1/hb_takeover.1.gz
/Usr/share/man/man5/authkeys.5.gz
/Usr/share/man/man5/ha.cf.5.gz
/Usr/share/man/man8/apphbd.8.gz
/Usr/share/man/man8/heartbeat.8.gz

Copy the configuration file to/etc/ha. d.

2. heartbeat Configuration

Master node configuration:

(1) Master configuration file (ha. cf)

# Debugfile/var/log/ha-debug
Logfile/var/log/ha-log # indicates the location where heartbeat logs are stored.
# Crm yes # Whether to enable the Cluster Resource Manager (Cluster Resource management) function.
# Bcast eth1 # indicates that the heartbeat uses the Ethernet broadcast method and broadcasts the data on the eth1 interface.
Keepalive 2 # specifies the heartbeat interval to 2 seconds (that is, a broadcast is sent on eth1 every two seconds ).
Deadtime 30 # After the slave node does not receive the heartbeat signal from the master node within 30 seconds, it immediately takes over the service resources of the master node.
Warntime 10 # specifies the heartbeat delay time to 10 seconds. When the backup node cannot receive the heartbeat signal of the master node within 10 seconds, a warning log is written to the log, but the service is not switched.
Initdead 120 # in some systems, after the system is started or restarted, it takes some time for the Network to work normally. This option is used to solve the time interval generated in this situation. The value must be at least two times of deadtime.
Udpport 694 # Set the port used for broadcast communication. 694 is the default port number.
# Baud 19200 # Set the baud rate of serial communication.
# Serial/dev/ttyS0 # select a serial communication device for dual-host connection with a serial line. If the dual-host is connected over Ethernet, disable this option.
Ucast eth0 192.168.8.126 # uses the udp Unicast Network Card eth0 to organize the heartbeat. The IP address followed by the IP address should be the IP address of the Peer machine.
# Mcast eth0 225.0.0.1 694 1 0 # Use Udp multicast of eth0 as the NIC to organize heartbeat. It is generally used when there are more than one slave node. Bcast, ucast, and mcast represent broadcast, unicast, and multicasting, respectively. They are three ways to organize heartbeat. You can choose either of them.
Auto_failback on # defines whether to automatically switch back the service after the master node recovers. The two master nodes of heartbeat are the master node and backup node respectively. The master node normally occupies resources and runs all services. In case of a fault, the node is handed over to the backup node and the backup node runs the services. When this option is set to on, once the master node resumes operation, the system automatically obtains the resource and replaces the backup node. If this option is set to off, after the master node recovers, the original backup node becomes the master node.
# Stonith baytech/etc/ha. d/conf/stonith. baytech # stonith is mainly used to remove faulty nodes from the cluster environment and release cluster resources to prevent two nodes from competing for one resource. Ensure the security and integrity of shared data.
# Watchdog/dev/watchdog # This option is optional and is used to monitor the running status of the system through Heartbeat. To use this feature, you need to load the "softdog" kernel module in the kernel to generate the actual device file. If this kernel module is not in the system, you need to specify this module and re-compile the kernel. Compile and input "insmod softdog" to load the module. Enter "grep misc/proc/devices" (10) and "cat/proc/misc | grep watchdog" (130 ). Finally, generate the device file: "mknod/dev/watchdog c 10 130 ". You can use this function.
Node usvr-124 # master node host name, which can be viewed through the command "uanme-n.
Node usvr-126 # slave node host name.
Ping 192.168.3.1 # select the ping node. The better the ping node, the stronger the HA cluster. You can select a fixed router as the ping node, but it is best not to select members in the cluster as the ping node, the ping node is only used to test network connections.
Respawn hacluster/usr/lib64/heartbeat/ipfail # This option is an optional configuration to list the processes started and closed together with heartbeat. This process is generally a plug-in integrated with heartbeat, these processes can be automatically restarted if they encounter a fault. The most common process is ipfail, which is used to detect and handle network faults. You need to use the ping node specified by the ping statement to detect network connectivity. Hacluster indicates the identity to start the ipfail process.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • 3
  • Next Page

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.