keepalived可以實現兩大功能是:健康檢測和故障轉移
keepalived.conf的配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | global_defs?{ ??? notification_email?{ ???? acassen@firewall.loc ???? failover@firewall.loc ???? sysadmin@firewall.loc ??? } ??? notification_email_from?Alexandre.Cassen@firewall.loc ??? smtp_server?192.168.200.1 ??? smtp_connect_timeout?30 ??? router_id?LVS_DEVEL } vrrp_instance?VI_1?{ ???? state?MASTER ???? interface?eth1 ???? virtual_router_id?51 ???? priority?100 ???? advert_int?1 ???? authentication?{ ???????? auth_type?PASS ???????? auth_pass?1111 ???? } ???? virtual_ipaddress?{ ???????? 10.0.22.245 ???? } } virtual_server?10.0.22.245?80?{ ???? delay_loop?6 ???? lb_algo?rr ???? lb_kind?DR ???? nat_mask?255.255.255.0 ???? persistence_timeout?50 ???? protocol?TCP ???? real_server?10.0.22.248?80?{ ???????? weight?1 ???????? TCP_CHECK?{ ???????????? connect_timeout?3 ???????????? nb_get_retry?3 ???????????? delay_before_retry?3 ???????? } ???? } ???? real_server?10.0.22.249?80?{???????? ???????? weight????1???????????????????? ???????? TCP_CHECK?{ ???????????? connect_timeout?8 ???????????? nb_get_retry?3 ???????????? delay_before_retry?3 ???????????? #connect_port?80 ???????? } ??? } } |
vrrp_instance相關參數說明:
? state:當時服務器的角色,為主或者為備
? interface:在哪個網卡進行設置
? virtual_router_id:虛擬路由id,多個keepalived通信時,此id要一致
? priority:當前服務器的優先級
? advert_int:探測間隔時間
? authentication:設置多個keepalived間的通信方式及密碼
? virtual_ipaddress:需要虛擬的IP
? nopreempt:設置為非搶占模式,默認為搶占模式;即當MASTER故障恢復后,從BACKUP再搶回來
virtual_server相關參數說明:
? delay_loop:
? lb_algo:定義lvs的輪詢算法,相當于ipvsadm中的-s參數
? lb_kind:定義lvs的工作模式,相當于ipvsadm中的-g|-m|-i參數??
? net_mask:指定VIP(虛擬IP)的子網掩碼
? persistence_timeout:定義lvs的會話保持時間,相當于ipvsadm中的-p選項
? protocol:定義lvs使用什么協議,相當于ipvsadm中的-t|-u選項
real_server相關參數說明:
? weight:設置RS的權重,相當于ipvsadm中的-w參數
? TCP_CHECK:當protocol為TCP時,為TCP_CHECK
? connect_timeout:后端主機的超時時長
? nb_get_retry:后端主機的重試次數
? delay_before_retry:每次重試之間的間隔時間
? connect_port:連接后端主機的端口,當real_server指定端口后,此參數可以省略
本文轉自激情燃燒的歲月博客51CTO博客,原文鏈接http://blog.51cto.com/liuzhengwei521/1929458如需轉載請自行聯系原作者
weilovepan520