Corosync/openais + lvs + ldirectord 实现高可用+检测状态
(这里的lvs,Corosync相关安装就不写了可以参照前面的文档)
一、拓扑如下:
二、安装ldirectord
- # yum -y --nogpgcheck localinstall perl-MailTools-1.77-1.el5.noarch.rpm heartbeat-ldirectord-2.1.4-9.el5.i386.rpm
- # cp /usr/share/doc/heartbeat-ldirectord-2.1.4/ldirectord.cf /etc/ha.d/
- # cd /etc/ha.d/
三、修改配置文件, 【Linux公社 http://www.linuxidc.com 】
1、node1和node2一样
- # egrep -v "^$|^#" ldirectord.cf
- checktimeout=3 //超时时间
- checkinterval=1 //检查时间
- autoreload=yes //是否自动加载文件
- logfile="/var/log/ldirectord.log" //定义日志
- quiescent=yes //静默模式
- virtual=172.16.15.100:80 //定义LVS虚拟服务
- real=172.16.15.70:80 gate
- real=172.16.15.60:80 gate
- fallback=127.0.0.1:80 gate
- service=http //服务
- request=".test.html" //健康状况检查的文件
- receive="ok" //文件中包含的字符串
- scheduler=rr //调度算法
- protocol=tcp
- checktype=negotiate //协商模式
- checkport=80
- # scp -p ldirectord.cf node2:/etc/ha.d/
2、分别在RS1和RS2的/var/www/html/建立个.test.html文件,内容为ok
# echo "ok" > /var/www/html/.test.html
# chkconfig ldirectord off
(注:node1和node2也安装http服务,但不启动 fallback=127.0.0.1:80 gate 选项设置的是当节点都失效后的访问页面)

