LVS高可用性
当Director不可用时,整个系统将不可用;SPoF Single Point of Failure(单点失败问题)
解决方案:高可用
keepalived heartbeat/corosync
2 某RS不可用时,Director依然会调度请求至此RS
解决方案: 由Director对各RS健康状态进行检查,失败时禁用,成功时启用
keepalived heartbeat/corosync ldirectord
RS全不用时:backup server, sorry server
ldirectord:监控和控制LVS守护进程,可管理LVS规则
包名:ldirectord-3.9.6-0rc1.1.1.x86_64.rpm
下载地址:ldirectord:http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/x86_64/ldirectord-3.9.6-0rc1.1.1.x86_64.rpm
相关文件:
/etc/ha.d/ldirectord.cf 主配置文件
/usr/share/doc/ldirectord-3.9.6/ldirectord.cf 配置模版
/usr/lib/systemd/system/ldirectord.service 服务
/usr/sbin/ldirectord 主程序
/var/log/ldirectord.log 日志
/var/run/ldirectord.ldirectord.pid pid文件
实现环境:在上一篇文章已经配置好LVS/DR模型,进而直接进行ldirectord配置。
编辑主配置文件,ipvs规则在文件中定义
[root@centos7 ~]# vim /etc/ha.d/ldirectord.cf
#Global Directives
checktimeout=3
checkinterval=1
#fallback=127.0.0.1:80
#fallback6=[::1]:80
autoreload=yes
#logfile="/var/log/ldirectord.log"
#logfile="local0"
#emailalert="admin@x.y.z"
#emailalertfreq=3600
#emailalertstatus=all
quiescent=no
# Sample for an http virtual service
virtual=10.0.0.100:80
real=192.168.147.132:80 gate 1
real=192.168.147.133:80 gate 2
fallback=127.0.0.1:80 gate //定义sorry server
service=http
scheduler=wrr
#persistent=600
#netmask=255.255.255.255
protocol=tcp
checktype=negotiate
checkport=80
request="index.html"
receive="RS"
#virtualhost=www.x.y.z
清空原有的ipvs规则,并启动服务。
[root@centos7 ~]# ipvsadm -C
[root@centos7 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
[root@centos7 ~]# systemctl start ldirectord.service
[root@centos7 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.0.0.100:80 wrr
-> 192.168.147.132:80 Route 1 0 0
-> 192.168.147.133:80 Route 2 0 0
测试
[root@centos7 ~]# curl 10.0.0.100
RS132
[root@centos7 ~]# curl 10.0.0.100
RS133
[root@centos7 ~]# curl 10.0.0.100
RS133
[root@centos7 ~]# curl 10.0.0.100
RS132
[root@centos7 ~]# curl 10.0.0.100
RS133
[root@centos7 ~]# curl 10.0.0.100
RS133
关闭其中一台RS服务器
[root@centos7 ~]# systemctl stop httpd
此时,在LVS服务上查看规则,可以看到只有一台提供服务。
[root@centos7 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.0.0.100:80 wrr
-> 192.168.147.132:80 Route 1 0 0
这是再测试一次,只有132服务器提供服务
[root@centos7 ~]# curl 10.0.0.100
RS132
[root@centos7 ~]# curl 10.0.0.100
RS132
[root@centos7 ~]# curl 10.0.0.100
RS132
[root@centos7 ~]# curl 10.0.0.100
RS132
LVS高可用性配置
730

被折叠的 条评论
为什么被折叠?



