当前位置:网站首页>openresty 高可用部署
openresty 高可用部署
2022-08-03 17:59:00 【o_瓜田李下_o】
openresty 高可用部署
docker keepalived:https://github.com/osixia/docker-keepalived
keepalived 原理
常见应用:解决nginx、openresty等单点故障,实现高可用部署
nginx/openresty可实现后端服务的负载均衡,但一个集群如果只有一台nginx,会容易出现单点故障;
可结合keepalived实现主从备份,当nginx、openresty出现故障时,能自动切换到备用节点
VRRP协议:虚拟路由冗余协议(Virtual Router Redundancy Protocol)
keepalived内置了VRRP协议,对外提供一个虚拟ip(也可为真实服务器ip),供外部访问;
keepalived服务器通过arp广播(同网段传播,无法跨网段)的方式,进行节点之间的通信;
master服务器发生故障时,通过选举策略,自动将backup服务器切换为master服务器;
VRRP 选主策略
virtual ip地址拥有者,优先成为master服务器;
如果没有virtual ip拥有者,优先级高的节点成为master服务器;
如果没有virtual ip拥有者,且优先级相同,则ip地址大的成为master服务器
抢占式选主、非抢占式选主
# 相关配置属性
state:节点初始状态(master、backup)
priority:当前节点的优先级,抢占模式下,优先级高的成为master节点
nopreempt:非抢占模式,节点在backup状态下,即使优先级比master节点高,也不会去抢占master服务器
# 抢占式选主:master服务器故障恢复后,会重新抢占master服务器
* 优先级高的成为master服务器,优先级低的为backup服务器;
* 当master服务器故障后,优先级高的backup服务器成为master服务器;
* 原master服务器恢复后,如果优先级比当前的master服务器高,
则会切换称为maeter服务器,当前服务器降级为backup服务器
# 非抢占式选主:master服务器故障恢复后,保持backup状态,不会抢占master服务器
* 如果节点的初始状态都是backup,并且标识了nopreempt,则为非抢占模式
* 非抢占模式下,哪个节点先启动,哪个节点就成为master服务器
* 原master服务器故障恢复后,不会去抢占master服务器,避免了master切换,常用于生产环境
docker keepalived
下载镜像
docker pull osixia/keepalived
配置文件:/usr/local/etc/keepalived/keepalived.conf
global_defs { # 全剧默认配置
default_interface eth0 # 默认网卡
}
vrrp_instance VI_1 {
interface eth0 # 网卡
state BACKUP # 节点初始状态
virtual_router_id 51 # 虚拟路由id,同一集群id需保持一致
priority 150 # 优先级
nopreempt # 非抢占模式
unicast_peer { # 路由节点
192.168.1.10
192.168.1.11
}
virtual_ipaddress { # 虚拟ip地址
192.168.1.231
192.168.1.232
}
authentication { # 认证
auth_type PASS
auth_pass d0cker
}
notify "/container/service/keepalived/assets/notify.sh"
}
通知脚本:/container/service/keepalived/assets/notify.sh
#!/bin/bash
# for ANY state transition.
# "notify" script is called AFTER the
# notify_* script(s) and is executed
# with 3 arguments provided by keepalived
# (ie don't include parameters in the notify line).
# arguments
# $1 = "GROUP"|"INSTANCE"
# $2 = name of group or instance
# $3 = target state of transition
# ("MASTER"|"BACKUP"|"FAULT")
TYPE=$1
NAME=$2
STATE=$3
case $STATE in
"MASTER") echo "I'm the MASTER! Whup whup." > /proc/1/fd/1
exit 0
;;
"BACKUP") echo "Ok, i'm just a backup, great." > /proc/1/fd/1
exit 0
;;
"FAULT") echo "Fault, what ?" > /proc/1/fd/1
exit 0
;;
*) echo "Unknown state" > /proc/1/fd/1
exit 1
;;
esac
*************
创建集群
配置文件(主备服务器配置相同,非抢占模式)
global_defs {
default_interface eth0
}
vrrp_instance VI_1 {
interface eth0
state BACKUP
virtual_router_id 50
priority 150
nopreempt
unicast_peer {
172.18.0.21
172.18.0.22
172.18.0.23
}
virtual_ipaddress {
172.18.0.3
}
authentication {
auth_type PASS
auth_pass d0cker
}
notify "/container/service/keepalived/assets/notify.sh"
}
创建容器
docker run -it -d --net fixed --ip 172.18.0.21 --privileged \
-v /Users/huli/lua/openresty/keep/keepalived.conf:/usr/local/etc/keepalived/keepalived.conf \
--name keepalived osixia/keepalived
docker run -it -d --net fixed --ip 172.18.0.22 --privileged \
-v /Users/huli/lua/openresty/keep/keepalived.conf:/usr/local/etc/keepalived/keepalived.conf \
--name keepalived2 osixia/keepalived
docker run -it -d --net fixed --ip 172.18.0.23 --privileged \
-v /Users/huli/lua/openresty/keep/keepalived.conf:/usr/local/etc/keepalived/keepalived.conf \
--name keepalived3 osixia/keepalived
查看容器日志:keepalived
[email protected] ~ % docker logs keepalived
*** CONTAINER_LOG_LEVEL = 3 (info)
*** Search service in CONTAINER_SERVICE_DIR = /container/service :
*** link /container/service/keepalived/startup.sh to /container/run/startup/keepalived
*** link /container/service/keepalived/process.sh to /container/run/process/keepalived/run
*** link /container/service/keepalived/finish.sh to /container/run/process/keepalived/finish
*** Set environment for startup files
*** Environment files will be proccessed in this order :
Caution: previously defined variables will not be overriden.
/container/environment/99-default/default.yaml
To see how this files are processed and environment variables values,
run this container with '--loglevel debug'
/container/tool/run:294: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
env_vars = yaml.load(f)
*** Running /container/run/startup/keepalived...
*** Set environment for container process
*** Environment files will be proccessed in this order :
Caution: previously defined variables will not be overriden.
/container/environment/99-default/default.yaml
To see how this files are processed and environment variables values,
run this container with '--loglevel debug'
*** Running /container/run/process/keepalived/run...
Waiting config file /usr/local/etc/keepalived/keepalived.confok
Tue Aug 2 05:46:44 2022: Starting Keepalived v2.0.20 (01/22,2020)
Keepalived[56]: Starting Keepalived v2.0.20 (01/22,2020)
Tue Aug 2 05:46:44 2022: Running on Linux 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 (built for Linux 4.19.36)
Keepalived[56]: Running on Linux 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 (built for Linux 4.19.36)
Tue Aug 2 05:46:44 2022: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
Keepalived[56]: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
Tue Aug 2 05:46:44 2022: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
Keepalived[56]: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
Tue Aug 2 05:46:44 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Keepalived[56]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Tue Aug 2 05:46:44 2022: Starting VRRP child process, pid=58
Keepalived[56]: Starting VRRP child process, pid=58
Tue Aug 2 05:46:44 2022: Registering Kernel netlink reflector
Keepalived_vrrp[58]: Registering Kernel netlink reflector
Tue Aug 2 05:46:44 2022: Registering Kernel netlink command channel
Keepalived_vrrp[58]: Registering Kernel netlink command channel
Tue Aug 2 05:46:44 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Keepalived_vrrp[58]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Tue Aug 2 05:46:44 2022: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
Keepalived_vrrp[58]: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
Tue Aug 2 05:46:44 2022: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
Keepalived_vrrp[58]: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
Tue Aug 2 05:46:44 2022: Assigned address 172.18.0.21 for interface eth0
Keepalived_vrrp[58]: Assigned address 172.18.0.21 for interface eth0
Tue Aug 2 05:46:44 2022: Registering gratuitous ARP shared channel
Keepalived_vrrp[58]: Registering gratuitous ARP shared channel
Tue Aug 2 05:46:44 2022: (VI_1) removing VIPs.
Keepalived_vrrp[58]: (VI_1) removing VIPs.
Tue Aug 2 05:46:44 2022: ------< Global definitions >------
Keepalived_vrrp[58]: ------< Global definitions >------
Tue Aug 2 05:46:44 2022: Network namespace = (default)
Keepalived_vrrp[58]: Network namespace = (default)
Tue Aug 2 05:46:44 2022: Router ID = 5d02fb9ca56a
Keepalived_vrrp[58]: Router ID = 5d02fb9ca56a
Tue Aug 2 05:46:44 2022: Default smtp_alert = unset
Keepalived_vrrp[58]: Default smtp_alert = unset
Tue Aug 2 05:46:44 2022: Default smtp_alert_vrrp = unset
Keepalived_vrrp[58]: Default smtp_alert_vrrp = unset
Tue Aug 2 05:46:44 2022: Default smtp_alert_checker = unset
Keepalived_vrrp[58]: Default smtp_alert_checker = unset
Tue Aug 2 05:46:44 2022: Checkers log all failures = false
Keepalived_vrrp[58]: Checkers log all failures = false
Tue Aug 2 05:46:44 2022: Dynamic interfaces = false
Keepalived_vrrp[58]: Dynamic interfaces = false
Tue Aug 2 05:46:44 2022: Default interface = eth0
Keepalived_vrrp[58]: Default interface = eth0
Tue Aug 2 05:46:44 2022: LVS flush = false
Keepalived_vrrp[58]: LVS flush = false
Tue Aug 2 05:46:44 2022: LVS flush on stop = disabled
Keepalived_vrrp[58]: LVS flush on stop = disabled
Tue Aug 2 05:46:44 2022: VRRP notify priority changes = false
Keepalived_vrrp[58]: VRRP notify priority changes = false
Tue Aug 2 05:46:44 2022: VRRP IPv4 mcast group = 224.0.0.18
Keepalived_vrrp[58]: VRRP IPv4 mcast group = 224.0.0.18
Tue Aug 2 05:46:44 2022: VRRP IPv6 mcast group = ff02::12
Keepalived_vrrp[58]: VRRP IPv6 mcast group = ff02::12
Tue Aug 2 05:46:44 2022: Gratuitous ARP delay = 5
Keepalived_vrrp[58]: Gratuitous ARP delay = 5
Tue Aug 2 05:46:44 2022: Gratuitous ARP repeat = 5
Keepalived_vrrp[58]: Gratuitous ARP repeat = 5
Tue Aug 2 05:46:44 2022: Gratuitous ARP refresh timer = 0
Keepalived_vrrp[58]: Gratuitous ARP refresh timer = 0
Tue Aug 2 05:46:44 2022: Gratuitous ARP refresh repeat = 1
Keepalived_vrrp[58]: Gratuitous ARP refresh repeat = 1
Tue Aug 2 05:46:44 2022: Gratuitous ARP lower priority delay = 5
Keepalived_vrrp[58]: Gratuitous ARP lower priority delay = 5
Tue Aug 2 05:46:44 2022: Gratuitous ARP lower priority repeat = 5
Keepalived_vrrp[58]: Gratuitous ARP lower priority repeat = 5
Tue Aug 2 05:46:44 2022: Send advert after receive lower priority advert = true
查看容器日志:keepalived2
[email protected] ~ % docker logs keepalived2
*** CONTAINER_LOG_LEVEL = 3 (info)
*** Search service in CONTAINER_SERVICE_DIR = /container/service :
*** link /container/service/keepalived/startup.sh to /container/run/startup/keepalived
*** link /container/service/keepalived/process.sh to /container/run/process/keepalived/run
*** link /container/service/keepalived/finish.sh to /container/run/process/keepalived/finish
*** Set environment for startup files
*** Environment files will be proccessed in this order :
Caution: previously defined variables will not be overriden.
/container/environment/99-default/default.yaml
To see how this files are processed and environment variables values,
run this container with '--loglevel debug'
/container/tool/run:294: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
env_vars = yaml.load(f)
*** Running /container/run/startup/keepalived...
*** Set environment for container process
*** Environment files will be proccessed in this order :
Caution: previously defined variables will not be overriden.
/container/environment/99-default/default.yaml
To see how this files are processed and environment variables values,
run this container with '--loglevel debug'
*** Running /container/run/process/keepalived/run...
Waiting config file /usr/local/etc/keepalived/keepalived.confok
Tue Aug 2 05:46:59 2022: Starting Keepalived v2.0.20 (01/22,2020)
Keepalived[55]: Starting Keepalived v2.0.20 (01/22,2020)
Tue Aug 2 05:46:59 2022: Running on Linux 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 (built for Linux 4.19.36)
Keepalived[55]: Running on Linux 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 (built for Linux 4.19.36)
Tue Aug 2 05:46:59 2022: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
Keepalived[55]: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
Tue Aug 2 05:46:59 2022: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
Keepalived[55]: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
Tue Aug 2 05:46:59 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Keepalived[55]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Tue Aug 2 05:46:59 2022: Starting VRRP child process, pid=57
Keepalived[55]: Starting VRRP child process, pid=57
Tue Aug 2 05:46:59 2022: Registering Kernel netlink reflector
Keepalived_vrrp[57]: Registering Kernel netlink reflector
Tue Aug 2 05:46:59 2022: Registering Kernel netlink command channel
Keepalived_vrrp[57]: Registering Kernel netlink command channel
Tue Aug 2 05:46:59 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Keepalived_vrrp[57]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Tue Aug 2 05:46:59 2022: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
Keepalived_vrrp[57]: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
Tue Aug 2 05:46:59 2022: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
Keepalived_vrrp[57]: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
Tue Aug 2 05:46:59 2022: Assigned address 172.18.0.22 for interface eth0
Keepalived_vrrp[57]: Assigned address 172.18.0.22 for interface eth0
Tue Aug 2 05:46:59 2022: Registering gratuitous ARP shared channel
Keepalived_vrrp[57]: Registering gratuitous ARP shared channel
Tue Aug 2 05:46:59 2022: (VI_1) removing VIPs.
Keepalived_vrrp[57]: (VI_1) removing VIPs.
Tue Aug 2 05:46:59 2022: ------< Global definitions >------
Keepalived_vrrp[57]: ------< Global definitions >------
Tue Aug 2 05:46:59 2022: Network namespace = (default)
Keepalived_vrrp[57]: Network namespace = (default)
Tue Aug 2 05:46:59 2022: Router ID = 0b054866c757
Keepalived_vrrp[57]: Router ID = 0b054866c757
Tue Aug 2 05:46:59 2022: Default smtp_alert = unset
Keepalived_vrrp[57]: Default smtp_alert = unset
Tue Aug 2 05:46:59 2022: Default smtp_alert_vrrp = unset
Keepalived_vrrp[57]: Default smtp_alert_vrrp = unset
Tue Aug 2 05:46:59 2022: Default smtp_alert_checker = unset
Keepalived_vrrp[57]: Default smtp_alert_checker = unset
Tue Aug 2 05:46:59 2022: Checkers log all failures = false
Keepalived_vrrp[57]: Checkers log all failures = false
Tue Aug 2 05:46:59 2022: Dynamic interfaces = false
Keepalived_vrrp[57]: Dynamic interfaces = false
Tue Aug 2 05:46:59 2022: Default interface = eth0
Keepalived_vrrp[57]: Default interface = eth0
Tue Aug 2 05:46:59 2022: LVS flush = false
Keepalived_vrrp[57]: LVS flush = false
Tue Aug 2 05:46:59 2022: LVS flush on stop = disabled
Keepalived_vrrp[57]: LVS flush on stop = disabled
Tue Aug 2 05:46:59 2022: VRRP notify priority changes = false
Keepalived_vrrp[57]: VRRP notify priority changes = false
Tue Aug 2 05:46:59 2022: VRRP IPv4 mcast group = 224.0.0.18
Keepalived_vrrp[57]: VRRP IPv4 mcast group = 224.0.0.18
Tue Aug 2 05:46:59 2022: VRRP IPv6 mcast group = ff02::12
Keepalived_vrrp[57]: VRRP IPv6 mcast group = ff02::12
Tue Aug 2 05:46:59 2022: Gratuitous ARP delay = 5
Keepalived_vrrp[57]: Gratuitous ARP delay = 5
Tue Aug 2 05:46:59 2022: Gratuitous ARP repeat = 5
Keepalived_vrrp[57]: Gratuitous ARP repeat = 5
Tue Aug 2 05:46:59 2022: Gratuitous ARP refresh timer = 0
Keepalived_vrrp[57]: Gratuitous ARP refresh timer = 0
Tue Aug 2 05:46:59 2022: Gratuitous ARP refresh repeat = 1
Keepalived_vrrp[57]: Gratuitous ARP refresh repeat = 1
Tue Aug 2 05:46:59 2022: Gratuitous ARP lower priority delay = 5
Keepalived_vrrp[57]: Gratuitous ARP lower priority delay = 5
Tue Aug 2 05:46:59 2022: Gratuitous ARP lower priority repeat = 5
Keepalived_vrrp[57]: Gratuitous ARP lower priority repeat = 5
Tue Aug 2 05:46:59 2022: Send advert after receive lower priority advert = true
Keepalived_vrrp[57]: Send advert after receive lower priority advert = true
Tue Aug 2 05:46:59 2022: Send advert after receive higher priority advert = false
Keepalived_vrrp[57]: Send advert after receive higher priority advert = false
Tue Aug 2 05:46:59 2022: Gratuitous ARP interval = 0.000000
Keepalived_vrrp[57]: Gratuitous ARP interval = 0.000000
Tue Aug 2 05:46:59 2022: Gratuitous NA interval = 0.000000
Keepalived_vrrp[57]: Gratuitous NA interval = 0.000000
Tue Aug 2 05:46:59 2022: VRRP default protocol version = 2
Keepalived_vrrp[57]: VRRP default protocol version = 2
Tue Aug 2 05:46:59 2022: VRRP check unicast_src = false
Keepalived_vrrp[57]: VRRP check unicast_src = false
Tue Aug 2 05:46:59 2022: VRRP skip check advert addresses = false
Keepalived_vrrp[57]: VRRP skip check advert addresses = false
Tue Aug 2 05:46:59 2022: VRRP strict mode = false
Keepalived_vrrp[57]: VRRP strict mode = false
Tue Aug 2 05:46:59 2022: VRRP process priority = 0
Keepalived_vrrp[57]: VRRP process priority = 0
Tue Aug 2 05:46:59 2022: VRRP don't swap = false
Keepalived_vrrp[57]: VRRP don't swap = false
Tue Aug 2 05:46:59 2022: VRRP realtime priority = 0
Keepalived_vrrp[57]: VRRP realtime priority = 0
Tue Aug 2 05:46:59 2022: Checker process priority = 0
Keepalived_vrrp[57]: Checker process priority = 0
Tue Aug 2 05:46:59 2022: Checker don't swap = false
Keepalived_vrrp[57]: Checker don't swap = false
Tue Aug 2 05:46:59 2022: Checker realtime priority = 0
Keepalived_vrrp[57]: Checker realtime priority = 0
Tue Aug 2 05:46:59 2022: Script security disabled
Keepalived_vrrp[57]: Script security disabled
Tue Aug 2 05:46:59 2022: Default script uid:gid 0:0
Keepalived_vrrp[57]: Default script uid:gid 0:0
Tue Aug 2 05:46:59 2022: vrrp_netlink_cmd_rcv_bufs = 0
Keepalived_vrrp[57]: vrrp_netlink_cmd_rcv_bufs = 0
Tue Aug 2 05:46:59 2022: vrrp_netlink_cmd_rcv_bufs_force = 0
Keepalived_vrrp[57]: vrrp_netlink_cmd_rcv_bufs_force = 0
Tue Aug 2 05:46:59 2022: vrrp_netlink_monitor_rcv_bufs = 0
Keepalived_vrrp[57]: vrrp_netlink_monitor_rcv_bufs = 0
Tue Aug 2 05:46:59 2022: vrrp_netlink_monitor_rcv_bufs_force = 0
Keepalived_vrrp[57]: vrrp_netlink_monitor_rcv_bufs_force = 0
Tue Aug 2 05:46:59 2022: process_monitor_rcv_bufs = 0
Keepalived_vrrp[57]: process_monitor_rcv_bufs = 0
Tue Aug 2 05:46:59 2022: process_monitor_rcv_bufs_force = 0
Keepalived_vrrp[57]: process_monitor_rcv_bufs_force = 0
Tue Aug 2 05:46:59 2022: lvs_netlink_cmd_rcv_bufs = 0
Keepalived_vrrp[57]: lvs_netlink_cmd_rcv_bufs = 0
Tue Aug 2 05:46:59 2022: lvs_netlink_cmd_rcv_bufs_force = 0
Keepalived_vrrp[57]: lvs_netlink_cmd_rcv_bufs_force = 0
Tue Aug 2 05:46:59 2022: lvs_netlink_monitor_rcv_bufs = 0
Keepalived_vrrp[57]: lvs_netlink_monitor_rcv_bufs = 0
Tue Aug 2 05:46:59 2022: lvs_netlink_monitor_rcv_bufs_force = 0
Keepalived_vrrp[57]: lvs_netlink_monitor_rcv_bufs_force = 0
Tue Aug 2 05:46:59 2022: rs_init_notifies = 0
Keepalived_vrrp[57]: rs_init_notifies = 0
Tue Aug 2 05:46:59 2022: no_checker_emails = 0
Keepalived_vrrp[57]: no_checker_emails = 0
Tue Aug 2 05:46:59 2022: rx_bufs_multiples = 3
Keepalived_vrrp[57]: rx_bufs_multiples = 3
Tue Aug 2 05:46:59 2022: umask = 0177
Keepalived_vrrp[57]: umask = 0177
Tue Aug 2 05:46:59 2022: ------< VRRP Topology >------
Keepalived_vrrp[57]: ------< VRRP Topology >------
Tue Aug 2 05:46:59 2022: VRRP Instance = VI_1
Keepalived_vrrp[57]: VRRP Instance = VI_1
Tue Aug 2 05:46:59 2022: VRRP Version = 2
Keepalived_vrrp[57]: VRRP Version = 2
Tue Aug 2 05:46:59 2022: Wantstate = BACKUP
Keepalived_vrrp[57]: Wantstate = BACKUP
Tue Aug 2 05:46:59 2022: Interface = eth0
Keepalived_vrrp[57]: Interface = eth0
Tue Aug 2 05:46:59 2022: Using src_ip = 172.18.0.22
Keepalived_vrrp[57]: Using src_ip = 172.18.0.22
Tue Aug 2 05:46:59 2022: Gratuitous ARP delay = 5
Keepalived_vrrp[57]: Gratuitous ARP delay = 5
Tue Aug 2 05:46:59 2022: Gratuitous ARP repeat = 5
Keepalived_vrrp[57]: Gratuitous ARP repeat = 5
Tue Aug 2 05:46:59 2022: Gratuitous ARP refresh = 0
Keepalived_vrrp[57]: Gratuitous ARP refresh = 0
Tue Aug 2 05:46:59 2022: Gratuitous ARP refresh repeat = 1
Keepalived_vrrp[57]: Gratuitous ARP refresh repeat = 1
Tue Aug 2 05:46:59 2022: Gratuitous ARP lower priority delay = 5
Keepalived_vrrp[57]: Gratuitous ARP lower priority delay = 5
Tue Aug 2 05:46:59 2022: Gratuitous ARP lower priority repeat = 5
Keepalived_vrrp[57]: Gratuitous ARP lower priority repeat = 5
Tue Aug 2 05:46:59 2022: Send advert after receive lower priority advert = true
Keepalived_vrrp[57]: Send advert after receive lower priority advert = true
Tue Aug 2 05:46:59 2022: Send advert after receive higher priority advert = false
Keepalived_vrrp[57]: Send advert after receive higher priority advert = false
Tue Aug 2 05:46:59 2022: Virtual Router ID = 51
Keepalived_vrrp[57]: Virtual Router ID = 51
Tue Aug 2 05:46:59 2022: Priority = 150
Keepalived_vrrp[57]: Priority = 150
Tue Aug 2 05:46:59 2022: Advert interval = 1 sec
Keepalived_vrrp[57]: Advert interval = 1 sec
Tue Aug 2 05:46:59 2022: Accept = enabled
Keepalived_vrrp[57]: Accept = enabled
Tue Aug 2 05:46:59 2022: Preempt = disabled
Keepalived_vrrp[57]: Preempt = disabled
Tue Aug 2 05:46:59 2022: Promote_secondaries = disabled
Keepalived_vrrp[57]: Promote_secondaries = disabled
Tue Aug 2 05:46:59 2022: Authentication type = SIMPLE_PASSWORD
Keepalived_vrrp[57]: Authentication type = SIMPLE_PASSWORD
Tue Aug 2 05:46:59 2022: Password = d0cker
Keepalived_vrrp[57]: Password = d0cker
Tue Aug 2 05:46:59 2022: Virtual IP = 2
Keepalived_vrrp[57]: Virtual IP = 2
Tue Aug 2 05:46:59 2022: 172.18.0.3 dev eth0 scope global
Keepalived_vrrp[57]: 172.18.0.3 dev eth0 scope global
Tue Aug 2 05:46:59 2022: 172.18.0.4 dev eth0 scope global
Keepalived_vrrp[57]: 172.18.0.4 dev eth0 scope global
Tue Aug 2 05:46:59 2022: Unicast Peer = 3
Keepalived_vrrp[57]: Unicast Peer = 3
Tue Aug 2 05:46:59 2022: 172.18.0.21
Keepalived_vrrp[57]: 172.18.0.21
Tue Aug 2 05:46:59 2022: 172.18.0.22
Keepalived_vrrp[57]: 172.18.0.22
Tue Aug 2 05:46:59 2022: 172.18.0.23
Keepalived_vrrp[57]: 172.18.0.23
Tue Aug 2 05:46:59 2022: Unicast checksum compatibility = no
Keepalived_vrrp[57]: Unicast checksum compatibility = no
Tue Aug 2 05:46:59 2022: No sockets allocated
Keepalived_vrrp[57]: No sockets allocated
Tue Aug 2 05:46:59 2022: Using smtp notification = no
Keepalived_vrrp[57]: Using smtp notification = no
Tue Aug 2 05:46:59 2022: Generic state transition script = '/container/service/keepalived/assets/notify.sh', uid:gid 0:0
Keepalived_vrrp[57]: Generic state transition script = '/container/service/keepalived/assets/notify.sh', uid:gid 0:0
Tue Aug 2 05:46:59 2022: Notify priority changes = false
Keepalived_vrrp[57]: Notify priority changes = false
Tue Aug 2 05:46:59 2022: ------< Interfaces >------
Keepalived_vrrp[57]: ------< Interfaces >------
Tue Aug 2 05:46:59 2022: Name = lo
Keepalived_vrrp[57]: Name = lo
Tue Aug 2 05:46:59 2022: index = 1
Keepalived_vrrp[57]: index = 1
Tue Aug 2 05:46:59 2022: IPv4 address = 127.0.0.1
Keepalived_vrrp[57]: IPv4 address = 127.0.0.1
Tue Aug 2 05:46:59 2022: IPv6 address = (none)
Keepalived_vrrp[57]: IPv6 address = (none)
Tue Aug 2 05:46:59 2022: State = UP, RUNNING, no broadcast, loopback, no multicast
Keepalived_vrrp[57]: State = UP, RUNNING, no broadcast, loopback, no multicast
Tue Aug 2 05:46:59 2022: MTU = 65536
Keepalived_vrrp[57]: MTU = 65536
Tue Aug 2 05:46:59 2022: HW Type = LOOPBACK
Keepalived_vrrp[57]: HW Type = LOOPBACK
Tue Aug 2 05:46:59 2022: NIC netlink status update
Keepalived_vrrp[57]: NIC netlink status update
Tue Aug 2 05:46:59 2022: Reset ARP config counter 0
Keepalived_vrrp[57]: Reset ARP config counter 0
Tue Aug 2 05:46:59 2022: Original arp_ignore 0
Keepalived_vrrp[57]: Original arp_ignore 0
Tue Aug 2 05:46:59 2022: Original arp_filter 0
Keepalived_vrrp[57]: Original arp_filter 0
Tue Aug 2 05:46:59 2022: Original promote_secondaries 0
Keepalived_vrrp[57]: Original promote_secondaries 0
Tue Aug 2 05:46:59 2022: Reset promote_secondaries counter 0
Keepalived_vrrp[57]: Reset promote_secondaries counter 0
Tue Aug 2 05:46:59 2022: Tracking VRRP instances = 0
Keepalived_vrrp[57]: Tracking VRRP instances = 0
Tue Aug 2 05:46:59 2022: Name = tunl0
Keepalived_vrrp[57]: Name = tunl0
Tue Aug 2 05:46:59 2022: index = 2
Keepalived_vrrp[57]: index = 2
Tue Aug 2 05:46:59 2022: IPv4 address = (none)
Keepalived_vrrp[57]: IPv4 address = (none)
Tue Aug 2 05:46:59 2022: IPv6 address = (none)
Keepalived_vrrp[57]: IPv6 address = (none)
Tue Aug 2 05:46:59 2022: State = not UP, not RUNNING, no broadcast, no arp, no multicast
Keepalived_vrrp[57]: State = not UP, not RUNNING, no broadcast, no arp, no multicast
Tue Aug 2 05:46:59 2022: MTU = 1480
Keepalived_vrrp[57]: MTU = 1480
Tue Aug 2 05:46:59 2022: HW Type = UNKNOWN (768)
Keepalived_vrrp[57]: HW Type = UNKNOWN (768)
Tue Aug 2 05:46:59 2022: NIC netlink status update
Keepalived_vrrp[57]: NIC netlink status update
Tue Aug 2 05:46:59 2022: Reset ARP config counter 0
Keepalived_vrrp[57]: Reset ARP config counter 0
Tue Aug 2 05:46:59 2022: Original arp_ignore 0
Keepalived_vrrp[57]: Original arp_ignore 0
Tue Aug 2 05:46:59 2022: Original arp_filter 0
Keepalived_vrrp[57]: Original arp_filter 0
Tue Aug 2 05:46:59 2022: Original promote_secondaries 0
Keepalived_vrrp[57]: Original promote_secondaries 0
Tue Aug 2 05:46:59 2022: Reset promote_secondaries counter 0
Keepalived_vrrp[57]: Reset promote_secondaries counter 0
Tue Aug 2 05:46:59 2022: Tracking VRRP instances = 0
Keepalived_vrrp[57]: Tracking VRRP instances = 0
Tue Aug 2 05:46:59 2022: Name = ip6tnl0
Keepalived_vrrp[57]: Name = ip6tnl0
Tue Aug 2 05:46:59 2022: index = 3
Keepalived_vrrp[57]: index = 3
Tue Aug 2 05:46:59 2022: IPv4 address = (none)
Keepalived_vrrp[57]: IPv4 address = (none)
Tue Aug 2 05:46:59 2022: IPv6 address = (none)
Keepalived_vrrp[57]: IPv6 address = (none)
Tue Aug 2 05:46:59 2022: State = not UP, not RUNNING, no broadcast, no arp, no multicast
Keepalived_vrrp[57]: State = not UP, not RUNNING, no broadcast, no arp, no multicast
Tue Aug 2 05:46:59 2022: MTU = 1452
Keepalived_vrrp[57]: MTU = 1452
Tue Aug 2 05:46:59 2022: HW Type = UNKNOWN (769)
Keepalived_vrrp[57]: HW Type = UNKNOWN (769)
Tue Aug 2 05:46:59 2022: NIC netlink status update
Keepalived_vrrp[57]: NIC netlink status update
Tue Aug 2 05:46:59 2022: Reset ARP config counter 0
Keepalived_vrrp[57]: Reset ARP config counter 0
Tue Aug 2 05:46:59 2022: Original arp_ignore 0
Keepalived_vrrp[57]: Original arp_ignore 0
Tue Aug 2 05:46:59 2022: Original arp_filter 0
Keepalived_vrrp[57]: Original arp_filter 0
Tue Aug 2 05:46:59 2022: Original promote_secondaries 0
Keepalived_vrrp[57]: Original promote_secondaries 0
Tue Aug 2 05:46:59 2022: Reset promote_secondaries counter 0
Keepalived_vrrp[57]: Reset promote_secondaries counter 0
Tue Aug 2 05:46:59 2022: Tracking VRRP instances = 0
Keepalived_vrrp[57]: Tracking VRRP instances = 0
Tue Aug 2 05:46:59 2022: Name = eth0
Keepalived_vrrp[57]: Name = eth0
Tue Aug 2 05:46:59 2022: index = 21
Keepalived_vrrp[57]: index = 21
Tue Aug 2 05:46:59 2022: IPv4 address = 172.18.0.22
Keepalived_vrrp[57]: IPv4 address = 172.18.0.22
Tue Aug 2 05:46:59 2022: IPv6 address = (none)
Keepalived_vrrp[57]: IPv6 address = (none)
Tue Aug 2 05:46:59 2022: MAC = 02:42:ac:12:00:16
Keepalived_vrrp[57]: MAC = 02:42:ac:12:00:16
Tue Aug 2 05:46:59 2022: MAC broadcast = ff:ff:ff:ff:ff:ff
Keepalived_vrrp[57]: MAC broadcast = ff:ff:ff:ff:ff:ff
Tue Aug 2 05:46:59 2022: State = UP, RUNNING
Keepalived_vrrp[57]: State = UP, RUNNING
Tue Aug 2 05:46:59 2022: MTU = 1500
Keepalived_vrrp[57]: MTU = 1500
Tue Aug 2 05:46:59 2022: HW Type = ETHERNET
Keepalived_vrrp[57]: HW Type = ETHERNET
Tue Aug 2 05:46:59 2022: NIC netlink status update
Keepalived_vrrp[57]: NIC netlink status update
Tue Aug 2 05:46:59 2022: Reset ARP config counter 0
Keepalived_vrrp[57]: Reset ARP config counter 0
Tue Aug 2 05:46:59 2022: Original arp_ignore 0
Keepalived_vrrp[57]: Original arp_ignore 0
Tue Aug 2 05:46:59 2022: Original arp_filter 0
Keepalived_vrrp[57]: Original arp_filter 0
Tue Aug 2 05:46:59 2022: Original promote_secondaries 0
Keepalived_vrrp[57]: Original promote_secondaries 0
Tue Aug 2 05:46:59 2022: Reset promote_secondaries counter 0
Keepalived_vrrp[57]: Reset promote_secondaries counter 0
Tue Aug 2 05:46:59 2022: Tracking VRRP instances = 1
Keepalived_vrrp[57]: Tracking VRRP instances = 1
Tue Aug 2 05:46:59 2022: VI_1, weight 0
Keepalived_vrrp[57]: VI_1, weight 0
Tue Aug 2 05:46:59 2022: (VI_1) Entering BACKUP STATE (init)
Keepalived_vrrp[57]: (VI_1) Entering BACKUP STATE (init)
Tue Aug 2 05:46:59 2022: VRRP sockpool: [ifindex(21), family(IPv4), proto(112), unicast(1), fd(11,12)]
Keepalived_vrrp[57]: VRRP sockpool: [ifindex(21), family(IPv4), proto(112), unicast(1), fd(11,12)]
# 当前节点为backup节点
Ok, i'm just a backup, great.
查看容器日志:keepalived3
[email protected] ~ % docker logs keepalived3
*** CONTAINER_LOG_LEVEL = 3 (info)
*** Search service in CONTAINER_SERVICE_DIR = /container/service :
*** link /container/service/keepalived/startup.sh to /container/run/startup/keepalived
*** link /container/service/keepalived/process.sh to /container/run/process/keepalived/run
*** link /container/service/keepalived/finish.sh to /container/run/process/keepalived/finish
*** Set environment for startup files
*** Environment files will be proccessed in this order :
Caution: previously defined variables will not be overriden.
/container/environment/99-default/default.yaml
To see how this files are processed and environment variables values,
run this container with '--loglevel debug'
/container/tool/run:294: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
env_vars = yaml.load(f)
*** Running /container/run/startup/keepalived...
*** Set environment for container process
*** Environment files will be proccessed in this order :
Caution: previously defined variables will not be overriden.
/container/environment/99-default/default.yaml
To see how this files are processed and environment variables values,
run this container with '--loglevel debug'
*** Running /container/run/process/keepalived/run...
Waiting config file /usr/local/etc/keepalived/keepalived.confok
Tue Aug 2 05:49:08 2022: Starting Keepalived v2.0.20 (01/22,2020)
Keepalived[55]: Starting Keepalived v2.0.20 (01/22,2020)
Tue Aug 2 05:49:08 2022: Running on Linux 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 (built for Linux 4.19.36)
Keepalived[55]: Running on Linux 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 (built for Linux 4.19.36)
Tue Aug 2 05:49:08 2022: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
Keepalived[55]: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
Tue Aug 2 05:49:08 2022: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
Keepalived[55]: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
Tue Aug 2 05:49:08 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Keepalived[55]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Tue Aug 2 05:49:08 2022: Starting VRRP child process, pid=57
Tue Aug 2 05:49:08 2022: Registering Kernel netlink reflector
Keepalived_vrrp[57]: Registering Kernel netlink reflector
Tue Aug 2 05:49:08 2022: Registering Kernel netlink command channel
Keepalived[55]: Starting VRRP child process, pid=57
Keepalived_vrrp[57]: Registering Kernel netlink command channel
Tue Aug 2 05:49:08 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Keepalived_vrrp[57]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
Tue Aug 2 05:49:08 2022: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
Keepalived_vrrp[57]: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
Tue Aug 2 05:49:08 2022: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
Keepalived_vrrp[57]: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
Tue Aug 2 05:49:08 2022: Assigned address 172.18.0.23 for interface eth0
Keepalived_vrrp[57]: Assigned address 172.18.0.23 for interface eth0
Tue Aug 2 05:49:08 2022: Registering gratuitous ARP shared channel
Keepalived_vrrp[57]: Registering gratuitous ARP shared channel
Tue Aug 2 05:49:08 2022: (VI_1) removing VIPs.
Keepalived_vrrp[57]: (VI_1) removing VIPs.
Tue Aug 2 05:49:08 2022: ------< Global definitions >------
Keepalived_vrrp[57]: ------< Global definitions >------
Tue Aug 2 05:49:08 2022: Network namespace = (default)
Keepalived_vrrp[57]: Network namespace = (default)
Tue Aug 2 05:49:08 2022: Router ID = 8f41ec8e1808
Keepalived_vrrp[57]: Router ID = 8f41ec8e1808
Tue Aug 2 05:49:08 2022: Default smtp_alert = unset
Keepalived_vrrp[57]: Default smtp_alert = unset
Tue Aug 2 05:49:08 2022: Default smtp_alert_vrrp = unset
Keepalived_vrrp[57]: Default smtp_alert_vrrp = unset
Tue Aug 2 05:49:08 2022: Default smtp_alert_checker = unset
Keepalived_vrrp[57]: Default smtp_alert_checker = unset
Tue Aug 2 05:49:08 2022: Checkers log all failures = false
Keepalived_vrrp[57]: Checkers log all failures = false
Tue Aug 2 05:49:08 2022: Dynamic interfaces = false
Keepalived_vrrp[57]: Dynamic interfaces = false
Tue Aug 2 05:49:08 2022: Default interface = eth0
Keepalived_vrrp[57]: Default interface = eth0
Tue Aug 2 05:49:08 2022: LVS flush = false
Keepalived_vrrp[57]: LVS flush = false
Tue Aug 2 05:49:08 2022: LVS flush on stop = disabled
Keepalived_vrrp[57]: LVS flush on stop = disabled
Tue Aug 2 05:49:08 2022: VRRP notify priority changes = false
Keepalived_vrrp[57]: VRRP notify priority changes = false
Tue Aug 2 05:49:08 2022: VRRP IPv4 mcast group = 224.0.0.18
Keepalived_vrrp[57]: VRRP IPv4 mcast group = 224.0.0.18
Tue Aug 2 05:49:08 2022: VRRP IPv6 mcast group = ff02::12
Keepalived_vrrp[57]: VRRP IPv6 mcast group = ff02::12
Tue Aug 2 05:49:08 2022: Gratuitous ARP delay = 5
Keepalived_vrrp[57]: Gratuitous ARP delay = 5
Tue Aug 2 05:49:08 2022: Gratuitous ARP repeat = 5
Keepalived_vrrp[57]: Gratuitous ARP repeat = 5
Tue Aug 2 05:49:08 2022: Gratuitous ARP refresh timer = 0
Keepalived_vrrp[57]: Gratuitous ARP refresh timer = 0
Tue Aug 2 05:49:08 2022: Gratuitous ARP refresh repeat = 1
Keepalived_vrrp[57]: Gratuitous ARP refresh repeat = 1
Tue Aug 2 05:49:08 2022: Gratuitous ARP lower priority delay = 5
Keepalived_vrrp[57]: Gratuitous ARP lower priority delay = 5
Tue Aug 2 05:49:08 2022: Gratuitous ARP lower priority repeat = 5
Keepalived_vrrp[57]: Gratuitous ARP lower priority repeat = 5
Tue Aug 2 05:49:08 2022: Send advert after receive lower priority advert = true
Keepalived_vrrp[57]: Send advert after receive lower priority advert = true
Tue Aug 2 05:49:08 2022: Send advert after receive higher priority advert = false
Keepalived_vrrp[57]: Send advert after receive higher priority advert = false
Tue Aug 2 05:49:08 2022: Gratuitous ARP interval = 0.000000
Keepalived_vrrp[57]: Gratuitous ARP interval = 0.000000
Tue Aug 2 05:49:08 2022: Gratuitous NA interval = 0.000000
Keepalived_vrrp[57]: Gratuitous NA interval = 0.000000
Tue Aug 2 05:49:08 2022: VRRP default protocol version = 2
Keepalived_vrrp[57]: VRRP default protocol version = 2
Tue Aug 2 05:49:08 2022: VRRP check unicast_src = false
Keepalived_vrrp[57]: VRRP check unicast_src = false
Tue Aug 2 05:49:08 2022: VRRP skip check advert addresses = false
Keepalived_vrrp[57]: VRRP skip check advert addresses = false
Tue Aug 2 05:49:08 2022: VRRP strict mode = false
Keepalived_vrrp[57]: VRRP strict mode = false
Tue Aug 2 05:49:08 2022: VRRP process priority = 0
Keepalived_vrrp[57]: VRRP process priority = 0
Tue Aug 2 05:49:08 2022: VRRP don't swap = false
Keepalived_vrrp[57]: VRRP don't swap = false
Tue Aug 2 05:49:08 2022: VRRP realtime priority = 0
Keepalived_vrrp[57]: VRRP realtime priority = 0
Tue Aug 2 05:49:08 2022: Checker process priority = 0
Keepalived_vrrp[57]: Checker process priority = 0
Tue Aug 2 05:49:08 2022: Checker don't swap = false
Keepalived_vrrp[57]: Checker don't swap = false
Tue Aug 2 05:49:08 2022: Checker realtime priority = 0
Keepalived_vrrp[57]: Checker realtime priority = 0
Tue Aug 2 05:49:08 2022: Script security disabled
Keepalived_vrrp[57]: Script security disabled
Tue Aug 2 05:49:08 2022: Default script uid:gid 0:0
Keepalived_vrrp[57]: Default script uid:gid 0:0
Tue Aug 2 05:49:08 2022: vrrp_netlink_cmd_rcv_bufs = 0
Keepalived_vrrp[57]: vrrp_netlink_cmd_rcv_bufs = 0
Tue Aug 2 05:49:08 2022: vrrp_netlink_cmd_rcv_bufs_force = 0
Keepalived_vrrp[57]: vrrp_netlink_cmd_rcv_bufs_force = 0
Tue Aug 2 05:49:08 2022: vrrp_netlink_monitor_rcv_bufs = 0
Keepalived_vrrp[57]: vrrp_netlink_monitor_rcv_bufs = 0
Tue Aug 2 05:49:08 2022: vrrp_netlink_monitor_rcv_bufs_force = 0
Keepalived_vrrp[57]: vrrp_netlink_monitor_rcv_bufs_force = 0
Tue Aug 2 05:49:08 2022: process_monitor_rcv_bufs = 0
Keepalived_vrrp[57]: process_monitor_rcv_bufs = 0
Tue Aug 2 05:49:08 2022: process_monitor_rcv_bufs_force = 0
Keepalived_vrrp[57]: process_monitor_rcv_bufs_force = 0
Tue Aug 2 05:49:08 2022: lvs_netlink_cmd_rcv_bufs = 0
Keepalived_vrrp[57]: lvs_netlink_cmd_rcv_bufs = 0
Tue Aug 2 05:49:08 2022: lvs_netlink_cmd_rcv_bufs_force = 0
Keepalived_vrrp[57]: lvs_netlink_cmd_rcv_bufs_force = 0
Tue Aug 2 05:49:08 2022: lvs_netlink_monitor_rcv_bufs = 0
Keepalived_vrrp[57]: lvs_netlink_monitor_rcv_bufs = 0
Tue Aug 2 05:49:08 2022: lvs_netlink_monitor_rcv_bufs_force = 0
Keepalived_vrrp[57]: lvs_netlink_monitor_rcv_bufs_force = 0
Tue Aug 2 05:49:08 2022: rs_init_notifies = 0
Keepalived_vrrp[57]: rs_init_notifies = 0
Tue Aug 2 05:49:08 2022: no_checker_emails = 0
Keepalived_vrrp[57]: no_checker_emails = 0
Tue Aug 2 05:49:08 2022: rx_bufs_multiples = 3
Keepalived_vrrp[57]: rx_bufs_multiples = 3
Tue Aug 2 05:49:08 2022: umask = 0177
Keepalived_vrrp[57]: umask = 0177
Tue Aug 2 05:49:08 2022: ------< VRRP Topology >------
Keepalived_vrrp[57]: ------< VRRP Topology >------
Tue Aug 2 05:49:08 2022: VRRP Instance = VI_1
Keepalived_vrrp[57]: VRRP Instance = VI_1
Tue Aug 2 05:49:08 2022: VRRP Version = 2
Keepalived_vrrp[57]: VRRP Version = 2
Tue Aug 2 05:49:08 2022: Wantstate = BACKUP
Keepalived_vrrp[57]: Wantstate = BACKUP
Tue Aug 2 05:49:08 2022: Interface = eth0
Keepalived_vrrp[57]: Interface = eth0
Tue Aug 2 05:49:08 2022: Using src_ip = 172.18.0.23
Keepalived_vrrp[57]: Using src_ip = 172.18.0.23
Tue Aug 2 05:49:08 2022: Gratuitous ARP delay = 5
Keepalived_vrrp[57]: Gratuitous ARP delay = 5
Tue Aug 2 05:49:08 2022: Gratuitous ARP repeat = 5
Keepalived_vrrp[57]: Gratuitous ARP repeat = 5
Tue Aug 2 05:49:08 2022: Gratuitous ARP refresh = 0
Keepalived_vrrp[57]: Gratuitous ARP refresh = 0
Tue Aug 2 05:49:08 2022: Gratuitous ARP refresh repeat = 1
Keepalived_vrrp[57]: Gratuitous ARP refresh repeat = 1
Tue Aug 2 05:49:08 2022: Gratuitous ARP lower priority delay = 5
Keepalived_vrrp[57]: Gratuitous ARP lower priority delay = 5
Tue Aug 2 05:49:08 2022: Gratuitous ARP lower priority repeat = 5
Keepalived_vrrp[57]: Gratuitous ARP lower priority repeat = 5
Tue Aug 2 05:49:08 2022: Send advert after receive lower priority advert = true
Keepalived_vrrp[57]: Send advert after receive lower priority advert = true
Tue Aug 2 05:49:08 2022: Send advert after receive higher priority advert = false
Keepalived_vrrp[57]: Send advert after receive higher priority advert = false
Tue Aug 2 05:49:08 2022: Virtual Router ID = 51
Keepalived_vrrp[57]: Virtual Router ID = 51
Tue Aug 2 05:49:08 2022: Priority = 150
Keepalived_vrrp[57]: Priority = 150
Tue Aug 2 05:49:08 2022: Advert interval = 1 sec
Keepalived_vrrp[57]: Advert interval = 1 sec
Tue Aug 2 05:49:08 2022: Accept = enabled
Keepalived_vrrp[57]: Accept = enabled
Tue Aug 2 05:49:08 2022: Preempt = disabled
Keepalived_vrrp[57]: Preempt = disabled
Tue Aug 2 05:49:08 2022: Promote_secondaries = disabled
Keepalived_vrrp[57]: Promote_secondaries = disabled
Tue Aug 2 05:49:08 2022: Authentication type = SIMPLE_PASSWORD
Keepalived_vrrp[57]: Authentication type = SIMPLE_PASSWORD
Tue Aug 2 05:49:08 2022: Password = d0cker
Keepalived_vrrp[57]: Password = d0cker
Tue Aug 2 05:49:08 2022: Virtual IP = 2
Keepalived_vrrp[57]: Virtual IP = 2
Tue Aug 2 05:49:08 2022: 172.18.0.3 dev eth0 scope global
Keepalived_vrrp[57]: 172.18.0.3 dev eth0 scope global
Tue Aug 2 05:49:08 2022: 172.18.0.4 dev eth0 scope global
Keepalived_vrrp[57]: 172.18.0.4 dev eth0 scope global
Tue Aug 2 05:49:08 2022: Unicast Peer = 3
Keepalived_vrrp[57]: Unicast Peer = 3
Tue Aug 2 05:49:08 2022: 172.18.0.21
Keepalived_vrrp[57]: 172.18.0.21
Tue Aug 2 05:49:08 2022: 172.18.0.22
Keepalived_vrrp[57]: 172.18.0.22
Tue Aug 2 05:49:08 2022: 172.18.0.23
Keepalived_vrrp[57]: 172.18.0.23
Tue Aug 2 05:49:08 2022: Unicast checksum compatibility = no
Keepalived_vrrp[57]: Unicast checksum compatibility = no
Tue Aug 2 05:49:08 2022: No sockets allocated
Keepalived_vrrp[57]: No sockets allocated
Tue Aug 2 05:49:08 2022: Using smtp notification = no
Keepalived_vrrp[57]: Using smtp notification = no
Tue Aug 2 05:49:08 2022: Generic state transition script = '/container/service/keepalived/assets/notify.sh', uid:gid 0:0
Keepalived_vrrp[57]: Generic state transition script = '/container/service/keepalived/assets/notify.sh', uid:gid 0:0
Tue Aug 2 05:49:08 2022: Notify priority changes = false
Keepalived_vrrp[57]: Notify priority changes = false
Tue Aug 2 05:49:08 2022: ------< Interfaces >------
Keepalived_vrrp[57]: ------< Interfaces >------
Tue Aug 2 05:49:08 2022: Name = lo
Keepalived_vrrp[57]: Name = lo
Tue Aug 2 05:49:08 2022: index = 1
Keepalived_vrrp[57]: index = 1
Tue Aug 2 05:49:08 2022: IPv4 address = 127.0.0.1
Keepalived_vrrp[57]: IPv4 address = 127.0.0.1
Tue Aug 2 05:49:08 2022: IPv6 address = (none)
Keepalived_vrrp[57]: IPv6 address = (none)
Tue Aug 2 05:49:08 2022: State = UP, RUNNING, no broadcast, loopback, no multicast
Keepalived_vrrp[57]: State = UP, RUNNING, no broadcast, loopback, no multicast
Tue Aug 2 05:49:08 2022: MTU = 65536
Keepalived_vrrp[57]: MTU = 65536
Tue Aug 2 05:49:08 2022: HW Type = LOOPBACK
Keepalived_vrrp[57]: HW Type = LOOPBACK
Tue Aug 2 05:49:08 2022: NIC netlink status update
Keepalived_vrrp[57]: NIC netlink status update
Tue Aug 2 05:49:08 2022: Reset ARP config counter 0
Keepalived_vrrp[57]: Reset ARP config counter 0
Tue Aug 2 05:49:08 2022: Original arp_ignore 0
Keepalived_vrrp[57]: Original arp_ignore 0
Tue Aug 2 05:49:08 2022: Original arp_filter 0
Keepalived_vrrp[57]: Original arp_filter 0
Tue Aug 2 05:49:08 2022: Original promote_secondaries 0
Keepalived_vrrp[57]: Original promote_secondaries 0
Tue Aug 2 05:49:08 2022: Reset promote_secondaries counter 0
Keepalived_vrrp[57]: Reset promote_secondaries counter 0
Tue Aug 2 05:49:08 2022: Tracking VRRP instances = 0
Keepalived_vrrp[57]: Tracking VRRP instances = 0
Tue Aug 2 05:49:08 2022: Name = tunl0
Keepalived_vrrp[57]: Name = tunl0
Tue Aug 2 05:49:08 2022: index = 2
Keepalived_vrrp[57]: index = 2
Tue Aug 2 05:49:08 2022: IPv4 address = (none)
Keepalived_vrrp[57]: IPv4 address = (none)
Tue Aug 2 05:49:08 2022: IPv6 address = (none)
Keepalived_vrrp[57]: IPv6 address = (none)
Tue Aug 2 05:49:08 2022: State = not UP, not RUNNING, no broadcast, no arp, no multicast
Keepalived_vrrp[57]: State = not UP, not RUNNING, no broadcast, no arp, no multicast
Tue Aug 2 05:49:08 2022: MTU = 1480
Keepalived_vrrp[57]: MTU = 1480
Tue Aug 2 05:49:08 2022: HW Type = UNKNOWN (768)
Keepalived_vrrp[57]: HW Type = UNKNOWN (768)
Tue Aug 2 05:49:08 2022: NIC netlink status update
Keepalived_vrrp[57]: NIC netlink status update
Tue Aug 2 05:49:08 2022: Reset ARP config counter 0
Keepalived_vrrp[57]: Reset ARP config counter 0
Tue Aug 2 05:49:08 2022: Original arp_ignore 0
Keepalived_vrrp[57]: Original arp_ignore 0
Tue Aug 2 05:49:08 2022: Original arp_filter 0
Keepalived_vrrp[57]: Original arp_filter 0
Tue Aug 2 05:49:08 2022: Original promote_secondaries 0
Keepalived_vrrp[57]: Original promote_secondaries 0
Tue Aug 2 05:49:08 2022: Reset promote_secondaries counter 0
Keepalived_vrrp[57]: Reset promote_secondaries counter 0
Tue Aug 2 05:49:08 2022: Tracking VRRP instances = 0
Keepalived_vrrp[57]: Tracking VRRP instances = 0
Tue Aug 2 05:49:08 2022: Name = ip6tnl0
Keepalived_vrrp[57]: Name = ip6tnl0
Tue Aug 2 05:49:08 2022: index = 3
Keepalived_vrrp[57]: index = 3
Tue Aug 2 05:49:08 2022: IPv4 address = (none)
Keepalived_vrrp[57]: IPv4 address = (none)
Tue Aug 2 05:49:08 2022: IPv6 address = (none)
Keepalived_vrrp[57]: IPv6 address = (none)
Tue Aug 2 05:49:08 2022: State = not UP, not RUNNING, no broadcast, no arp, no multicast
Keepalived_vrrp[57]: State = not UP, not RUNNING, no broadcast, no arp, no multicast
Tue Aug 2 05:49:08 2022: MTU = 1452
Keepalived_vrrp[57]: MTU = 1452
Tue Aug 2 05:49:08 2022: HW Type = UNKNOWN (769)
Keepalived_vrrp[57]: HW Type = UNKNOWN (769)
Tue Aug 2 05:49:08 2022: NIC netlink status update
Keepalived_vrrp[57]: NIC netlink status update
Tue Aug 2 05:49:08 2022: Reset ARP config counter 0
Keepalived_vrrp[57]: Reset ARP config counter 0
Tue Aug 2 05:49:08 2022: Original arp_ignore 0
Keepalived_vrrp[57]: Original arp_ignore 0
Tue Aug 2 05:49:08 2022: Original arp_filter 0
Keepalived_vrrp[57]: Original arp_filter 0
Tue Aug 2 05:49:08 2022: Original promote_secondaries 0
Keepalived_vrrp[57]: Original promote_secondaries 0
Tue Aug 2 05:49:08 2022: Reset promote_secondaries counter 0
Keepalived_vrrp[57]: Reset promote_secondaries counter 0
Tue Aug 2 05:49:08 2022: Tracking VRRP instances = 0
Keepalived_vrrp[57]: Tracking VRRP instances = 0
Tue Aug 2 05:49:08 2022: Name = eth0
Keepalived_vrrp[57]: Name = eth0
Tue Aug 2 05:49:08 2022: index = 23
Keepalived_vrrp[57]: index = 23
Tue Aug 2 05:49:08 2022: IPv4 address = 172.18.0.23
Keepalived_vrrp[57]: IPv4 address = 172.18.0.23
Tue Aug 2 05:49:08 2022: IPv6 address = (none)
Keepalived_vrrp[57]: IPv6 address = (none)
Tue Aug 2 05:49:08 2022: MAC = 02:42:ac:12:00:17
Keepalived_vrrp[57]: MAC = 02:42:ac:12:00:17
Tue Aug 2 05:49:08 2022: MAC broadcast = ff:ff:ff:ff:ff:ff
Keepalived_vrrp[57]: MAC broadcast = ff:ff:ff:ff:ff:ff
Tue Aug 2 05:49:08 2022: State = UP, RUNNING
Keepalived_vrrp[57]: State = UP, RUNNING
Tue Aug 2 05:49:08 2022: MTU = 1500
Keepalived_vrrp[57]: MTU = 1500
Tue Aug 2 05:49:08 2022: HW Type = ETHERNET
Keepalived_vrrp[57]: HW Type = ETHERNET
Tue Aug 2 05:49:08 2022: NIC netlink status update
Keepalived_vrrp[57]: NIC netlink status update
Tue Aug 2 05:49:08 2022: Reset ARP config counter 0
Keepalived_vrrp[57]: Reset ARP config counter 0
Tue Aug 2 05:49:08 2022: Original arp_ignore 0
Keepalived_vrrp[57]: Original arp_ignore 0
Tue Aug 2 05:49:08 2022: Original arp_filter 0
Keepalived_vrrp[57]: Original arp_filter 0
Tue Aug 2 05:49:08 2022: Original promote_secondaries 0
Keepalived_vrrp[57]: Original promote_secondaries 0
Tue Aug 2 05:49:08 2022: Reset promote_secondaries counter 0
Keepalived_vrrp[57]: Reset promote_secondaries counter 0
Tue Aug 2 05:49:08 2022: Tracking VRRP instances = 1
Keepalived_vrrp[57]: Tracking VRRP instances = 1
Tue Aug 2 05:49:08 2022: VI_1, weight 0
Keepalived_vrrp[57]: VI_1, weight 0
Tue Aug 2 05:49:08 2022: (VI_1) Entering BACKUP STATE (init)
Keepalived_vrrp[57]: (VI_1) Entering BACKUP STATE (init)
Tue Aug 2 05:49:08 2022: VRRP sockpool: [ifindex(23), family(IPv4), proto(112), unicast(1), fd(11,12)]
Keepalived_vrrp[57]: VRRP sockpool: [ifindex(23), family(IPv4), proto(112), unicast(1), fd(11,12)]
# 当前节点为backup节点
Ok, i'm just a backup, great.
openresty keepalived
*************
创建镜像
下载安装包:https://www.keepalived.org/download.html
[email protected] source % pwd
/Users/huli/lua/openresty/keep/source
[email protected] source % ls
keepalived-2.2.7.tar.gz
镜像包含keepalived
# 创建基础容器
docker run -it -d --net fixed --ip 172.18.0.81 -p 9001:80 --privileged \
-v /Users/huli/lua/openresty/keep/source:/source \
--name open-keepalived lihu12344/openresty init
# 进入容器
docker exec -it open-keepalived bash
# 依次执行以下命令
yum -y install openssl-devel gcc gcc-c++ libnl libnl-devel libstdc++.i686 initscripts
yum -y install rsyslog
systemctl start rsyslog
mkdir -p /var/run/openresty/
touch /var/run/openresty/nginx-client-body
mkdir -p /tmp/keepalived
cp /source/* /tmp/keepalived
cd /tmp/keepalived
tar -zxvf keepalived-2.2.7.tar.gz
mv keepalived-2.2.7 /usr/local/keepalived
cd /usr/local/keepalived
./configure --prefix=/usr/local/keepalived
make && make install
cp etc/sysconfig/keepalived /etc/sysconfig/keepalived
cp sbin/keepalived /usr/sbin/keepalived
cp keepalived/etc/init.d/keepalived /etc/rc.d/init.d/keepalived
mkdir -p /etc/keepalived
* keepalived配置文件
vi /etc/keepalived/keepalived.conf
* 添加并开启keepalived服务,设置为开机自启
chkconfig --add keepalived
chkconfig keepalived on
systemctl start keepalived
# 退出容器后,创建镜像文件
docker commit open-keepalived lihu12344/open-keepalived
keepalived配置文件
global_defs {
default_interface eth0
}
vrrp_instance VI_1 {
interface eth0
state BACKUP
virtual_router_id 50
priority 150
nopreempt
unicast_peer {
172.18.0.81
172.18.0.82
}
virtual_ipaddress {
172.18.0.83
}
authentication {
auth_type PASS
auth_pass d0cker
}
notify "/container/service/keepalived/assets/notify.sh"
}
*************
主备服务器
default.conf
server {
listen 80;
server_name localhost;
location / {
root /usr/local/openresty/nginx/html;
index index.html index.htm;
}
location /test {
echo "172.18.0.81";
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/openresty/nginx/html;
}
}
default2.conf
server {
listen 80;
server_name localhost;
location / {
root /usr/local/openresty/nginx/html;
index index.html index.htm;
}
location /test {
echo "172.18.0.82";
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/openresty/nginx/html;
}
}
创建openresty主备容器
docker run -it -d --net fixed --ip 172.18.0.81 -p 6001:80 --privileged \
-v /Users/huli/lua/openresty/keep/default.conf:/etc/nginx/conf.d/default.conf \
--name open-keepalived lihu12344/open-keepalived init
docker run -it -d --net fixed --ip 172.18.0.82 -p 6002:80 --privileged \
-v /Users/huli/lua/openresty/keep/default2.conf:/etc/nginx/conf.d/default.conf \
--name open-keepalived2 lihu12344/open-keepalived init
# 进入容器,开启openresty服务
mkdir -p /var/run/openresty
touch /var/run/openresty/nginx-client-body
./usr/bin/openresty
open-keepalived、open-keepalived2均正常工作
# keepalived
[[email protected] /]# curl localhost:80/test
127.0.0.1 - - [03/Aug/2022:01:36:03 +0000] "GET /test HTTP/1.1" 200 22 "-" "curl/7.29.0"
172.18.0.81
[[email protected] /]# curl 172.18.0.83:80/test
172.18.0.83 - - [03/Aug/2022:01:36:12 +0000] "GET /test HTTP/1.1" 200 22 "-" "curl/7.29.0"
172.18.0.81
# keepalived2
[[email protected] /]# curl localhost:80/test
127.0.0.1 - - [03/Aug/2022:01:37:12 +0000] "GET /test HTTP/1.1" 200 22 "-" "curl/7.29.0"
172.18.0.82
[[email protected] /]# curl 172.18.0.83:80/test
172.18.0.81
open-keepalived关闭、open-kepalived2正常工作
# open-keepalived2
[[email protected] /]# curl localhost:80/test
127.0.0.1 - - [03/Aug/2022:02:13:20 +0000] "GET /test HTTP/1.1" 200 22 "-" "curl/7.29.0"
172.18.0.82
[[email protected] /]# curl 172.18.0.83:80/test
172.18.0.83 - - [03/Aug/2022:02:13:24 +0000] "GET /test HTTP/1.1" 200 22 "-" "curl/7.29.0"
172.18.0.82
open-keepalived2切换为master服务器,使用虚拟ip调用,输出open-keepalived2接口
边栏推荐
- ASP.NET Core依赖注入之旅:3.Service Locator和依赖注入
- 想要防止数据泄漏,如何选择国产浏览器?
- 细胞不可渗透的荧光探针 锌离子荧光探针Zinquin 151606-29-0
- 多表查询最值
- ATM银行系统(对象初级练习)
- 走进通信:为什么4G信号满格,却上不了网呢
- Dataworks中PyOdps里面pandas.read_sql()支持Odps吗?
- Cool open technology x StarRocks: unified OLAP analysis engine, comprehensive building digital model of OTT
- WPF 实现柱形统计图
- 多肽介导PEG磷脂——靶向功能材料之DSPE-PEG-RGD/TAT/NGR/APRPG
猜你喜欢
随机推荐
华为ECS云服务器上安装Docker及部署Redis详细教程【华为云至简致远】
分享 14 个你必须知道的 JS 函数
【技术白皮书】第二章:OCR智能文字识别回顾——自然语言文本发展历程
【机器学习】机器学习的基本概念/术语2
LyScript 从文本中读写ShellCode
常见荧光染料修饰多种基团及其激发和 发射波长数据一览数据
快手通过国际权威信息安全和隐私保护认证,安全能力达到国际领先水平
想要防止数据泄漏,如何选择国产浏览器?
云图说丨初识华为云微服务引擎CSE
ATM银行系统(对象初级练习)
计网知识点
Trie思想及模板
@resource和@autowired的区别
【Django-Docker】Sqlite3.db读取权限不够-20220803
CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes), problem: (D) Magical Array
CC2530_ZigBee+HUAWEI CLOUD IOT: Design your own cold chain acquisition system
JSON.stringify()的深入学习和理解
广告电商、泰山众筹、链动2+1,这3个模式到底怎么样?
TiFlash 计算层概览
云图说丨初识华为云微服务引擎CSE