From 98f3ad52dde7e8044a0728d5ad4b517c314dac4e Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 24 Oct 2023 15:24:36 +0800 Subject: [PATCH] Update keepalived.conf --- plugins/keepalived/config/keepalived.conf | 137 +++------------------- 1 file changed, 18 insertions(+), 119 deletions(-) diff --git a/plugins/keepalived/config/keepalived.conf b/plugins/keepalived/config/keepalived.conf index 587df8702..aa66311d4 100644 --- a/plugins/keepalived/config/keepalived.conf +++ b/plugins/keepalived/config/keepalived.conf @@ -45,125 +45,24 @@ track_script { chk_mysql_port } -virtual_server 192.168.200.100 443 { - delay_loop 6 - lb_algo rr - lb_kind NAT - persistence_timeout 50 - protocol TCP - - real_server 192.168.201.100 443 { - weight 1 - SSL_GET { - url { - path / - digest ff20ad2481f97b1754ef3e12ecd3a9cc - } - url { - path /mrtg/ - digest 9b3a0c85a887a256d6939da88aabd8cd - } - connect_timeout 3 - retry 3 - delay_before_retry 3 - } +vrrp_instance VI_1 { + state BACKUP #这里所有节点都定义为BACKUP + interface ens34 #指定虚拟ip的网卡接口 + mcast_src_ip 192.168.10.11 #本地IP + virtual_router_id 51 #路由器标识,MASTER和BACKUP必须是一致的 + priority 101 + #定义优先级,数字越大,优先级越高,在同一个vrrp_instance下,MASTER的优先级必须大于BACKUP的优先级。 + advert_int 1 + nopreempt #不抢占模式,在优先级高的机器上设置即可,优先级低的机器可不设置 + authentication { + auth_type PASS + auth_pass 1111 } -} - -virtual_server 10.10.10.2 1358 { - delay_loop 6 - lb_algo rr - lb_kind NAT - persistence_timeout 50 - protocol TCP - - sorry_server 192.168.200.200 1358 - - real_server 192.168.200.2 1358 { - weight 1 - HTTP_GET { - url { - path /testurl/test.jsp - digest 640205b7b0fc66c1ea91c463fac6334d - } - url { - path /testurl2/test.jsp - digest 640205b7b0fc66c1ea91c463fac6334d - } - url { - path /testurl3/test.jsp - digest 640205b7b0fc66c1ea91c463fac6334d - } - connect_timeout 3 - retry 3 - delay_before_retry 3 - } + virtual_ipaddress { + 192.168.10.10 #虚拟IP } - - real_server 192.168.200.3 1358 { - weight 1 - HTTP_GET { - url { - path /testurl/test.jsp - digest 640205b7b0fc66c1ea91c463fac6334c - } - url { - path /testurl2/test.jsp - digest 640205b7b0fc66c1ea91c463fac6334c - } - connect_timeout 3 - retry 3 - delay_before_retry 3 - } + + track_script { + chk_mysql_port } -} - -virtual_server 10.10.10.3 1358 { - delay_loop 3 - lb_algo rr - lb_kind NAT - persistence_timeout 50 - protocol TCP - - real_server 192.168.200.4 1358 { - weight 1 - HTTP_GET { - url { - path /testurl/test.jsp - digest 640205b7b0fc66c1ea91c463fac6334d - } - url { - path /testurl2/test.jsp - digest 640205b7b0fc66c1ea91c463fac6334d - } - url { - path /testurl3/test.jsp - digest 640205b7b0fc66c1ea91c463fac6334d - } - connect_timeout 3 - retry 3 - delay_before_retry 3 - } - } - - real_server 192.168.200.5 1358 { - weight 1 - HTTP_GET { - url { - path /testurl/test.jsp - digest 640205b7b0fc66c1ea91c463fac6334d - } - url { - path /testurl2/test.jsp - digest 640205b7b0fc66c1ea91c463fac6334d - } - url { - path /testurl3/test.jsp - digest 640205b7b0fc66c1ea91c463fac6334d - } - connect_timeout 3 - retry 3 - delay_before_retry 3 - } - } -} +} \ No newline at end of file