ldirectord
server1(vs)
[root@server1: ~]# ls
ldirectord-3.9.5-3.1.x86_64.rpm
[root@server1: ~]# yum install ldirectord-3.9.5-3.1.x86_64.rpm
[root@server1: ~]# rpm -qpl ldirectord-3.9.5-3.1.x86_64.rpm
warning: ldirectord-3.9.5-3.1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 7b709911: NOKEY
/etc/ha.d
/etc/ha.d/resource.d
/etc/ha.d/resource.d/ldirectord
/etc/init.d/ldirectord
/etc/logrotate.d/ldirectord
/usr/lib/ocf/resource.d/heartbeat/ldirectord
/usr/sbin/ldirectord
/usr/share/doc/ldirectord-3.9.5
/usr/share/doc/ldirectord-3.9.5/COPYING
/usr/share/doc/ldirectord-3.9.5/ldirectord.cf
/usr/share/man/man8/ldirectord.8.gz
[root@server1: ~]# cd /etc/ha.d
[root@server1: ha.d]# ls
resource.d shellfuncs
[root@server1: ha.d]# cp /usr/share/doc/ldirectord-3.9.5/ldirectord.cf .
[root@server1: ha.d]# ls
ldirectord.cf resource.d shellfuncs
[root@server1: ha.d]# vim ldirectord.cf
25 virtual=172.25.51.100:80
26 real=172.25.51.2:80 gate
27 real=172.25.51.3:80 gate
28 fallback=127.0.0.1:80 gate
29 service=http
30 scheduler=rr
31 #persistent=600
32 #netmask=255.255.255.255
33 protocol=tcp
34 checktype=negotiate
35 checkport=80
36 request="index.html"
37 # receive="Test Page"
38 # virtualhost=www.x.y.z
[root@server1: ha.d]# /etc/init.d/ldirectord start
Starting ldirectord... success
[root@server1: ha.d]# ipvsadm -C
[root@server1: ha.d]# vim /var/www/html/index.html
[root@server1: ha.d]# cat /var/www/html/index.html
<h1>此网站正在维护中,请稍后再试......</h1>
[root@server1: ha.d]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: apr_sockaddr_info_get() failed for server1:
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
[root@server1: ha.d]# /etc/init.d/ldirectord restart
Restarting ldirectord... success
[root@server1: ha.d]# ipvsadm -L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.25.51.100:http rr
-> localhost:http Local 1 0 0
server2和server3(RS)
配置文件和lvs相同
测试:
正常情况
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server3</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server2</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server3</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server2</h1>
sever2 出问题sever3正常的时候
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server3</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server3</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server3</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server3</h1>
当server3出问题sever2正常的时候
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server2</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server2</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server2</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>server2</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>此网站正在维护中,请稍后再试......</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>此网站正在维护中,请稍后再试......</h1>
[kiosk@foundation12 rhel6.5]$ curl 172.25.51.100
<h1>此网站正在维护中,请稍后再试......</h1>