keepalive实现web服务器activepassive

it2022-05-05  216

keepalive实现web服务器active/passive

https://github.com/acassen/keepalived/blob/v1.2.13/doc/keepalived.conf.SYNOPSIS http://ngyuki.hatenablog.com/entry/2016/04/04/193949

master

global_defs { notification_email { sysadmin@mydomain.com } notification_email_from sysadmin@mydomain.com smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id us-1-219 } vrrp_script chk_http_port { script "</dev/tcp/127.0.0.1/80" interval 1 fall 2 rise 1 } vrrp_sync_group sync_group_1 { group { private public } } vrrp_instance private { state MASTER interface em1 virtual_router_id 110 priority 200 advert_int 1 authentication { auth_type PASS auth_pass cce068f9 } virtual_ipaddress { 10.150.1.20/24 dev em1 label em1:0 } track_script { chk_http_port weight 0 } } vrrp_instance public { state MASTER interface em2 virtual_router_id 119 priority 200 advert_int 1 authentication { auth_type PASS auth_pass cce068f9 } virtual_ipaddress { 169.169.34.29/27 dev em2 label em2:0 } track_script { chk_http_port weight 0 } }

backup

global_defs { notification_email { sysadmin@mydomain.com } notification_email_from sysadmin@mydomain.com smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id us-1-220 } vrrp_script chk_http_port { script "</dev/tcp/127.0.0.1/80" interval 1 fall 2 rise 1 } vrrp_sync_group sync_group_1 { group { private public } } vrrp_instance private { state BACKUP interface em1 virtual_router_id 110 priority 100 advert_int 1 authentication { auth_type PASS auth_pass cce068f9 } virtual_ipaddress { 10.150.1.20/24 dev em1 label em1:0 } track_script { chk_http_port weight 0 } } vrrp_instance public { state BACKUP interface em2 virtual_router_id 119 priority 100 advert_int 1 authentication { auth_type PASS auth_pass cce068f9 } virtual_ipaddress { 169.169.34.29/27 dev em2 label em2:0 } track_script { chk_http_port weight 0 } }

备注

#1 ip存活检测与服务存活检测 #2 同步组功能,内外网卡有一块有问题,vip就切换 #3 主机的state设置为MASTER,备机的state设置为BACKUP,priority来决定谁为主,谁为从 #4 主备机同一个vrrp_instance的id要一致

测试

#219 ifdown em1 or ifdown em2,2个vip从219飘到220 ifdown em2 or ifdown em2,2个vip又飘回219 /etc/init.d/nginx stop,2个vip从219飘到220 /etc/init.d/nginx start,2个vip又飘回219 posted on 2016-08-25 16:36 北京涛子 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/liujitao79/p/5807398.html

相关资源:各显卡算力对照表!

最新回复(0)