LVS 高可用性实现
LVS 不可用时:
Director不可用,整个系统将不可用;SPoF Single Point of Failure
解决方案:高可用,keepalived、heartbeat/corosync
RS 不可用时:
某RS不可用时,Director依然会调度请求至此RS
解决方案: 由Director对各RS健康状态进行检查,失败时禁用,成功时启用
常用解决方案:
- keepalived
- heartbeat/corosync
- ldirectord
 检测方式:
-网络层检测,icmp
- (b) 传输层检测,端口探测
- (c) 应用层检测,请求某关键资源
RS全不用时:backup server, sorry server
ldirectord软件
ldirectord:监控和控制LVS守护进程,可管理LVS规则
包名:ldirectord-3.9.6-0rc1.1.1.x86_64.rpm
下载:http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-7/x86_64/
相关文件:
- /etc/ha.d/ldirectord.cf #主配置文件
- /usr/share/doc/ldirectord-3.9.6/ldirectord.cf # 配置模版
- /usr/lib/systemd/system/ldirectord.service # 服务
- /usr/sbin/ldirectord #主程序,Perl实现
- /var/log/ldirectord.log #日志
- /var/run/ldirectord.ldirectord.pid #pid文件
ldirectord配置文件示例
范例:DR模型的HTTP
[root@centos7 ~]#vim /etc/ha.d/ldirectord.cf
checktimeout=3
checkinterval=1
autoreload=yes
logfile="/var/log/ldirectord.log"
quiescent=no     #当RS down时 yes将修改权重为0,此配置有bug ,no为从调度列表中删除RS
virtual=10.0.0.100:80
    real=192.168.39.17 gate 1  #gate 表示DR模式,1 表示weight
    real=192.168.39.18 gate 2 
    fallback=127.0.0.1:80 gate 
    service=http
    scheduler=wrr
    #persistent=600
    #netmask=255.255.255.255
    protocol=tcp
    checktype=negotiate
    checkport=80
[root@lvs ~]#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.39.17:80             Route   1      0          31        
  -> 192.168.39.18:80             Route   2      0          62范例:DR模型的FWM
[root@centos7 ~]# /etc/ha.d/ldirectord.cf
checktimeout=3
checkinterval=1
autoreload=yes
logfile=“/var/log/ldirectord.log“     #日志文件
quiescent=no            #当RS down时 yes将修改权重为0,此配置有bug ,no为从调度列表中删除RS
virtual=66               #指定VS的FWM 或 IP:PORT
    real=172.16.0.7:80 gate 2    #DR模型,权重为 2 
    real=172.16.0.8:80 gate 1
    fallback=127.0.0.1:80 gate   #sorry server
    service=http
    scheduler=wrr
    #protocol=tcp     #如果FWM模式,此行必须注释掉
    checktype=negotiate
    checkport=80
    request="index.html"
    receive=“Test Ldirectord"本文链接:http://www.yunweipai.com/35620.html
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/52768.html
