之前有写过keepalived+mysql 和lvsDR模式的分析篇。然而LVS没有写高冗余。今天来写一篇LVS+keepalived的
LVSDR只负责转发,LVS也没有nginx后端检查功能,所以后端realserver 宕机了,LVS还是会转发到后端去的。so 我们需要一个检查后端的功能,并剔除or增加。那这个任务就交给keepalived了
LVS安装 和keepalived 安装这里就不多说,
keepalived 安装请看:http://www.cnblogs.com/shiyiwen/p/5045027.html
LVSDR安装请看:http://www.cnblogs.com/shiyiwen/p/5069901.html
上拓扑
这里 37 为 master 161位backup
37-master keepalived.conf配置如下
! Configuration File for keepalived global_defs { notification_email { [email protected] } notification_email_from [email protected] smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_DEVEL } # VIP1 vrrp_instance VI_1 { state MASTER interface eth0 lvs_sync_daemon_inteface eth0 virtual_router_id 51 priority 100 advert_int 5 # nopreempt authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.0.36 } } virtual_server 192.168.0.36 80 { delay_loop 6 lb_algo wrr lb_kind DR # persistence_timeout 60 protocol TCP real_server 192.168.0.38 80 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 192.168.0.162 80 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } }
161 BACKUP -keepalived.conf 如下
! Configuration Filefor keepalived global_defs { notification_email { [email protected] } notification_email_from [email protected] smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_DEVEL } # VIP1 vrrp_instance VI_1 { state BACKUP interface eth0 lvs_sync_daemon_inteface eth0 virtual_router_id 51 priority 90 advert_int 5 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.0.36 } } #REAL_SERVER_1 virtual_server 192.168.0.36 80 { delay_loop 6 lb_algo wlc lb_kind DR persistence_timeout 60 protocol TCP real_server 192.168.0.38 80 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } #REAL_SERVER_2 real_server 192.168.0.162 80 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } }
至于排错,大家有问题,可留言~
时间: 2024-10-26 12:51:33