Heartbeat+ldirector+lvs enable highly available clusters

Source: Internet
Author: User

7. Heartbeat+ldirector+lvs realizes high availability cluster

the experiment was carried out on the basis of the Dr Model of LVs .



Heartbeat Working principle:

Heartbeat core consists of two parts, heartbeat monitoring part and the resource takeover part, heartbeat monitoring can be carried out through the network link and the serial port, and support redundant link, they send each other a newspaper Greek tell each other's own current state, if within the specified time has not received the message sent by the other party, Then it is considered that the other party is invalid, then the resource takeover module should be started to take over the resources or services running on the other host.

Two units Dispatch Server :

Heartbeat is just an HA software that only completes heartbeat monitoring and resource takeover, and does not monitor the resources or applications it controls. to monitor whether resources and applications are functioning properly, you must use third-party plug-ins, such as Ipfail, Ldirector, and so on

Ldirector is a plug-in that monitors the running state of a Cluster service node. Ldirector If a service in the cluster node is monitored for failure, the external connection capability of this node is masked, and subsequent requests are transferred to the normal node for service. This plugin is often used in LVS load balancing clusters.

Ldirector automatically detects the health of the background realserver and responds to the action.


Configuration:

Director server1:eth0---10.0.5.100 (IP of the teacher doing the experiment) 10.0.199.4 (my own IP)

eth0:0--10.0.5.200 10.0.199.200

eth1--- 192.168.10.1 192.168.100.1


Director server2:eth0---10.0.5.1 10.0.199.3          

eth1--- 192.168.10.2 192.168.100.2

Two real servers:

Real server1:10.0.199.1

Real server1:10.0.199.2


650) this.width=650; "src=" Http://note.youdao.com/yws/res/21945/5F3CD3FC58CD4B9A94C6B19CA5C8D54B "alt=" Screenshot.png "/>

Dispatch server configuration:

(1) Installing the software

# yum Install PyXML resource-agents ipvsadm perl-mailtools perl-net-ssleay perl-libwww-perl perl-timedate

# yum Install Cluster-glue cluster-glue-libs

go to the teacher machine Mirro R Heartbeat

# CD Heartbeat/x86_64 (if 64-bit then enter this x86_64 if 32 bits are entered i686)

# RPM-IVH heartbeat-3.0.4-1.el6.x86_64.rpm heartbeat-devel-3.0.4-1.el6.x86_64.rpm heartbeat-libs-3.0.4-1 c2>.el6.x86_64.rpm ldirectord-3.9.2-2.fc17.1.x86_64.rpm


(2) configuration Heartbeat

# CP /USR/SHARE/DOC/HEARTBEAT-3.0.4/HA.CF/ETC/HA.D

# cp/usr/share/doc/ldectord-3.9.2/LDIRECTORD.CF/ETC/HA.D

# cp/usr/ sha re/doc/h EARTBEAT-3.0.4/AUTHKEYS/ETC/HA.D

# cp/usr/share/doc/heartbeat-3.0.4/haresources/etc/ha.d


Configure dual-machine interconnect authentication files Authkeys

authkeys files are used to set heartbeat authentication methods There are 3 kinds of:crc< MD5 <SHA1 (highest security, occupying system resources)

# vim authkeys \ \ Master heartbeat The key profile for communication between servers

Auth 3
3 MD5 aixocm!


# chmod authkeys \ \ Modify Permissions
    
# vim ha.cf \ \ Master Profile file
logfile/var/log/ha-log \ \ Set heartbeat log storage location
logfacility local0
keepalive 2 \ \ Set Heartbeat (monitor) time to 2 seconds, monitor once every 2 seconds
Deadtime 30 \ \ Continuous for a long time to think that the other side hangs off the unit seconds
warntime 10 \ \ For how long do you not contact after the start warning prompt
Initdead 120 \ \ Here the main type to the restart after the reservation of a period of time to ignore (such as: Restart after the network, such as start) \ \ If the network is not through, Keepaliv E detection is certainly not, but this time does not switch, \ \ This value is at least twice times deadtime)
Udpport 694 \ \ Sets the port for broadcast communication by default to 694
ucast eth1 192.168.100.2 # eth1 IP for another dispatch server
auto_failback on \ \ Need to automatically switch back on after returning to normal switch on instructions
node server1 \ \ Host name of the Master dispatch server ' # hostname ' uname-n '
node server2 \ \ Host name of alternate dispatch server

Ping 10.0.2.253 \ \ Test network connectivity is generally set as the IP of the gateway,

\ \ But this is actually the IP of the machine that is the least likely to be down.

respawn hacluster/usr/lib64/heartbeat/ipfail \ \ Lists the processes that are started and closed together with Heartbeat
apiauth ipfail gid=haclient uid=hacluster
deadping
Conn_logd_time
compression bz2
Compression_threshold 2

(3) Configuring the Haresource resource configuration file
# vim Haresources
Server1 ipaddr::10.0.199.200/16/eth0:0 ldirectord::/etc/ha.d/ldirectord.cf

The above IP is the virtual out IP

1. The first column of the resource group is one of our servers in the HA.CF configuration file, and is the host name currently being prepared as the primary dispatch server

2 , each row represents a resource group, if the line can not write "" line

3 . Resource group start order from left to right, close order right to left

4 . There is no necessary connection between different resource groups

5 , each resource is a script, it can be in the/ETC/INIT.D directory, or it can be a script under the/USR/LOCAL/ETC/HA.D/RESOURCE.D directory.

(4) Configuring Ldirectord for LVS scheduling
# VIM/USR/SHARE/DOC/LDIRECTORD-3.9.2/LDIRECTORD.CF
checktimeout=3
checkinterval=1
Autoreload=yes
logfile= "/var/log/ldirectord.log"
logfile= "Local0"
emailalert= "[email protected]"
emailalertfreq=3600
Emailalertstatus=all
Quiescent=no

virtual=10.0.199.200:80 \\10.0.199.200 Virtual address
real=10.0.199.1:80 Gate 2
real=10.0.199.2:80 Gate 3
service=http
SCHEDULER=WRR
persistent=300
netmask=255.255.255.255
protocol=tcp
checktype=negotiate
checkport=80
request= "test.html"
receive= "ok!"

This article is from the "Zhanglulu" blog, make sure to keep this source http://zhanglulu913.blog.51cto.com/10592685/1688964

Heartbeat+ldirector+lvs enable highly available clusters

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.