高可用集群heartbeat和调度器

时间:2021-03-24 03:17:20

高可用集群和调度器

#**heartbeat -> ldirectord -> lvs**
server1:
(1)
/#首先要保证lvs的正常运行
server1:
ipvsadm -C ##清除策略
ip addr del 172.25.32.100/24 dev eth0 ##删除虚拟ip
ip addr

(2)ldirectord的配置
ldirectord -> 控制ipvsadm
server1 & 4:
yum install ldirectord-3.9.5-3.1.x86_64.rpm -y
cp /usr/share/doc/ldirectord-3.9.5/ldirectord.cf /etc/ha.d ##配置文件的复制
vim /etc/ha.d/ldirectord.cf ##编辑ldirectord的配置文件

virtual=172.25.32.100:80        ##虚拟主机
real=172.25.32.2:80 gate ##rs
real=172.25.32.3:80 gate ##rs
fallback=127.0.0.1:80 gate ##如果调度rs都出现错误,则返回本机
service=http
scheduler=rr
#persistent=600
#netmask=255.255.255.255
protocol=tcp
checktype=negotiate ##健康检查,检查类型,协商
checkport=80 ##检查端口
request="index.html"
# receive="Test Page"
# virtualhost=www.x.y.z

(3)heartbeat的配置
vim /etc/ha.d/haresources ##编辑heartbeat的资源文件

server1 IPaddr::172.25.32.100/24/eth0 httpd ldirectord

scp haresources ldirectord.cf server4:/etc/ha.d/ ##将配置发送给server4
/etc/init.d/heartbeat start ##开启heartbeat

(4)测试
浏览器 172.25.32.100
[root@foundation32 kiosk]# arp -an | grep 172.25.32.100
? (172.25.32.100) at 52:54:00:e2:a2:c0 [ether] on br0

server2:
/etc/init.d/heartbeat stop
ipvsadm -l

server3:
/etc/init.d/heartbeat stop
ipvsadm -l