HEARTBEAT+LDIRECTORD+LVS+HTTPD Cluster deployment

Source: Internet
Author: User
Tags md5 encryption

HEARTBEAT+LDIRECTORD+LVS+HTTPD Cluster deployment

First, the hardware environment

4 virtual machines on the same network segment

Operating system: centos6.3

Turn off unnecessary service scripts for the system

#!/bin/bashservices= ' Chkconfig--list|cut-f1|cut-d ""-f1 ' for ser in $servicesdo if ["$ser" = = "Network"] | | ["$ser" = = "Rsyslog"] | | ["$ser" = = "sshd"] | | ["$ser" = = "Crond"] | | ["$ser" = = "ATD"]; Then Chkconfig "$ser" on Else Chkconfig "$ser" Off Fidonereboot

Second, IP address planning

Master 172.30.82.45slave 172.30.82.58node1 172.30.82.3node2 172.30.82.11VIP 172.30.82.61

Third, note:

1, set the time synchronization between each node

Ntpdate 172.30.82.254 &>/dev/null

2, based on the Hosts file implementation can use the host name to access, modify the/etc/hosts file

3, the use of uname-n execution results with the same host name

4. Ensure that the Ldirectord service shuts down and starts

Chkconfig Ldirectord off

5. Turn off SELinux

Setenfroce 0

Iv. installation of relevant software

Heartbeat Heartbeat-libs:http://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/letter_h.group.htmllibdnet:http ://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/letter_l.group.htmlldirectord:http://download.opensuse.org/  Repositories/network:/ha-clustering:/stable/centos_centos-6/x86_64/yum install-y Perl-MailTools  Perl-compress-zlib perl-html-parser perl-html-tagset perl-timedate perl-libwww-perlyum--nogpgcheck localinstall heartbeat-3.0.4-2.el6.x86_64.rpm heartbeat-libs-3.0.4-2.el6.x86_64.rpm libdnet-1.12-6.el6.x86_64.rpm ldirectord-3.9.6-0rc1.1.1.x86_64.rpm

V. Configuring the High availability of the Director node

1. Copy configuration file cp /usr/share/doc/heartbeat-3.0.4/{authkeys,ha.cf,haresources}  /etc/ha.dcp /usr/ SHARE/DOC/LDIRECTORD-3.9.6/LDIRECTORD.CF /ETC/HA.D/2, modify authkeysauth 11 md5  eb09b7d8e7117191cb9e6e68054ff83beb09b7d8e7117191cb9e6e68054ff83b  the random number for MD5 encryption can be obtained by: Dd if=/dev/random  BS=10 COUNT=1 |MD5SUM3, modify heartbeat master configuration file ha.cflogfile /var/log/heartbeat.log                         # the path to the log file #logfacility local0keepalive 2                      #心跳检测的平率为2秒一次        deadtime 10                      #如果30秒内没有相应心跳就做切换warntime  10                      #指明心跳的延时为10秒做警告记录一条日志, no other action initdead 40                     # This value is set to Deadtime twice times the # baud 115200   19200            #串口速率 # serial /dev/ttys0              #串口检测心跳udpport  694                      #数据通信的端口bcast  eth0                      # Eth0 for heartbeat working interface ucast eth1 10.0.0.2              #检测对端心跳接口的地址   (eth1 address of HA standby node) auto_failback on                #Automatically switch node    master           when the primary HA node resumes         #主HA节点计算机名  node    slave                    #备HA节点计算机名  ping  172.30.82.254              #检测网络是否正常, Can be set to gateway address 4, modify the cluster resource profile haresources, add: Master  172.30.82.61/24/eth0/172.30.82.255 ldirectordmaster   Specify the primary node of the cluster 172.30.82.61  the VIP/24 subnet mask for the specified cluster/eth0 the network card that specifies the VIP binding, and if not specified and the server has multiple network cards, the system is bound to the network card with the VIP on the same network segment by default  / 172.30.82.255  the network broadcast address, you can start Ldirectord resources without specifying a  LDIRECTORD definition, note the spaces between the resources 5, Modify the Ldirectord configuration file ldirectord.cfchecktimeout=3                         # Detection Timeout checkinterval=1                        # detection Interval autoreload=yes                          # New Load Client logfile= "/var/log/ldirectord.log"      # log path logfile= "Local0" quiescent=no                           # realserver  removed from the LVS list after the outage and automatically added to the list after recovery virtual= 192.168.2.200:80              # Listening VIP address 80 port real=192.168.2.203:80 gate             # Real IP address and port   route mode Real=192.168.2.204:80 gatefallback=127.0.0.1:80 gate   # If the real node is down, failback to the loopback address service=http                          # Service is httprequest= ". text.html"                   # is saved in the real Web root directory and can be accessed to determine if Real is alive receive= "OK"                                # Detecting file Contents scheduler=rr                   # Scheduling Algorithm        protocol= tcp               # Detection Protocol               checktype=negotiate                    # Detection Type checkport=80                    & nbsp;      # detect port 6, copy the configuration file to the standby node: scp -p authkeys  haresources   ha.cf  ldirectord.cf  slave:/etc/ha.d/

