Introduction of experimental environment
Hardware: Lenovo T410s
Software: VMWARE Workstation
So:centos 6.6
Ii. purpose of the experiment
High availability of LVS and health monitoring of back-end RS via Ldirectord
Third, network topology
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/6C/wKioL1V8L16C9Q2EAAOzAIMuTFE159.jpg "title=" Qq20150613211804.png "width=" "height=" 269 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:350PX;HEIGHT:269PX; "alt = "Wkiol1v8l16c9q2eaaozaimutfe159.jpg"/>
Iv. preparation of the experimental environment
1. Configure the NTP server to ensure time synchronization
[Email protected] ha.d]# vim/etc/ntp.conf
Add the following
Restrict 192.168.239.0 mask 255.255.255.0 nomodify #允许哪些个网段的主机过来同步
Note the following time server
#server 0.centos.pool.ntp.org Iburst
#server 1.centos.pool.ntp.org Iburst
#server 2.centos.pool.ntp.org Iburst
#server 3.centos.pool.ntp.org Iburst
Server server s1a.time.edu.cn #去该NTP服务器同步时间
[Email protected] ha.d]# ntpdate s1a.time.edu.cn
[[Email protected] ha.d]# service NTPD start
2. The names of nodes communicate with each other
[Email protected] ha.d]# vim/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.239.133 node1.hailang.com Node1
192.168.239.134 node2.hailang.com Node2
[Email protected] ha.d]# hostname node1.hailang.com
[Email protected] ha.d]# uname-n
3, SSH mutual authentication
[[email protected] ha.d]# ssh-keygen-t RSA
[Email protected] ha.d]# Ssh-copy-id ~/.ssh/id_isa.pub 192.168.239.134
[[email protected] ha.d]# ssh node2.hailang.com
4. Turn off firewall and SELinux
[[Email protected] ha.d]# service iptables stop
[Email protected] ha.d]# Setenforce 0
5. Configure the Yum source
[Email protected] 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 (Node1 provide the content of the page for sorry Node1,node2 to provide the content of the page sorry Node2)
[Email protected] ha.d]# yum-y install httpd
[Email protected] ha.d]# service httpd STATRT
[Email protected] ha.d]# vim/var/www/html/index.html
Node1
V. Installing and configuring Herartbeat v1 and Ldirectord
1. Installation (133 and 134)
[email protected] ~]# Yum install perl-timedate net-snmp-libs libnet PyXML
[Email protected] ~]# 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)
[Email protected] ~]# Cp/usr/share/doc/heartbeat-2.1.4/{ha.cf,authkeys,haresources}/etc/ha.d/
[Email protected] ~]# cp/usr/share/doc/heartbeat-ldirectord-2.1.4/ldirectord.cf/etc/ha.d/
1) ha.cf
[Email protected] ~]# 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
Node node2.hailang.com
Ping 192.168.239.1
2) Authkeys
[Email protected] ~]# Vim/etc/ha.d/authkeys
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"
Scheduler=rr
3) haresources
Node1.hailang.com 192.168.239.200/32/eth0/192.168.239.200 LDIRECTORD::/ETC/HA.D/LDIRECTORD.CF
4) Set the kernel parameters on the 128 and 135 servers
[Email protected] ~]# echo 1 >/proc/sys/net/ipv4/conf/lo/arp_ignore
[Email protected] ~]# echo 1 >/proc/sys/net/ipv4/conf/all/arp_ignore
[Email protected] ~]# Echo 2 >/proc/sys/net/ipv4/conf/all/arp_announce
[Email protected] ~]# Echo 2 >/proc/sys/net/ipv4/conf/lo/arp_announce
[Email protected] ~]# ifconfig lo:0 192.168.239.200 netmask 255.255.255.255 Broadcast 192.168.239.200
[Email protected] ~]# route add-host 192.168.239.200 Dev Lo
5) Start the HTTPD service on the 128 and 135 servers and turn off the firewall and provide a test page
[[Email protected] ~]# service httpd start
Starting httpd: [OK]
[[Email protected] ~]# service iptables stop
[Email protected] ~]# vim/var/www/html/index.html
3. Start up (133 and 134)
[[Email protected] ha.d]# service heartbeat start
4. Testing
1) Visit http://192.168.239.200
Result: Switch between 128 and 135
2) Stop HTTP service for 128 server
[[Email protected] ~]# service HTTP Stop
Results: showing 135 pages
3) Stop HTTP service for 128 and 135 servers
Results: Showing 133 of sorry pages
4) Stop the heartbeat of the 133 server
[Email protected] ~]# cd/usr/lib64/heartbeat/
[Email protected] heartbeat]#./hb_standby
Results: Showing 134 of sorry pages
Heartbeat v1 + ldirctord