环境说明:
MASTER IP:192.168.202.16 BACKUP IP:192.168.202.17 漂移IP: 192.168.202.200
下面例子用来提供一个http服务的双机HA
|
#MASTER配置文件
global_defs { notification_email { } notification_email_from smtp_server 192.168.0.11 smtp_connect_timeout 30 router_id LVS_DEVEL }
vrrp_instance VI_1 { state MASTER #角色 interface eth0 #HA监测的设备 virtual_router_id 51 #虚拟路由ID一组集群必须设置为同一个ID priority 100 #权重,backup不能高于master advert_int 1 #检测时间间隔 mcast_src_ip 192.168.202.16 #多播地址(自己的IP) authentication { auth_type PASS #认证类型 auth_pass 1111 #认证密码,设置为一致 } virtual_ipaddress { 192.168.202.200 #漂移IP,可以为多个 } } virtual_server 192.168.202.200 80 { delay_loop 5 lb_algo sh lb_kind NAT persistence_timeout 50 protocol TCP real_server 192.168.202.16 80 { weight 1 TCP_CHECK { connect_timeout 3 } } real_server 192.168.202.17 80 { weight 1 TCP_CHECK { connect_timeout 3 } } }
|
#BACKUP配置文件
global_defs { notification_email { } notification_email_from smtp_server 192.168.0.11 smtp_connect_timeout 30 router_id LVS_DEVEL }
vrrp_instance VI_1 { state BACKUP #角色 interface eth0 #HA监测的设备 virtual_router_id 51 #虚拟路由ID一组集群必须设置为同一个ID priority 90 #权重,backup不能高于master advert_int 1 #检测时间间隔 mcast_src_ip 192.168.202.17 #多播地址(自己的IP) authentication { auth_type PASS #认证类型 auth_pass 1111 #认证密码,设置为一致 } virtual_ipaddress { 192.168.202.200 #漂移IP,可以为多个 } }
virtual_server 192.168.202.200 80 { delay_loop 5 lb_algo sh lb_kind NAT persistence_timeout 50 protocol TCP real_server 192.168.202.16 80 { weight 1 TCP_CHECK { connect_timeout 3 } } real_server 192.168.202.17 80 { weight 1 TCP_CHECK { connect_timeout 3 } } }
|
阅读(713) | 评论(0) | 转发(0) |