Six, Dr Model configuration Realserver script:

#!/bin/bashvip=172.30.82.61host= '/bin/hostname ' case  "$"  instart)         # Start LVS-DR real server on this machine.          /sbin/ifconfig lo down          /sbin/ifconfig lo up         echo  "1"  >/proc/sys/net/ipv4/conf/lo/arp_ignore         echo   "2"  >/proc/sys/net/ipv4/conf/lo/arp_announce          echo  "1"  >/proc/sys/net/ipv4/conf/all/arp_ignore          echo  "2"  >/proc/sys/net/ipv4/conf/all/arp_announce          /sbin/ifconfig lo:0  $VIP  netmask 255.255.255.255 up          /sbin/route add -host  $VIP  dev lo:0;; Stop)          # Stop LVS-DR real server  Loopback device (s) .         /sbin/ifconfig lo:0  down         echo  "0"  >/proc/sys/net/ipv4/conf/lo/ arp_ignore         echo  "0"  >/proc/sys/net/ipv4/conf /lo/arp_announce         echo  "0"  >/proc/sys/net/ ipv4/conf/all/arp_ignore         echo  "0"  >/proc/sys /net/ipv4/conf/all/arp_announce;; Status)          # Status of LVS-DR real  Server.         islothere= '/sbin/ifconfig lo:0 |  grep  $VIP '  &Nbsp;       isrothere= ' netstat -rn | grep  lo '  |  grep  $VIP '                  if [ !  "$islothere"  -o !  "$isrothere"  ];then          # either the route or the lo:0 device          # not found.                          echo  "lvs-dr real server is stopped."                 else                          echo  "lvs-dr real server  is running. "                 fi;; *)          # Invalid entry.          echo  "$0: usage: $0 {start|status|stop}"           exit 1;; Esac

VII. Install the HTTPD service on real and add a test page

1, Node1yum install-y httpdecho "Welcome to Realserver 1" >/var/www/html/index.htmlecho "OK" >/var/www/html/. Text.htmlservice httpd start2, Node2yum install-y httpdecho "Welcome to Realserver 2" >/var/www/html/index.htmlecho "O K ">/var/www/html/.text.htmlservice httpd start

Eight, open and test high-availability cluster services

1. Execute service heartbeat startssh slave  ' Service heaertbeat start ' 2 on Master, Cluster resource run status test A, client Access http://172.30.82.61master  execute  [[email protected] log]# ipvsadm  -lnip virtual server version 1.2.1  (size=4096) prot localaddress:port  scheduler flags  -> remoteaddress:port            forward weight activeconn inactconntcp  172.30.82.61:80 rr   -> 172.30.82.3:80                Route   1      0           11          ->  172.30.82.11:80              route    1      1          11 b, performing [[email  on slave protected] log]# ipvsadm -lnip virtual server version 1.2.1  (size=4096 ) prot localaddress:port scheduler flags  -> remoteaddress:port            Forward Weight ActiveConn  Inactconn indicates that the cluster resource only runs on Master 3, cluster resource transfer test A, master execution service heartbeat stop[[email protected]  log]# ipvsadm -lnip virtual server version 1.2.1  (size=4096) Prot  localaddress:port scheduler flags  -> remoteaddress:port            FORWARD WEIGHT ACTIVECONN INACTCONNB, execute on slave [[email  protected] log]# ipvsadm -LnIP Virtual Server version 1.2.1  ( size=4096) PROT LOCALADDRESS:PORT SCheduler flags  -> remoteaddress:port            forward weight activeconn inactconntcp  172.30.82.61:80 rr   -> 172.30.82.3:80                Route   1      1           17          ->  172.30.82.11:80              route    1      0           18 Instructions for cluster resource transfer successful C, master execution, test whether the Cluster service will be returned to the primary node on SERVICE HEARTBEAT STARTD, back-end service failure detection node1 on execution service httpd  stop View master Cluster service [[Email protected] log]# ipvsadm -lnip virtual server  version 1.2.1  (Size=4096) prot localaddress:port scheduler flags  -> remoteaddress:port            Forward Weight ActiveConn  inactconntcp  172.30.82.61:80 rr  -> 172.30.82.11:80               Route   1       0          0  Recovery Node1 Service SERVICE HTTPD  start[[email protected] log]# ipvsadm -lnip virtual server version  1.2.1  (size=4096) prot localaddress:port scheduler flags  ->  remoteaddress:port           forward weight  activeconn inactconntcp  172.30.82.61:80 rr  -> 172.30.82.11:80               route   1      0           0

Error handling:

Heartbeat: [56411]: ERROR:glib:Error binding socket (Permission denied). Retryingsetenforce 0 off SELinux


This article is from the "Shallow Seabed Line" blog, please be sure to keep this source http://buguoruci.blog.51cto.com/4104173/1653005

HEARTBEAT+LDIRECTORD+LVS+HTTPD Cluster deployment

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.