corosync+lvs+ldirectord

1.环境:四台oel6.3。两台用作httpd节点,两台用作lvs节点。lvs节点由corosync做高可用。lvs节点的ip分别为172.16.5.158(hadoopm)和172.16.5.202(test)。两个httpd节点分别为172.16.5.200和172.16.5.201,VIP为172.16.5.178
2.集群安装
wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -ivh epel-release-5-4.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

wget http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/x86_64/pssh-2.3.1-3.2.x86_64.rpm
wget http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/x86_64/ crmsh-1.2.6-5.1.x86_64.rpm
yum localinstall --nogpgcheck -y pssh-2.3.1-3.2.x86_64.rpm crmsh-1.2.6-5.1.x86_64.rpm
wget -O /etc/yum.repos.d/pacemaker.repo http://clusterlabs.org/rpm/epel-5/clusterlabs.repo
yum install -y corosync pacemaker ldirectord
3.lvs节点配置
1)确保两台lvs节点双机互信,且/etc/hosts文件保持一致,时间同步。
2)编辑ldirectord.cf配置文件
cp /usr/share/doc/ldirectord-1.0.4/ldirectord.cf /etc/ha.d/
vim ldirectord.cf
# Global Directives
checktimeout=5
checkinterval=3
#fallback=127.0.0.1:80
autoreload=yes
logfile="/var/log/ldirectord.log"
quiescent=no
# Sample for an http virtual service
virtual=172.16.5.187:80
       real=172.16.5.201:80 gate
       real=172.16.5.200:80 gate
#       fallback=127.0.0.1:80 gate
       service=http
       scheduler=rr
       #persistent=600
       netmask=255.255.255.0
       protocol=tcp
       checktype=negotiate
       checkport=80
       request="test.html"
       receive="Test Page"
确保两台节点ldirectord.cf配置一致
3)httpd节点的配置
yum install -y httpd
echo "Test page" > /var/www/html/test.html
echo "test" > /var/www/html/index.html
service httpd start
iptables -t nat -A PREROUTING -d 172.16.5.187 -j REDIRECT
3)配置corosync资源
crm configure property stonish-enabled=false            #关闭stonish
crm configure property no-quorum-policy=ignore     #忽略法定票数
crm configure rsc_defaults reource-stickiness=100      #配置资源粘性,更倾向于留在当前节点
crm configure primitive webip ocf:heartbeat:IPaddr params ip=172.16.5.187 nic=eth0 cidr_netmask=24   #定义虚拟IP资源
crm configure primitive ldirectord lsb:ldirectord op start timeout=15s op stop timeout=15s   #定义ldirectord资源
crm configure colocation webip_with_ldirectord inf: webip ldirectord     #定义排列约束,两个资源必须在同一台服务器上
crm configure order ldirectord_after_webip inf: webip ldirectord    #定义顺序约束,先启动虚拟IP,再启动ldirectord
crm configure location on_test webip 200: test.cmmobi-wh.com    #定义位置约束,默认在test.cmmobi-wh.com这台服务器上启动


关于corosync的配置,请参考本人博客《corosync+pacemaker》:http://breezey.blog.51cto.com/2400275/133939

关于ldirectord的配置说明,请参考本人博客《ldirectord配置文件详解》:http://breezey.blog.51cto.com/2400275/1339455

你可能感兴趣的:(LVS,crm,pacemaker,corosync,ldirectord)