heartbeat v1 + ldirctord

I. Introduction to the experimental environment

Hardware: lenovo T410S

Software: VMWARE workstation

SO: Centos 6.6

Second, the purpose of the experiment

Realize the high availability and back-end of LVS through ldirectord Monitoring the health status of RS on the end

3. Network topology

Four, experimental environment preparation

1. Configure an NTP server to ensure time synchronization

[root@node2 ha.d]# vim /etc/ntp .conf

add as follows

restrict 192.168.239.0 m ask 255.255.255.0 nomodify #Which network segment hosts are allowed to come and synchronize

Comment the time server below

#server 0.centos.pool.ntp.org iburst

#server 1.centos.pool.ntp.org iburst

< p style="white-space:normal;">#server 2.centos.pool.ntp.org iburst

#server 3.centos.pool.ntp .org iburst

server server s1a.time.edu.cn #Sync time with this NTP server

[root@node2 ha.d]# ntpdate s1a.time.edu.cn

[root@node2 ha.d]# service ntpd start< /p>

2. The names of nodes communicate with each other

[root@node2 ha.d]# vim /etc/hosts

127.0.0.1 localhost localhost .localdomain localhost4 localhost4.localdomain4

::1 lo calhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.239.133 node1.hailang.com node1

192.168.239.134 node2.hailang.com node2

[root@node1 ha.d]# hostname node1.hailang.com

[root@node1 ha.d]# uname -n

3, SSH mutual authentication

[root@node1 ha.d]# ssh-keygen -t rsa

p>

[root@node1 ha.d]# ssh-copy-id ~/.ssh/id_isa.pub 192.168.239.134

[root@node1 ha.d]# ssh node2.hailang.com

4. Turn off the firewall and SELINUX

[root@node1 ha.d]# service iptables stop

[root@node1 ha.d]# setenforce 0

5. Configure yum source

[Root@node1 ha.d]# vim /etc/yum.repos.d/epel.repo

[epel]

name=Extra Packages for Enterprise Linux 6-$basearch

baseurl=http://mirrors.aliyun.com/epel/6/$basearch

http://mirrors.aliyuncs.com/ epel/6/$basearch

#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch

failovermethod=priority

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

6. httpd (The content of the page provided by node1 is sorry node1, and the content of the page provided by node2 is sorry node2)

[root@node1 ha.d]# yum -y install httpd

[root@node1 ha.d]# service httpd statrt

[root@node1 ha.d]# vim /var/www/html/index.html

node1

5. Install and configure herartbeat v1 and ldirectord

1. Installation (133 and 134)

[root@node1 ~]# yum install perl-TimeDate net-snmp-libs libnet PyXML

[root@node1 ~]# rpm- ivh heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm heartbeat-ldirectord-2.1. 4-12.el6.x86_64.rpm

2, configuration( 133 and 134)

[root@node1 ~]# cp/usr/share/doc/heartbeat-2.1.4/{ha.cf,authkeys,haresources} /etc/ ha.d/

[root@node1 ~]# cp/usr/share/doc/heartbeat-ldirectord-2.1.4/ldirectord.cf /etc/ ha.d/

1)ha.cf

[root@node1 ~]# vim /etc/ha.d/ha.cf

logfile /var/log/ha-log

Keepalive 2

deadtime 30

warntime 10

initdead 120

udpport 694

mcast eth0 225.0.0.1 694 1 0

auto_failback on

node node1.hailang.com< /p>

node node2.hailang .com

ping 192.168.239.1

2)authkeys

[root@node1 ~]# vim /etc/ha.d/authkeys< /p>

auth 1

1 crc

3)vim /etc/ha.d/ldirectord.cf

Checktimeout=3

Checkinterval=1

Autoreload=yes

Quiescent=yes

virtual=192.168.239.200:80

real=192.168.239.135:80 gate

real=192.168.239.128:80 gate

fallback=127.0.0.1:80 gate

service=http

request=”index.html”

receive=”ok”

p>

scheduler=rr

3)haresources

node1.hailang.com 192.168.239.200/32/eth0/192.168.239.200 Direct: lord :/etc/ha.d/ldirectord.cf

4) Set kernel parameters on 128 and 135 servers

[root@dn2 ~]# echo 1 >/proc/sys /net/ipv4/conf/lo/arp_ignore

[root@dn2 ~]# echo 1 >/proc/sys/net/ipv4/conf/all/arp_ignore

[root @dn2 ~]# echo 2 >/proc/sys/net/ipv4/conf/all/arp_announce

[root@dn2 ~]# echo 2 >/proc/sys/net/ipv4/conf/ lo/arp_announce

[root@dn2 ~]# ifconfig lo:0 192.168.239.200 netmask 255.255.255.255 broadcast 192.168.239.200

[root@dn2 ~]# route add -host 192.168.239.200 dev lo

5) Start httpd service on 128 and 135 servers And turn off the firewall and provide a test page

[root@dn2 ~]# service httpd start

Starting httpd: Starting httpd:

dn2 ~]# vim /var/www/html/index.html

3 , Start (133 and 134)

[root@node1 ha.d]# service heartbeat start

4. Test

1) Visit http ://192.168.239.200

Result: Switch between 128 and 135

2) Stop the http service of 128 servers

[Root@dn2 ~]# service http stop

Result: Display 135 page

3) Stop the http server of 128 and 135 servers Service

Result: Display the sorry page of 133


4) Stop the heartbeat of server 133

[root@node1 ~]# cd /usr/lib64/heartbeat/

[root@node1 heartbeat]# ./hb_standby

Result: Show 134 sorry page

Leave a Comment

Your email address will not be published.