LVS_Director + KeepAlivedKeepAlived在该项目中的功能:
1. 管理IPVS的路由表(包括对RealServer做健康检查)
2. 实现调度器的HA(高可用)
http://www.keepalived.orgKeepalived所执行的外部脚本命令建议使用绝对路径
=================================================================================
实施步骤:
1. 主/备调度器安装软件
[root@lvs-keepalived-master ~]
[root@lvs-keepalived-slave ~]
2. Keepalived
lvs-master
[root@lvs-keepalived-master ~]
! Configuration File for keepalivedglobal_defs {router_id lvs-keepalived-master
}vrrp_instance VI_1 {state MASTERinterface ens33 virtual_router_id 80 priority 100 advert_int 1 authentication {auth_type PASSauth_pass 1111}virtual_ipaddress {192.168.246.110/24}
}virtual_server 192.168.246.110 80 { delay_loop 3 lb_algo rr lb_kind DR nat_mask 255.255.255.0protocol TCP real_server 192.168.246.162 80 {weight 1inhibit_on_failure TCP_CHECK { connect_port 80 connect_timeout 3 }}real_server 192.168.246.163 80 {weight 1inhibit_on_failureTCP_CHECK {connect_timeout 3connect_port 80}}
}[root@lvs-keepalived-slave ~]
! Configuration File for keepalivedglobal_defs {router_id lvs-keepalived-slave
}vrrp_instance VI_1 {state BACKUPinterface ens33nopreempt virtual_router_id 80priority 50advert_int 1authentication {auth_type PASSauth_pass 1111}virtual_ipaddress {192.168.246.110/24}
}
virtual_server 192.168.246.110 80 {delay_loop 3lb_algo rrlb_kind DRnat_mask 255.255.255.0protocol TCPreal_server 192.168.246.162 80 {weight 1inhibit_on_failureTCP_CHECK {connect_port 80connect_timeout 3}}real_server 192.168.246.163 80 {weight 1inhibit_on_failureTCP_CHECK {connect_timeout 3connect_port 80}}
}
3. 启动KeepAlived(主备均启动)
[root@lvs-keepalived-master ~]
[root@lvs-keepalived-master ~][root@lvs-keepalived-master ~]
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.246.110:80 rr persistent 20-> 192.168.246.162:80 Route 1 0 0 -> 192.168.246.163:80 Route 0 0 04. 所有RS配置(nginx1,nginx2)
配置好网站服务器,测试所有RS
[root@test-nginx1 ~]
[root@test-nginx2 ~][root@test-nginx1 ~]
[root@test-nginx2 ~][root@test-nginx1 ~]
[root@test-nginx1 ~][root@test-nginx2 ~]
[root@test-nginx2 ~][root@test-nginx1 ~]
[root@test-nginx2 ~]
[root@test-nginx1 ~]LB集群测试
所有分发器和Real Server都正常主分发器故障及恢复