• openresty 高可用部署



    openresty 高可用部署

                

    docker keepalived:https://github.com/osixia/docker-keepalived

              

                         

                                        

    keepalived 原理

                               

                      

              

    常见应用:解决nginx、openresty等单点故障,实现高可用部署

    1. nginx/openresty可实现后端服务的负载均衡,但一个集群如果只有一台nginx,会容易出现单点故障;
    2. 可结合keepalived实现主从备份,当nginx、openresty出现故障时,能自动切换到备用节点

                        

    VRRP协议:虚拟路由冗余协议(Virtual Router Redundancy Protocol)

    1. keepalived内置了VRRP协议,对外提供一个虚拟ip(也可为真实服务器ip),供外部访问;
    2. keepalived服务器通过arp广播(同网段传播,无法跨网段)的方式,进行节点之间的通信;
    3. master服务器发生故障时,通过选举策略,自动将backup服务器切换为master服务器;

               

    VRRP 选主策略

    1. virtual ip地址拥有者,优先成为master服务器;
    2. 如果没有virtual ip拥有者,优先级高的节点成为master服务器;
    3. 如果没有virtual ip拥有者,且优先级相同,则ip地址大的成为master服务器

                

    抢占式选主、非抢占式选主

    1. # 相关配置属性
    2. state:节点初始状态(master、backup)
    3. priority:当前节点的优先级,抢占模式下,优先级高的成为master节点
    4. nopreempt:非抢占模式,节点在backup状态下,即使优先级比master节点高,也不会去抢占master服务器
    5. # 抢占式选主:master服务器故障恢复后,会重新抢占master服务器
    6. * 优先级高的成为master服务器,优先级低的为backup服务器;
    7. * 当master服务器故障后,优先级高的backup服务器成为master服务器;
    8. * 原master服务器恢复后,如果优先级比当前的master服务器高,
    9. 则会切换称为maeter服务器,当前服务器降级为backup服务器
    10. # 非抢占式选主:master服务器故障恢复后,保持backup状态,不会抢占master服务器
    11. * 如果节点的初始状态都是backup,并且标识了nopreempt,则为非抢占模式
    12. * 非抢占模式下,哪个节点先启动,哪个节点就成为master服务器
    13. * 原master服务器故障恢复后,不会去抢占master服务器,避免了master切换,常用于生产环境

              

                    

                                        

    docker keepalived

                         

    下载镜像

    docker pull osixia/keepalived

                  

    配置文件:/usr/local/etc/keepalived/keepalived.conf

    1. global_defs { # 全剧默认配置
    2. default_interface eth0 # 默认网卡
    3. }
    4. vrrp_instance VI_1 {
    5. interface eth0 # 网卡
    6. state BACKUP # 节点初始状态
    7. virtual_router_id 51 # 虚拟路由id,同一集群id需保持一致
    8. priority 150 # 优先级
    9. nopreempt # 非抢占模式
    10. unicast_peer { # 路由节点
    11. 192.168.1.10
    12. 192.168.1.11
    13. }
    14. virtual_ipaddress { # 虚拟ip地址
    15. 192.168.1.231
    16. 192.168.1.232
    17. }
    18. authentication { # 认证
    19. auth_type PASS
    20. auth_pass d0cker
    21. }
    22. notify "/container/service/keepalived/assets/notify.sh"
    23. }

               

    通知脚本:/container/service/keepalived/assets/notify.sh

    1. #!/bin/bash
    2. # for ANY state transition.
    3. # "notify" script is called AFTER the
    4. # notify_* script(s) and is executed
    5. # with 3 arguments provided by keepalived
    6. # (ie don't include parameters in the notify line).
    7. # arguments
    8. # $1 = "GROUP"|"INSTANCE"
    9. # $2 = name of group or instance
    10. # $3 = target state of transition
    11. # ("MASTER"|"BACKUP"|"FAULT")
    12. TYPE=$1
    13. NAME=$2
    14. STATE=$3
    15. case $STATE in
    16. "MASTER") echo "I'm the MASTER! Whup whup." > /proc/1/fd/1
    17. exit 0
    18. ;;
    19. "BACKUP") echo "Ok, i'm just a backup, great." > /proc/1/fd/1
    20. exit 0
    21. ;;
    22. "FAULT") echo "Fault, what ?" > /proc/1/fd/1
    23. exit 0
    24. ;;
    25. *) echo "Unknown state" > /proc/1/fd/1
    26. exit 1
    27. ;;
    28. esac

                

    *************

    创建集群

           

    配置文件(主备服务器配置相同,非抢占模式)

    1. global_defs {
    2. default_interface eth0
    3. }
    4. vrrp_instance VI_1 {
    5. interface eth0
    6. state BACKUP
    7. virtual_router_id 50
    8. priority 150
    9. nopreempt
    10. unicast_peer {
    11. 172.18.0.21
    12. 172.18.0.22
    13. 172.18.0.23
    14. }
    15. virtual_ipaddress {
    16. 172.18.0.3
    17. }
    18. authentication {
    19. auth_type PASS
    20. auth_pass d0cker
    21. }
    22. notify "/container/service/keepalived/assets/notify.sh"
    23. }

                

    创建容器

    1. docker run -it -d --net fixed --ip 172.18.0.21 --privileged \
    2. -v /Users/huli/lua/openresty/keep/keepalived.conf:/usr/local/etc/keepalived/keepalived.conf \
    3. --name keepalived osixia/keepalived
    4. docker run -it -d --net fixed --ip 172.18.0.22 --privileged \
    5. -v /Users/huli/lua/openresty/keep/keepalived.conf:/usr/local/etc/keepalived/keepalived.conf \
    6. --name keepalived2 osixia/keepalived
    7. docker run -it -d --net fixed --ip 172.18.0.23 --privileged \
    8. -v /Users/huli/lua/openresty/keep/keepalived.conf:/usr/local/etc/keepalived/keepalived.conf \
    9. --name keepalived3 osixia/keepalived

            

    查看容器日志:keepalived

    1. huli@hudeMacBook-Pro ~ % docker logs keepalived
    2. *** CONTAINER_LOG_LEVEL = 3 (info)
    3. *** Search service in CONTAINER_SERVICE_DIR = /container/service :
    4. *** link /container/service/keepalived/startup.sh to /container/run/startup/keepalived
    5. *** link /container/service/keepalived/process.sh to /container/run/process/keepalived/run
    6. *** link /container/service/keepalived/finish.sh to /container/run/process/keepalived/finish
    7. *** Set environment for startup files
    8. *** Environment files will be proccessed in this order :
    9. Caution: previously defined variables will not be overriden.
    10. /container/environment/99-default/default.yaml
    11. To see how this files are processed and environment variables values,
    12. run this container with '--loglevel debug'
    13. /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.
    14. env_vars = yaml.load(f)
    15. *** Running /container/run/startup/keepalived...
    16. *** Set environment for container process
    17. *** Environment files will be proccessed in this order :
    18. Caution: previously defined variables will not be overriden.
    19. /container/environment/99-default/default.yaml
    20. To see how this files are processed and environment variables values,
    21. run this container with '--loglevel debug'
    22. *** Running /container/run/process/keepalived/run...
    23. Waiting config file /usr/local/etc/keepalived/keepalived.confok
    24. Tue Aug 2 05:46:44 2022: Starting Keepalived v2.0.20 (01/22,2020)
    25. Keepalived[56]: Starting Keepalived v2.0.20 (01/22,2020)
    26. 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)
    27. 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)
    28. Tue Aug 2 05:46:44 2022: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
    29. Keepalived[56]: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
    30. Tue Aug 2 05:46:44 2022: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
    31. Keepalived[56]: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
    32. Tue Aug 2 05:46:44 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    33. Keepalived[56]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    34. Tue Aug 2 05:46:44 2022: Starting VRRP child process, pid=58
    35. Keepalived[56]: Starting VRRP child process, pid=58
    36. Tue Aug 2 05:46:44 2022: Registering Kernel netlink reflector
    37. Keepalived_vrrp[58]: Registering Kernel netlink reflector
    38. Tue Aug 2 05:46:44 2022: Registering Kernel netlink command channel
    39. Keepalived_vrrp[58]: Registering Kernel netlink command channel
    40. Tue Aug 2 05:46:44 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    41. Keepalived_vrrp[58]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    42. Tue Aug 2 05:46:44 2022: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
    43. Keepalived_vrrp[58]: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
    44. Tue Aug 2 05:46:44 2022: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
    45. Keepalived_vrrp[58]: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
    46. Tue Aug 2 05:46:44 2022: Assigned address 172.18.0.21 for interface eth0
    47. Keepalived_vrrp[58]: Assigned address 172.18.0.21 for interface eth0
    48. Tue Aug 2 05:46:44 2022: Registering gratuitous ARP shared channel
    49. Keepalived_vrrp[58]: Registering gratuitous ARP shared channel
    50. Tue Aug 2 05:46:44 2022: (VI_1) removing VIPs.
    51. Keepalived_vrrp[58]: (VI_1) removing VIPs.
    52. Tue Aug 2 05:46:44 2022: ------< Global definitions >------
    53. Keepalived_vrrp[58]: ------< Global definitions >------
    54. Tue Aug 2 05:46:44 2022: Network namespace = (default)
    55. Keepalived_vrrp[58]: Network namespace = (default)
    56. Tue Aug 2 05:46:44 2022: Router ID = 5d02fb9ca56a
    57. Keepalived_vrrp[58]: Router ID = 5d02fb9ca56a
    58. Tue Aug 2 05:46:44 2022: Default smtp_alert = unset
    59. Keepalived_vrrp[58]: Default smtp_alert = unset
    60. Tue Aug 2 05:46:44 2022: Default smtp_alert_vrrp = unset
    61. Keepalived_vrrp[58]: Default smtp_alert_vrrp = unset
    62. Tue Aug 2 05:46:44 2022: Default smtp_alert_checker = unset
    63. Keepalived_vrrp[58]: Default smtp_alert_checker = unset
    64. Tue Aug 2 05:46:44 2022: Checkers log all failures = false
    65. Keepalived_vrrp[58]: Checkers log all failures = false
    66. Tue Aug 2 05:46:44 2022: Dynamic interfaces = false
    67. Keepalived_vrrp[58]: Dynamic interfaces = false
    68. Tue Aug 2 05:46:44 2022: Default interface = eth0
    69. Keepalived_vrrp[58]: Default interface = eth0
    70. Tue Aug 2 05:46:44 2022: LVS flush = false
    71. Keepalived_vrrp[58]: LVS flush = false
    72. Tue Aug 2 05:46:44 2022: LVS flush on stop = disabled
    73. Keepalived_vrrp[58]: LVS flush on stop = disabled
    74. Tue Aug 2 05:46:44 2022: VRRP notify priority changes = false
    75. Keepalived_vrrp[58]: VRRP notify priority changes = false
    76. Tue Aug 2 05:46:44 2022: VRRP IPv4 mcast group = 224.0.0.18
    77. Keepalived_vrrp[58]: VRRP IPv4 mcast group = 224.0.0.18
    78. Tue Aug 2 05:46:44 2022: VRRP IPv6 mcast group = ff02::12
    79. Keepalived_vrrp[58]: VRRP IPv6 mcast group = ff02::12
    80. Tue Aug 2 05:46:44 2022: Gratuitous ARP delay = 5
    81. Keepalived_vrrp[58]: Gratuitous ARP delay = 5
    82. Tue Aug 2 05:46:44 2022: Gratuitous ARP repeat = 5
    83. Keepalived_vrrp[58]: Gratuitous ARP repeat = 5
    84. Tue Aug 2 05:46:44 2022: Gratuitous ARP refresh timer = 0
    85. Keepalived_vrrp[58]: Gratuitous ARP refresh timer = 0
    86. Tue Aug 2 05:46:44 2022: Gratuitous ARP refresh repeat = 1
    87. Keepalived_vrrp[58]: Gratuitous ARP refresh repeat = 1
    88. Tue Aug 2 05:46:44 2022: Gratuitous ARP lower priority delay = 5
    89. Keepalived_vrrp[58]: Gratuitous ARP lower priority delay = 5
    90. Tue Aug 2 05:46:44 2022: Gratuitous ARP lower priority repeat = 5
    91. Keepalived_vrrp[58]: Gratuitous ARP lower priority repeat = 5
    92. Tue Aug 2 05:46:44 2022: Send advert after receive lower priority advert = true

              

    查看容器日志:keepalived2

    1. huli@hudeMacBook-Pro ~ % docker logs keepalived2
    2. *** CONTAINER_LOG_LEVEL = 3 (info)
    3. *** Search service in CONTAINER_SERVICE_DIR = /container/service :
    4. *** link /container/service/keepalived/startup.sh to /container/run/startup/keepalived
    5. *** link /container/service/keepalived/process.sh to /container/run/process/keepalived/run
    6. *** link /container/service/keepalived/finish.sh to /container/run/process/keepalived/finish
    7. *** Set environment for startup files
    8. *** Environment files will be proccessed in this order :
    9. Caution: previously defined variables will not be overriden.
    10. /container/environment/99-default/default.yaml
    11. To see how this files are processed and environment variables values,
    12. run this container with '--loglevel debug'
    13. /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.
    14. env_vars = yaml.load(f)
    15. *** Running /container/run/startup/keepalived...
    16. *** Set environment for container process
    17. *** Environment files will be proccessed in this order :
    18. Caution: previously defined variables will not be overriden.
    19. /container/environment/99-default/default.yaml
    20. To see how this files are processed and environment variables values,
    21. run this container with '--loglevel debug'
    22. *** Running /container/run/process/keepalived/run...
    23. Waiting config file /usr/local/etc/keepalived/keepalived.confok
    24. Tue Aug 2 05:46:59 2022: Starting Keepalived v2.0.20 (01/22,2020)
    25. Keepalived[55]: Starting Keepalived v2.0.20 (01/22,2020)
    26. 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)
    27. 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)
    28. Tue Aug 2 05:46:59 2022: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
    29. Keepalived[55]: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
    30. Tue Aug 2 05:46:59 2022: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
    31. Keepalived[55]: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
    32. Tue Aug 2 05:46:59 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    33. Keepalived[55]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    34. Tue Aug 2 05:46:59 2022: Starting VRRP child process, pid=57
    35. Keepalived[55]: Starting VRRP child process, pid=57
    36. Tue Aug 2 05:46:59 2022: Registering Kernel netlink reflector
    37. Keepalived_vrrp[57]: Registering Kernel netlink reflector
    38. Tue Aug 2 05:46:59 2022: Registering Kernel netlink command channel
    39. Keepalived_vrrp[57]: Registering Kernel netlink command channel
    40. Tue Aug 2 05:46:59 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    41. Keepalived_vrrp[57]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    42. Tue Aug 2 05:46:59 2022: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
    43. Keepalived_vrrp[57]: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
    44. Tue Aug 2 05:46:59 2022: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
    45. Keepalived_vrrp[57]: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
    46. Tue Aug 2 05:46:59 2022: Assigned address 172.18.0.22 for interface eth0
    47. Keepalived_vrrp[57]: Assigned address 172.18.0.22 for interface eth0
    48. Tue Aug 2 05:46:59 2022: Registering gratuitous ARP shared channel
    49. Keepalived_vrrp[57]: Registering gratuitous ARP shared channel
    50. Tue Aug 2 05:46:59 2022: (VI_1) removing VIPs.
    51. Keepalived_vrrp[57]: (VI_1) removing VIPs.
    52. Tue Aug 2 05:46:59 2022: ------< Global definitions >------
    53. Keepalived_vrrp[57]: ------< Global definitions >------
    54. Tue Aug 2 05:46:59 2022: Network namespace = (default)
    55. Keepalived_vrrp[57]: Network namespace = (default)
    56. Tue Aug 2 05:46:59 2022: Router ID = 0b054866c757
    57. Keepalived_vrrp[57]: Router ID = 0b054866c757
    58. Tue Aug 2 05:46:59 2022: Default smtp_alert = unset
    59. Keepalived_vrrp[57]: Default smtp_alert = unset
    60. Tue Aug 2 05:46:59 2022: Default smtp_alert_vrrp = unset
    61. Keepalived_vrrp[57]: Default smtp_alert_vrrp = unset
    62. Tue Aug 2 05:46:59 2022: Default smtp_alert_checker = unset
    63. Keepalived_vrrp[57]: Default smtp_alert_checker = unset
    64. Tue Aug 2 05:46:59 2022: Checkers log all failures = false
    65. Keepalived_vrrp[57]: Checkers log all failures = false
    66. Tue Aug 2 05:46:59 2022: Dynamic interfaces = false
    67. Keepalived_vrrp[57]: Dynamic interfaces = false
    68. Tue Aug 2 05:46:59 2022: Default interface = eth0
    69. Keepalived_vrrp[57]: Default interface = eth0
    70. Tue Aug 2 05:46:59 2022: LVS flush = false
    71. Keepalived_vrrp[57]: LVS flush = false
    72. Tue Aug 2 05:46:59 2022: LVS flush on stop = disabled
    73. Keepalived_vrrp[57]: LVS flush on stop = disabled
    74. Tue Aug 2 05:46:59 2022: VRRP notify priority changes = false
    75. Keepalived_vrrp[57]: VRRP notify priority changes = false
    76. Tue Aug 2 05:46:59 2022: VRRP IPv4 mcast group = 224.0.0.18
    77. Keepalived_vrrp[57]: VRRP IPv4 mcast group = 224.0.0.18
    78. Tue Aug 2 05:46:59 2022: VRRP IPv6 mcast group = ff02::12
    79. Keepalived_vrrp[57]: VRRP IPv6 mcast group = ff02::12
    80. Tue Aug 2 05:46:59 2022: Gratuitous ARP delay = 5
    81. Keepalived_vrrp[57]: Gratuitous ARP delay = 5
    82. Tue Aug 2 05:46:59 2022: Gratuitous ARP repeat = 5
    83. Keepalived_vrrp[57]: Gratuitous ARP repeat = 5
    84. Tue Aug 2 05:46:59 2022: Gratuitous ARP refresh timer = 0
    85. Keepalived_vrrp[57]: Gratuitous ARP refresh timer = 0
    86. Tue Aug 2 05:46:59 2022: Gratuitous ARP refresh repeat = 1
    87. Keepalived_vrrp[57]: Gratuitous ARP refresh repeat = 1
    88. Tue Aug 2 05:46:59 2022: Gratuitous ARP lower priority delay = 5
    89. Keepalived_vrrp[57]: Gratuitous ARP lower priority delay = 5
    90. Tue Aug 2 05:46:59 2022: Gratuitous ARP lower priority repeat = 5
    91. Keepalived_vrrp[57]: Gratuitous ARP lower priority repeat = 5
    92. Tue Aug 2 05:46:59 2022: Send advert after receive lower priority advert = true
    93. Keepalived_vrrp[57]: Send advert after receive lower priority advert = true
    94. Tue Aug 2 05:46:59 2022: Send advert after receive higher priority advert = false
    95. Keepalived_vrrp[57]: Send advert after receive higher priority advert = false
    96. Tue Aug 2 05:46:59 2022: Gratuitous ARP interval = 0.000000
    97. Keepalived_vrrp[57]: Gratuitous ARP interval = 0.000000
    98. Tue Aug 2 05:46:59 2022: Gratuitous NA interval = 0.000000
    99. Keepalived_vrrp[57]: Gratuitous NA interval = 0.000000
    100. Tue Aug 2 05:46:59 2022: VRRP default protocol version = 2
    101. Keepalived_vrrp[57]: VRRP default protocol version = 2
    102. Tue Aug 2 05:46:59 2022: VRRP check unicast_src = false
    103. Keepalived_vrrp[57]: VRRP check unicast_src = false
    104. Tue Aug 2 05:46:59 2022: VRRP skip check advert addresses = false
    105. Keepalived_vrrp[57]: VRRP skip check advert addresses = false
    106. Tue Aug 2 05:46:59 2022: VRRP strict mode = false
    107. Keepalived_vrrp[57]: VRRP strict mode = false
    108. Tue Aug 2 05:46:59 2022: VRRP process priority = 0
    109. Keepalived_vrrp[57]: VRRP process priority = 0
    110. Tue Aug 2 05:46:59 2022: VRRP don't swap = false
    111. Keepalived_vrrp[57]: VRRP don't swap = false
    112. Tue Aug 2 05:46:59 2022: VRRP realtime priority = 0
    113. Keepalived_vrrp[57]: VRRP realtime priority = 0
    114. Tue Aug 2 05:46:59 2022: Checker process priority = 0
    115. Keepalived_vrrp[57]: Checker process priority = 0
    116. Tue Aug 2 05:46:59 2022: Checker don't swap = false
    117. Keepalived_vrrp[57]: Checker don't swap = false
    118. Tue Aug 2 05:46:59 2022: Checker realtime priority = 0
    119. Keepalived_vrrp[57]: Checker realtime priority = 0
    120. Tue Aug 2 05:46:59 2022: Script security disabled
    121. Keepalived_vrrp[57]: Script security disabled
    122. Tue Aug 2 05:46:59 2022: Default script uid:gid 0:0
    123. Keepalived_vrrp[57]: Default script uid:gid 0:0
    124. Tue Aug 2 05:46:59 2022: vrrp_netlink_cmd_rcv_bufs = 0
    125. Keepalived_vrrp[57]: vrrp_netlink_cmd_rcv_bufs = 0
    126. Tue Aug 2 05:46:59 2022: vrrp_netlink_cmd_rcv_bufs_force = 0
    127. Keepalived_vrrp[57]: vrrp_netlink_cmd_rcv_bufs_force = 0
    128. Tue Aug 2 05:46:59 2022: vrrp_netlink_monitor_rcv_bufs = 0
    129. Keepalived_vrrp[57]: vrrp_netlink_monitor_rcv_bufs = 0
    130. Tue Aug 2 05:46:59 2022: vrrp_netlink_monitor_rcv_bufs_force = 0
    131. Keepalived_vrrp[57]: vrrp_netlink_monitor_rcv_bufs_force = 0
    132. Tue Aug 2 05:46:59 2022: process_monitor_rcv_bufs = 0
    133. Keepalived_vrrp[57]: process_monitor_rcv_bufs = 0
    134. Tue Aug 2 05:46:59 2022: process_monitor_rcv_bufs_force = 0
    135. Keepalived_vrrp[57]: process_monitor_rcv_bufs_force = 0
    136. Tue Aug 2 05:46:59 2022: lvs_netlink_cmd_rcv_bufs = 0
    137. Keepalived_vrrp[57]: lvs_netlink_cmd_rcv_bufs = 0
    138. Tue Aug 2 05:46:59 2022: lvs_netlink_cmd_rcv_bufs_force = 0
    139. Keepalived_vrrp[57]: lvs_netlink_cmd_rcv_bufs_force = 0
    140. Tue Aug 2 05:46:59 2022: lvs_netlink_monitor_rcv_bufs = 0
    141. Keepalived_vrrp[57]: lvs_netlink_monitor_rcv_bufs = 0
    142. Tue Aug 2 05:46:59 2022: lvs_netlink_monitor_rcv_bufs_force = 0
    143. Keepalived_vrrp[57]: lvs_netlink_monitor_rcv_bufs_force = 0
    144. Tue Aug 2 05:46:59 2022: rs_init_notifies = 0
    145. Keepalived_vrrp[57]: rs_init_notifies = 0
    146. Tue Aug 2 05:46:59 2022: no_checker_emails = 0
    147. Keepalived_vrrp[57]: no_checker_emails = 0
    148. Tue Aug 2 05:46:59 2022: rx_bufs_multiples = 3
    149. Keepalived_vrrp[57]: rx_bufs_multiples = 3
    150. Tue Aug 2 05:46:59 2022: umask = 0177
    151. Keepalived_vrrp[57]: umask = 0177
    152. Tue Aug 2 05:46:59 2022: ------< VRRP Topology >------
    153. Keepalived_vrrp[57]: ------< VRRP Topology >------
    154. Tue Aug 2 05:46:59 2022: VRRP Instance = VI_1
    155. Keepalived_vrrp[57]: VRRP Instance = VI_1
    156. Tue Aug 2 05:46:59 2022: VRRP Version = 2
    157. Keepalived_vrrp[57]: VRRP Version = 2
    158. Tue Aug 2 05:46:59 2022: Wantstate = BACKUP
    159. Keepalived_vrrp[57]: Wantstate = BACKUP
    160. Tue Aug 2 05:46:59 2022: Interface = eth0
    161. Keepalived_vrrp[57]: Interface = eth0
    162. Tue Aug 2 05:46:59 2022: Using src_ip = 172.18.0.22
    163. Keepalived_vrrp[57]: Using src_ip = 172.18.0.22
    164. Tue Aug 2 05:46:59 2022: Gratuitous ARP delay = 5
    165. Keepalived_vrrp[57]: Gratuitous ARP delay = 5
    166. Tue Aug 2 05:46:59 2022: Gratuitous ARP repeat = 5
    167. Keepalived_vrrp[57]: Gratuitous ARP repeat = 5
    168. Tue Aug 2 05:46:59 2022: Gratuitous ARP refresh = 0
    169. Keepalived_vrrp[57]: Gratuitous ARP refresh = 0
    170. Tue Aug 2 05:46:59 2022: Gratuitous ARP refresh repeat = 1
    171. Keepalived_vrrp[57]: Gratuitous ARP refresh repeat = 1
    172. Tue Aug 2 05:46:59 2022: Gratuitous ARP lower priority delay = 5
    173. Keepalived_vrrp[57]: Gratuitous ARP lower priority delay = 5
    174. Tue Aug 2 05:46:59 2022: Gratuitous ARP lower priority repeat = 5
    175. Keepalived_vrrp[57]: Gratuitous ARP lower priority repeat = 5
    176. Tue Aug 2 05:46:59 2022: Send advert after receive lower priority advert = true
    177. Keepalived_vrrp[57]: Send advert after receive lower priority advert = true
    178. Tue Aug 2 05:46:59 2022: Send advert after receive higher priority advert = false
    179. Keepalived_vrrp[57]: Send advert after receive higher priority advert = false
    180. Tue Aug 2 05:46:59 2022: Virtual Router ID = 51
    181. Keepalived_vrrp[57]: Virtual Router ID = 51
    182. Tue Aug 2 05:46:59 2022: Priority = 150
    183. Keepalived_vrrp[57]: Priority = 150
    184. Tue Aug 2 05:46:59 2022: Advert interval = 1 sec
    185. Keepalived_vrrp[57]: Advert interval = 1 sec
    186. Tue Aug 2 05:46:59 2022: Accept = enabled
    187. Keepalived_vrrp[57]: Accept = enabled
    188. Tue Aug 2 05:46:59 2022: Preempt = disabled
    189. Keepalived_vrrp[57]: Preempt = disabled
    190. Tue Aug 2 05:46:59 2022: Promote_secondaries = disabled
    191. Keepalived_vrrp[57]: Promote_secondaries = disabled
    192. Tue Aug 2 05:46:59 2022: Authentication type = SIMPLE_PASSWORD
    193. Keepalived_vrrp[57]: Authentication type = SIMPLE_PASSWORD
    194. Tue Aug 2 05:46:59 2022: Password = d0cker
    195. Keepalived_vrrp[57]: Password = d0cker
    196. Tue Aug 2 05:46:59 2022: Virtual IP = 2
    197. Keepalived_vrrp[57]: Virtual IP = 2
    198. Tue Aug 2 05:46:59 2022: 172.18.0.3 dev eth0 scope global
    199. Keepalived_vrrp[57]: 172.18.0.3 dev eth0 scope global
    200. Tue Aug 2 05:46:59 2022: 172.18.0.4 dev eth0 scope global
    201. Keepalived_vrrp[57]: 172.18.0.4 dev eth0 scope global
    202. Tue Aug 2 05:46:59 2022: Unicast Peer = 3
    203. Keepalived_vrrp[57]: Unicast Peer = 3
    204. Tue Aug 2 05:46:59 2022: 172.18.0.21
    205. Keepalived_vrrp[57]: 172.18.0.21
    206. Tue Aug 2 05:46:59 2022: 172.18.0.22
    207. Keepalived_vrrp[57]: 172.18.0.22
    208. Tue Aug 2 05:46:59 2022: 172.18.0.23
    209. Keepalived_vrrp[57]: 172.18.0.23
    210. Tue Aug 2 05:46:59 2022: Unicast checksum compatibility = no
    211. Keepalived_vrrp[57]: Unicast checksum compatibility = no
    212. Tue Aug 2 05:46:59 2022: No sockets allocated
    213. Keepalived_vrrp[57]: No sockets allocated
    214. Tue Aug 2 05:46:59 2022: Using smtp notification = no
    215. Keepalived_vrrp[57]: Using smtp notification = no
    216. Tue Aug 2 05:46:59 2022: Generic state transition script = '/container/service/keepalived/assets/notify.sh', uid:gid 0:0
    217. Keepalived_vrrp[57]: Generic state transition script = '/container/service/keepalived/assets/notify.sh', uid:gid 0:0
    218. Tue Aug 2 05:46:59 2022: Notify priority changes = false
    219. Keepalived_vrrp[57]: Notify priority changes = false
    220. Tue Aug 2 05:46:59 2022: ------< Interfaces >------
    221. Keepalived_vrrp[57]: ------< Interfaces >------
    222. Tue Aug 2 05:46:59 2022: Name = lo
    223. Keepalived_vrrp[57]: Name = lo
    224. Tue Aug 2 05:46:59 2022: index = 1
    225. Keepalived_vrrp[57]: index = 1
    226. Tue Aug 2 05:46:59 2022: IPv4 address = 127.0.0.1
    227. Keepalived_vrrp[57]: IPv4 address = 127.0.0.1
    228. Tue Aug 2 05:46:59 2022: IPv6 address = (none)
    229. Keepalived_vrrp[57]: IPv6 address = (none)
    230. Tue Aug 2 05:46:59 2022: State = UP, RUNNING, no broadcast, loopback, no multicast
    231. Keepalived_vrrp[57]: State = UP, RUNNING, no broadcast, loopback, no multicast
    232. Tue Aug 2 05:46:59 2022: MTU = 65536
    233. Keepalived_vrrp[57]: MTU = 65536
    234. Tue Aug 2 05:46:59 2022: HW Type = LOOPBACK
    235. Keepalived_vrrp[57]: HW Type = LOOPBACK
    236. Tue Aug 2 05:46:59 2022: NIC netlink status update
    237. Keepalived_vrrp[57]: NIC netlink status update
    238. Tue Aug 2 05:46:59 2022: Reset ARP config counter 0
    239. Keepalived_vrrp[57]: Reset ARP config counter 0
    240. Tue Aug 2 05:46:59 2022: Original arp_ignore 0
    241. Keepalived_vrrp[57]: Original arp_ignore 0
    242. Tue Aug 2 05:46:59 2022: Original arp_filter 0
    243. Keepalived_vrrp[57]: Original arp_filter 0
    244. Tue Aug 2 05:46:59 2022: Original promote_secondaries 0
    245. Keepalived_vrrp[57]: Original promote_secondaries 0
    246. Tue Aug 2 05:46:59 2022: Reset promote_secondaries counter 0
    247. Keepalived_vrrp[57]: Reset promote_secondaries counter 0
    248. Tue Aug 2 05:46:59 2022: Tracking VRRP instances = 0
    249. Keepalived_vrrp[57]: Tracking VRRP instances = 0
    250. Tue Aug 2 05:46:59 2022: Name = tunl0
    251. Keepalived_vrrp[57]: Name = tunl0
    252. Tue Aug 2 05:46:59 2022: index = 2
    253. Keepalived_vrrp[57]: index = 2
    254. Tue Aug 2 05:46:59 2022: IPv4 address = (none)
    255. Keepalived_vrrp[57]: IPv4 address = (none)
    256. Tue Aug 2 05:46:59 2022: IPv6 address = (none)
    257. Keepalived_vrrp[57]: IPv6 address = (none)
    258. Tue Aug 2 05:46:59 2022: State = not UP, not RUNNING, no broadcast, no arp, no multicast
    259. Keepalived_vrrp[57]: State = not UP, not RUNNING, no broadcast, no arp, no multicast
    260. Tue Aug 2 05:46:59 2022: MTU = 1480
    261. Keepalived_vrrp[57]: MTU = 1480
    262. Tue Aug 2 05:46:59 2022: HW Type = UNKNOWN (768)
    263. Keepalived_vrrp[57]: HW Type = UNKNOWN (768)
    264. Tue Aug 2 05:46:59 2022: NIC netlink status update
    265. Keepalived_vrrp[57]: NIC netlink status update
    266. Tue Aug 2 05:46:59 2022: Reset ARP config counter 0
    267. Keepalived_vrrp[57]: Reset ARP config counter 0
    268. Tue Aug 2 05:46:59 2022: Original arp_ignore 0
    269. Keepalived_vrrp[57]: Original arp_ignore 0
    270. Tue Aug 2 05:46:59 2022: Original arp_filter 0
    271. Keepalived_vrrp[57]: Original arp_filter 0
    272. Tue Aug 2 05:46:59 2022: Original promote_secondaries 0
    273. Keepalived_vrrp[57]: Original promote_secondaries 0
    274. Tue Aug 2 05:46:59 2022: Reset promote_secondaries counter 0
    275. Keepalived_vrrp[57]: Reset promote_secondaries counter 0
    276. Tue Aug 2 05:46:59 2022: Tracking VRRP instances = 0
    277. Keepalived_vrrp[57]: Tracking VRRP instances = 0
    278. Tue Aug 2 05:46:59 2022: Name = ip6tnl0
    279. Keepalived_vrrp[57]: Name = ip6tnl0
    280. Tue Aug 2 05:46:59 2022: index = 3
    281. Keepalived_vrrp[57]: index = 3
    282. Tue Aug 2 05:46:59 2022: IPv4 address = (none)
    283. Keepalived_vrrp[57]: IPv4 address = (none)
    284. Tue Aug 2 05:46:59 2022: IPv6 address = (none)
    285. Keepalived_vrrp[57]: IPv6 address = (none)
    286. Tue Aug 2 05:46:59 2022: State = not UP, not RUNNING, no broadcast, no arp, no multicast
    287. Keepalived_vrrp[57]: State = not UP, not RUNNING, no broadcast, no arp, no multicast
    288. Tue Aug 2 05:46:59 2022: MTU = 1452
    289. Keepalived_vrrp[57]: MTU = 1452
    290. Tue Aug 2 05:46:59 2022: HW Type = UNKNOWN (769)
    291. Keepalived_vrrp[57]: HW Type = UNKNOWN (769)
    292. Tue Aug 2 05:46:59 2022: NIC netlink status update
    293. Keepalived_vrrp[57]: NIC netlink status update
    294. Tue Aug 2 05:46:59 2022: Reset ARP config counter 0
    295. Keepalived_vrrp[57]: Reset ARP config counter 0
    296. Tue Aug 2 05:46:59 2022: Original arp_ignore 0
    297. Keepalived_vrrp[57]: Original arp_ignore 0
    298. Tue Aug 2 05:46:59 2022: Original arp_filter 0
    299. Keepalived_vrrp[57]: Original arp_filter 0
    300. Tue Aug 2 05:46:59 2022: Original promote_secondaries 0
    301. Keepalived_vrrp[57]: Original promote_secondaries 0
    302. Tue Aug 2 05:46:59 2022: Reset promote_secondaries counter 0
    303. Keepalived_vrrp[57]: Reset promote_secondaries counter 0
    304. Tue Aug 2 05:46:59 2022: Tracking VRRP instances = 0
    305. Keepalived_vrrp[57]: Tracking VRRP instances = 0
    306. Tue Aug 2 05:46:59 2022: Name = eth0
    307. Keepalived_vrrp[57]: Name = eth0
    308. Tue Aug 2 05:46:59 2022: index = 21
    309. Keepalived_vrrp[57]: index = 21
    310. Tue Aug 2 05:46:59 2022: IPv4 address = 172.18.0.22
    311. Keepalived_vrrp[57]: IPv4 address = 172.18.0.22
    312. Tue Aug 2 05:46:59 2022: IPv6 address = (none)
    313. Keepalived_vrrp[57]: IPv6 address = (none)
    314. Tue Aug 2 05:46:59 2022: MAC = 02:42:ac:12:00:16
    315. Keepalived_vrrp[57]: MAC = 02:42:ac:12:00:16
    316. Tue Aug 2 05:46:59 2022: MAC broadcast = ff:ff:ff:ff:ff:ff
    317. Keepalived_vrrp[57]: MAC broadcast = ff:ff:ff:ff:ff:ff
    318. Tue Aug 2 05:46:59 2022: State = UP, RUNNING
    319. Keepalived_vrrp[57]: State = UP, RUNNING
    320. Tue Aug 2 05:46:59 2022: MTU = 1500
    321. Keepalived_vrrp[57]: MTU = 1500
    322. Tue Aug 2 05:46:59 2022: HW Type = ETHERNET
    323. Keepalived_vrrp[57]: HW Type = ETHERNET
    324. Tue Aug 2 05:46:59 2022: NIC netlink status update
    325. Keepalived_vrrp[57]: NIC netlink status update
    326. Tue Aug 2 05:46:59 2022: Reset ARP config counter 0
    327. Keepalived_vrrp[57]: Reset ARP config counter 0
    328. Tue Aug 2 05:46:59 2022: Original arp_ignore 0
    329. Keepalived_vrrp[57]: Original arp_ignore 0
    330. Tue Aug 2 05:46:59 2022: Original arp_filter 0
    331. Keepalived_vrrp[57]: Original arp_filter 0
    332. Tue Aug 2 05:46:59 2022: Original promote_secondaries 0
    333. Keepalived_vrrp[57]: Original promote_secondaries 0
    334. Tue Aug 2 05:46:59 2022: Reset promote_secondaries counter 0
    335. Keepalived_vrrp[57]: Reset promote_secondaries counter 0
    336. Tue Aug 2 05:46:59 2022: Tracking VRRP instances = 1
    337. Keepalived_vrrp[57]: Tracking VRRP instances = 1
    338. Tue Aug 2 05:46:59 2022: VI_1, weight 0
    339. Keepalived_vrrp[57]: VI_1, weight 0
    340. Tue Aug 2 05:46:59 2022: (VI_1) Entering BACKUP STATE (init)
    341. Keepalived_vrrp[57]: (VI_1) Entering BACKUP STATE (init)
    342. Tue Aug 2 05:46:59 2022: VRRP sockpool: [ifindex(21), family(IPv4), proto(112), unicast(1), fd(11,12)]
    343. Keepalived_vrrp[57]: VRRP sockpool: [ifindex(21), family(IPv4), proto(112), unicast(1), fd(11,12)]
    344. # 当前节点为backup节点
    345. Ok, i'm just a backup, great.

              

    查看容器日志:keepalived3

    1. huli@hudeMacBook-Pro ~ % docker logs keepalived3
    2. *** CONTAINER_LOG_LEVEL = 3 (info)
    3. *** Search service in CONTAINER_SERVICE_DIR = /container/service :
    4. *** link /container/service/keepalived/startup.sh to /container/run/startup/keepalived
    5. *** link /container/service/keepalived/process.sh to /container/run/process/keepalived/run
    6. *** link /container/service/keepalived/finish.sh to /container/run/process/keepalived/finish
    7. *** Set environment for startup files
    8. *** Environment files will be proccessed in this order :
    9. Caution: previously defined variables will not be overriden.
    10. /container/environment/99-default/default.yaml
    11. To see how this files are processed and environment variables values,
    12. run this container with '--loglevel debug'
    13. /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.
    14. env_vars = yaml.load(f)
    15. *** Running /container/run/startup/keepalived...
    16. *** Set environment for container process
    17. *** Environment files will be proccessed in this order :
    18. Caution: previously defined variables will not be overriden.
    19. /container/environment/99-default/default.yaml
    20. To see how this files are processed and environment variables values,
    21. run this container with '--loglevel debug'
    22. *** Running /container/run/process/keepalived/run...
    23. Waiting config file /usr/local/etc/keepalived/keepalived.confok
    24. Tue Aug 2 05:49:08 2022: Starting Keepalived v2.0.20 (01/22,2020)
    25. Keepalived[55]: Starting Keepalived v2.0.20 (01/22,2020)
    26. 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)
    27. 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)
    28. Tue Aug 2 05:49:08 2022: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
    29. Keepalived[55]: Command line: '/usr/local/sbin/keepalived' '-f' '/usr/local/etc/keepalived/keepalived.conf'
    30. Tue Aug 2 05:49:08 2022: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
    31. Keepalived[55]: '--dont-fork' '--log-console' '--log-detail' '--dump-conf'
    32. Tue Aug 2 05:49:08 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    33. Keepalived[55]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    34. Tue Aug 2 05:49:08 2022: Starting VRRP child process, pid=57
    35. Tue Aug 2 05:49:08 2022: Registering Kernel netlink reflector
    36. Keepalived_vrrp[57]: Registering Kernel netlink reflector
    37. Tue Aug 2 05:49:08 2022: Registering Kernel netlink command channel
    38. Keepalived[55]: Starting VRRP child process, pid=57
    39. Keepalived_vrrp[57]: Registering Kernel netlink command channel
    40. Tue Aug 2 05:49:08 2022: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    41. Keepalived_vrrp[57]: Opening file '/usr/local/etc/keepalived/keepalived.conf'.
    42. Tue Aug 2 05:49:08 2022: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
    43. Keepalived_vrrp[57]: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
    44. Tue Aug 2 05:49:08 2022: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
    45. Keepalived_vrrp[57]: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
    46. Tue Aug 2 05:49:08 2022: Assigned address 172.18.0.23 for interface eth0
    47. Keepalived_vrrp[57]: Assigned address 172.18.0.23 for interface eth0
    48. Tue Aug 2 05:49:08 2022: Registering gratuitous ARP shared channel
    49. Keepalived_vrrp[57]: Registering gratuitous ARP shared channel
    50. Tue Aug 2 05:49:08 2022: (VI_1) removing VIPs.
    51. Keepalived_vrrp[57]: (VI_1) removing VIPs.
    52. Tue Aug 2 05:49:08 2022: ------< Global definitions >------
    53. Keepalived_vrrp[57]: ------< Global definitions >------
    54. Tue Aug 2 05:49:08 2022: Network namespace = (default)
    55. Keepalived_vrrp[57]: Network namespace = (default)
    56. Tue Aug 2 05:49:08 2022: Router ID = 8f41ec8e1808
    57. Keepalived_vrrp[57]: Router ID = 8f41ec8e1808
    58. Tue Aug 2 05:49:08 2022: Default smtp_alert = unset
    59. Keepalived_vrrp[57]: Default smtp_alert = unset
    60. Tue Aug 2 05:49:08 2022: Default smtp_alert_vrrp = unset
    61. Keepalived_vrrp[57]: Default smtp_alert_vrrp = unset
    62. Tue Aug 2 05:49:08 2022: Default smtp_alert_checker = unset
    63. Keepalived_vrrp[57]: Default smtp_alert_checker = unset
    64. Tue Aug 2 05:49:08 2022: Checkers log all failures = false
    65. Keepalived_vrrp[57]: Checkers log all failures = false
    66. Tue Aug 2 05:49:08 2022: Dynamic interfaces = false
    67. Keepalived_vrrp[57]: Dynamic interfaces = false
    68. Tue Aug 2 05:49:08 2022: Default interface = eth0
    69. Keepalived_vrrp[57]: Default interface = eth0
    70. Tue Aug 2 05:49:08 2022: LVS flush = false
    71. Keepalived_vrrp[57]: LVS flush = false
    72. Tue Aug 2 05:49:08 2022: LVS flush on stop = disabled
    73. Keepalived_vrrp[57]: LVS flush on stop = disabled
    74. Tue Aug 2 05:49:08 2022: VRRP notify priority changes = false
    75. Keepalived_vrrp[57]: VRRP notify priority changes = false
    76. Tue Aug 2 05:49:08 2022: VRRP IPv4 mcast group = 224.0.0.18
    77. Keepalived_vrrp[57]: VRRP IPv4 mcast group = 224.0.0.18
    78. Tue Aug 2 05:49:08 2022: VRRP IPv6 mcast group = ff02::12
    79. Keepalived_vrrp[57]: VRRP IPv6 mcast group = ff02::12
    80. Tue Aug 2 05:49:08 2022: Gratuitous ARP delay = 5
    81. Keepalived_vrrp[57]: Gratuitous ARP delay = 5
    82. Tue Aug 2 05:49:08 2022: Gratuitous ARP repeat = 5
    83. Keepalived_vrrp[57]: Gratuitous ARP repeat = 5
    84. Tue Aug 2 05:49:08 2022: Gratuitous ARP refresh timer = 0
    85. Keepalived_vrrp[57]: Gratuitous ARP refresh timer = 0
    86. Tue Aug 2 05:49:08 2022: Gratuitous ARP refresh repeat = 1
    87. Keepalived_vrrp[57]: Gratuitous ARP refresh repeat = 1
    88. Tue Aug 2 05:49:08 2022: Gratuitous ARP lower priority delay = 5
    89. Keepalived_vrrp[57]: Gratuitous ARP lower priority delay = 5
    90. Tue Aug 2 05:49:08 2022: Gratuitous ARP lower priority repeat = 5
    91. Keepalived_vrrp[57]: Gratuitous ARP lower priority repeat = 5
    92. Tue Aug 2 05:49:08 2022: Send advert after receive lower priority advert = true
    93. Keepalived_vrrp[57]: Send advert after receive lower priority advert = true
    94. Tue Aug 2 05:49:08 2022: Send advert after receive higher priority advert = false
    95. Keepalived_vrrp[57]: Send advert after receive higher priority advert = false
    96. Tue Aug 2 05:49:08 2022: Gratuitous ARP interval = 0.000000
    97. Keepalived_vrrp[57]: Gratuitous ARP interval = 0.000000
    98. Tue Aug 2 05:49:08 2022: Gratuitous NA interval = 0.000000
    99. Keepalived_vrrp[57]: Gratuitous NA interval = 0.000000
    100. Tue Aug 2 05:49:08 2022: VRRP default protocol version = 2
    101. Keepalived_vrrp[57]: VRRP default protocol version = 2
    102. Tue Aug 2 05:49:08 2022: VRRP check unicast_src = false
    103. Keepalived_vrrp[57]: VRRP check unicast_src = false
    104. Tue Aug 2 05:49:08 2022: VRRP skip check advert addresses = false
    105. Keepalived_vrrp[57]: VRRP skip check advert addresses = false
    106. Tue Aug 2 05:49:08 2022: VRRP strict mode = false
    107. Keepalived_vrrp[57]: VRRP strict mode = false
    108. Tue Aug 2 05:49:08 2022: VRRP process priority = 0
    109. Keepalived_vrrp[57]: VRRP process priority = 0
    110. Tue Aug 2 05:49:08 2022: VRRP don't swap = false
    111. Keepalived_vrrp[57]: VRRP don't swap = false
    112. Tue Aug 2 05:49:08 2022: VRRP realtime priority = 0
    113. Keepalived_vrrp[57]: VRRP realtime priority = 0
    114. Tue Aug 2 05:49:08 2022: Checker process priority = 0
    115. Keepalived_vrrp[57]: Checker process priority = 0
    116. Tue Aug 2 05:49:08 2022: Checker don't swap = false
    117. Keepalived_vrrp[57]: Checker don't swap = false
    118. Tue Aug 2 05:49:08 2022: Checker realtime priority = 0
    119. Keepalived_vrrp[57]: Checker realtime priority = 0
    120. Tue Aug 2 05:49:08 2022: Script security disabled
    121. Keepalived_vrrp[57]: Script security disabled
    122. Tue Aug 2 05:49:08 2022: Default script uid:gid 0:0
    123. Keepalived_vrrp[57]: Default script uid:gid 0:0
    124. Tue Aug 2 05:49:08 2022: vrrp_netlink_cmd_rcv_bufs = 0
    125. Keepalived_vrrp[57]: vrrp_netlink_cmd_rcv_bufs = 0
    126. Tue Aug 2 05:49:08 2022: vrrp_netlink_cmd_rcv_bufs_force = 0
    127. Keepalived_vrrp[57]: vrrp_netlink_cmd_rcv_bufs_force = 0
    128. Tue Aug 2 05:49:08 2022: vrrp_netlink_monitor_rcv_bufs = 0
    129. Keepalived_vrrp[57]: vrrp_netlink_monitor_rcv_bufs = 0
    130. Tue Aug 2 05:49:08 2022: vrrp_netlink_monitor_rcv_bufs_force = 0
    131. Keepalived_vrrp[57]: vrrp_netlink_monitor_rcv_bufs_force = 0
    132. Tue Aug 2 05:49:08 2022: process_monitor_rcv_bufs = 0
    133. Keepalived_vrrp[57]: process_monitor_rcv_bufs = 0
    134. Tue Aug 2 05:49:08 2022: process_monitor_rcv_bufs_force = 0
    135. Keepalived_vrrp[57]: process_monitor_rcv_bufs_force = 0
    136. Tue Aug 2 05:49:08 2022: lvs_netlink_cmd_rcv_bufs = 0
    137. Keepalived_vrrp[57]: lvs_netlink_cmd_rcv_bufs = 0
    138. Tue Aug 2 05:49:08 2022: lvs_netlink_cmd_rcv_bufs_force = 0
    139. Keepalived_vrrp[57]: lvs_netlink_cmd_rcv_bufs_force = 0
    140. Tue Aug 2 05:49:08 2022: lvs_netlink_monitor_rcv_bufs = 0
    141. Keepalived_vrrp[57]: lvs_netlink_monitor_rcv_bufs = 0
    142. Tue Aug 2 05:49:08 2022: lvs_netlink_monitor_rcv_bufs_force = 0
    143. Keepalived_vrrp[57]: lvs_netlink_monitor_rcv_bufs_force = 0
    144. Tue Aug 2 05:49:08 2022: rs_init_notifies = 0
    145. Keepalived_vrrp[57]: rs_init_notifies = 0
    146. Tue Aug 2 05:49:08 2022: no_checker_emails = 0
    147. Keepalived_vrrp[57]: no_checker_emails = 0
    148. Tue Aug 2 05:49:08 2022: rx_bufs_multiples = 3
    149. Keepalived_vrrp[57]: rx_bufs_multiples = 3
    150. Tue Aug 2 05:49:08 2022: umask = 0177
    151. Keepalived_vrrp[57]: umask = 0177
    152. Tue Aug 2 05:49:08 2022: ------< VRRP Topology >------
    153. Keepalived_vrrp[57]: ------< VRRP Topology >------
    154. Tue Aug 2 05:49:08 2022: VRRP Instance = VI_1
    155. Keepalived_vrrp[57]: VRRP Instance = VI_1
    156. Tue Aug 2 05:49:08 2022: VRRP Version = 2
    157. Keepalived_vrrp[57]: VRRP Version = 2
    158. Tue Aug 2 05:49:08 2022: Wantstate = BACKUP
    159. Keepalived_vrrp[57]: Wantstate = BACKUP
    160. Tue Aug 2 05:49:08 2022: Interface = eth0
    161. Keepalived_vrrp[57]: Interface = eth0
    162. Tue Aug 2 05:49:08 2022: Using src_ip = 172.18.0.23
    163. Keepalived_vrrp[57]: Using src_ip = 172.18.0.23
    164. Tue Aug 2 05:49:08 2022: Gratuitous ARP delay = 5
    165. Keepalived_vrrp[57]: Gratuitous ARP delay = 5
    166. Tue Aug 2 05:49:08 2022: Gratuitous ARP repeat = 5
    167. Keepalived_vrrp[57]: Gratuitous ARP repeat = 5
    168. Tue Aug 2 05:49:08 2022: Gratuitous ARP refresh = 0
    169. Keepalived_vrrp[57]: Gratuitous ARP refresh = 0
    170. Tue Aug 2 05:49:08 2022: Gratuitous ARP refresh repeat = 1
    171. Keepalived_vrrp[57]: Gratuitous ARP refresh repeat = 1
    172. Tue Aug 2 05:49:08 2022: Gratuitous ARP lower priority delay = 5
    173. Keepalived_vrrp[57]: Gratuitous ARP lower priority delay = 5
    174. Tue Aug 2 05:49:08 2022: Gratuitous ARP lower priority repeat = 5
    175. Keepalived_vrrp[57]: Gratuitous ARP lower priority repeat = 5
    176. Tue Aug 2 05:49:08 2022: Send advert after receive lower priority advert = true
    177. Keepalived_vrrp[57]: Send advert after receive lower priority advert = true
    178. Tue Aug 2 05:49:08 2022: Send advert after receive higher priority advert = false
    179. Keepalived_vrrp[57]: Send advert after receive higher priority advert = false
    180. Tue Aug 2 05:49:08 2022: Virtual Router ID = 51
    181. Keepalived_vrrp[57]: Virtual Router ID = 51
    182. Tue Aug 2 05:49:08 2022: Priority = 150
    183. Keepalived_vrrp[57]: Priority = 150
    184. Tue Aug 2 05:49:08 2022: Advert interval = 1 sec
    185. Keepalived_vrrp[57]: Advert interval = 1 sec
    186. Tue Aug 2 05:49:08 2022: Accept = enabled
    187. Keepalived_vrrp[57]: Accept = enabled
    188. Tue Aug 2 05:49:08 2022: Preempt = disabled
    189. Keepalived_vrrp[57]: Preempt = disabled
    190. Tue Aug 2 05:49:08 2022: Promote_secondaries = disabled
    191. Keepalived_vrrp[57]: Promote_secondaries = disabled
    192. Tue Aug 2 05:49:08 2022: Authentication type = SIMPLE_PASSWORD
    193. Keepalived_vrrp[57]: Authentication type = SIMPLE_PASSWORD
    194. Tue Aug 2 05:49:08 2022: Password = d0cker
    195. Keepalived_vrrp[57]: Password = d0cker
    196. Tue Aug 2 05:49:08 2022: Virtual IP = 2
    197. Keepalived_vrrp[57]: Virtual IP = 2
    198. Tue Aug 2 05:49:08 2022: 172.18.0.3 dev eth0 scope global
    199. Keepalived_vrrp[57]: 172.18.0.3 dev eth0 scope global
    200. Tue Aug 2 05:49:08 2022: 172.18.0.4 dev eth0 scope global
    201. Keepalived_vrrp[57]: 172.18.0.4 dev eth0 scope global
    202. Tue Aug 2 05:49:08 2022: Unicast Peer = 3
    203. Keepalived_vrrp[57]: Unicast Peer = 3
    204. Tue Aug 2 05:49:08 2022: 172.18.0.21
    205. Keepalived_vrrp[57]: 172.18.0.21
    206. Tue Aug 2 05:49:08 2022: 172.18.0.22
    207. Keepalived_vrrp[57]: 172.18.0.22
    208. Tue Aug 2 05:49:08 2022: 172.18.0.23
    209. Keepalived_vrrp[57]: 172.18.0.23
    210. Tue Aug 2 05:49:08 2022: Unicast checksum compatibility = no
    211. Keepalived_vrrp[57]: Unicast checksum compatibility = no
    212. Tue Aug 2 05:49:08 2022: No sockets allocated
    213. Keepalived_vrrp[57]: No sockets allocated
    214. Tue Aug 2 05:49:08 2022: Using smtp notification = no
    215. Keepalived_vrrp[57]: Using smtp notification = no
    216. Tue Aug 2 05:49:08 2022: Generic state transition script = '/container/service/keepalived/assets/notify.sh', uid:gid 0:0
    217. Keepalived_vrrp[57]: Generic state transition script = '/container/service/keepalived/assets/notify.sh', uid:gid 0:0
    218. Tue Aug 2 05:49:08 2022: Notify priority changes = false
    219. Keepalived_vrrp[57]: Notify priority changes = false
    220. Tue Aug 2 05:49:08 2022: ------< Interfaces >------
    221. Keepalived_vrrp[57]: ------< Interfaces >------
    222. Tue Aug 2 05:49:08 2022: Name = lo
    223. Keepalived_vrrp[57]: Name = lo
    224. Tue Aug 2 05:49:08 2022: index = 1
    225. Keepalived_vrrp[57]: index = 1
    226. Tue Aug 2 05:49:08 2022: IPv4 address = 127.0.0.1
    227. Keepalived_vrrp[57]: IPv4 address = 127.0.0.1
    228. Tue Aug 2 05:49:08 2022: IPv6 address = (none)
    229. Keepalived_vrrp[57]: IPv6 address = (none)
    230. Tue Aug 2 05:49:08 2022: State = UP, RUNNING, no broadcast, loopback, no multicast
    231. Keepalived_vrrp[57]: State = UP, RUNNING, no broadcast, loopback, no multicast
    232. Tue Aug 2 05:49:08 2022: MTU = 65536
    233. Keepalived_vrrp[57]: MTU = 65536
    234. Tue Aug 2 05:49:08 2022: HW Type = LOOPBACK
    235. Keepalived_vrrp[57]: HW Type = LOOPBACK
    236. Tue Aug 2 05:49:08 2022: NIC netlink status update
    237. Keepalived_vrrp[57]: NIC netlink status update
    238. Tue Aug 2 05:49:08 2022: Reset ARP config counter 0
    239. Keepalived_vrrp[57]: Reset ARP config counter 0
    240. Tue Aug 2 05:49:08 2022: Original arp_ignore 0
    241. Keepalived_vrrp[57]: Original arp_ignore 0
    242. Tue Aug 2 05:49:08 2022: Original arp_filter 0
    243. Keepalived_vrrp[57]: Original arp_filter 0
    244. Tue Aug 2 05:49:08 2022: Original promote_secondaries 0
    245. Keepalived_vrrp[57]: Original promote_secondaries 0
    246. Tue Aug 2 05:49:08 2022: Reset promote_secondaries counter 0
    247. Keepalived_vrrp[57]: Reset promote_secondaries counter 0
    248. Tue Aug 2 05:49:08 2022: Tracking VRRP instances = 0
    249. Keepalived_vrrp[57]: Tracking VRRP instances = 0
    250. Tue Aug 2 05:49:08 2022: Name = tunl0
    251. Keepalived_vrrp[57]: Name = tunl0
    252. Tue Aug 2 05:49:08 2022: index = 2
    253. Keepalived_vrrp[57]: index = 2
    254. Tue Aug 2 05:49:08 2022: IPv4 address = (none)
    255. Keepalived_vrrp[57]: IPv4 address = (none)
    256. Tue Aug 2 05:49:08 2022: IPv6 address = (none)
    257. Keepalived_vrrp[57]: IPv6 address = (none)
    258. Tue Aug 2 05:49:08 2022: State = not UP, not RUNNING, no broadcast, no arp, no multicast
    259. Keepalived_vrrp[57]: State = not UP, not RUNNING, no broadcast, no arp, no multicast
    260. Tue Aug 2 05:49:08 2022: MTU = 1480
    261. Keepalived_vrrp[57]: MTU = 1480
    262. Tue Aug 2 05:49:08 2022: HW Type = UNKNOWN (768)
    263. Keepalived_vrrp[57]: HW Type = UNKNOWN (768)
    264. Tue Aug 2 05:49:08 2022: NIC netlink status update
    265. Keepalived_vrrp[57]: NIC netlink status update
    266. Tue Aug 2 05:49:08 2022: Reset ARP config counter 0
    267. Keepalived_vrrp[57]: Reset ARP config counter 0
    268. Tue Aug 2 05:49:08 2022: Original arp_ignore 0
    269. Keepalived_vrrp[57]: Original arp_ignore 0
    270. Tue Aug 2 05:49:08 2022: Original arp_filter 0
    271. Keepalived_vrrp[57]: Original arp_filter 0
    272. Tue Aug 2 05:49:08 2022: Original promote_secondaries 0
    273. Keepalived_vrrp[57]: Original promote_secondaries 0
    274. Tue Aug 2 05:49:08 2022: Reset promote_secondaries counter 0
    275. Keepalived_vrrp[57]: Reset promote_secondaries counter 0
    276. Tue Aug 2 05:49:08 2022: Tracking VRRP instances = 0
    277. Keepalived_vrrp[57]: Tracking VRRP instances = 0
    278. Tue Aug 2 05:49:08 2022: Name = ip6tnl0
    279. Keepalived_vrrp[57]: Name = ip6tnl0
    280. Tue Aug 2 05:49:08 2022: index = 3
    281. Keepalived_vrrp[57]: index = 3
    282. Tue Aug 2 05:49:08 2022: IPv4 address = (none)
    283. Keepalived_vrrp[57]: IPv4 address = (none)
    284. Tue Aug 2 05:49:08 2022: IPv6 address = (none)
    285. Keepalived_vrrp[57]: IPv6 address = (none)
    286. Tue Aug 2 05:49:08 2022: State = not UP, not RUNNING, no broadcast, no arp, no multicast
    287. Keepalived_vrrp[57]: State = not UP, not RUNNING, no broadcast, no arp, no multicast
    288. Tue Aug 2 05:49:08 2022: MTU = 1452
    289. Keepalived_vrrp[57]: MTU = 1452
    290. Tue Aug 2 05:49:08 2022: HW Type = UNKNOWN (769)
    291. Keepalived_vrrp[57]: HW Type = UNKNOWN (769)
    292. Tue Aug 2 05:49:08 2022: NIC netlink status update
    293. Keepalived_vrrp[57]: NIC netlink status update
    294. Tue Aug 2 05:49:08 2022: Reset ARP config counter 0
    295. Keepalived_vrrp[57]: Reset ARP config counter 0
    296. Tue Aug 2 05:49:08 2022: Original arp_ignore 0
    297. Keepalived_vrrp[57]: Original arp_ignore 0
    298. Tue Aug 2 05:49:08 2022: Original arp_filter 0
    299. Keepalived_vrrp[57]: Original arp_filter 0
    300. Tue Aug 2 05:49:08 2022: Original promote_secondaries 0
    301. Keepalived_vrrp[57]: Original promote_secondaries 0
    302. Tue Aug 2 05:49:08 2022: Reset promote_secondaries counter 0
    303. Keepalived_vrrp[57]: Reset promote_secondaries counter 0
    304. Tue Aug 2 05:49:08 2022: Tracking VRRP instances = 0
    305. Keepalived_vrrp[57]: Tracking VRRP instances = 0
    306. Tue Aug 2 05:49:08 2022: Name = eth0
    307. Keepalived_vrrp[57]: Name = eth0
    308. Tue Aug 2 05:49:08 2022: index = 23
    309. Keepalived_vrrp[57]: index = 23
    310. Tue Aug 2 05:49:08 2022: IPv4 address = 172.18.0.23
    311. Keepalived_vrrp[57]: IPv4 address = 172.18.0.23
    312. Tue Aug 2 05:49:08 2022: IPv6 address = (none)
    313. Keepalived_vrrp[57]: IPv6 address = (none)
    314. Tue Aug 2 05:49:08 2022: MAC = 02:42:ac:12:00:17
    315. Keepalived_vrrp[57]: MAC = 02:42:ac:12:00:17
    316. Tue Aug 2 05:49:08 2022: MAC broadcast = ff:ff:ff:ff:ff:ff
    317. Keepalived_vrrp[57]: MAC broadcast = ff:ff:ff:ff:ff:ff
    318. Tue Aug 2 05:49:08 2022: State = UP, RUNNING
    319. Keepalived_vrrp[57]: State = UP, RUNNING
    320. Tue Aug 2 05:49:08 2022: MTU = 1500
    321. Keepalived_vrrp[57]: MTU = 1500
    322. Tue Aug 2 05:49:08 2022: HW Type = ETHERNET
    323. Keepalived_vrrp[57]: HW Type = ETHERNET
    324. Tue Aug 2 05:49:08 2022: NIC netlink status update
    325. Keepalived_vrrp[57]: NIC netlink status update
    326. Tue Aug 2 05:49:08 2022: Reset ARP config counter 0
    327. Keepalived_vrrp[57]: Reset ARP config counter 0
    328. Tue Aug 2 05:49:08 2022: Original arp_ignore 0
    329. Keepalived_vrrp[57]: Original arp_ignore 0
    330. Tue Aug 2 05:49:08 2022: Original arp_filter 0
    331. Keepalived_vrrp[57]: Original arp_filter 0
    332. Tue Aug 2 05:49:08 2022: Original promote_secondaries 0
    333. Keepalived_vrrp[57]: Original promote_secondaries 0
    334. Tue Aug 2 05:49:08 2022: Reset promote_secondaries counter 0
    335. Keepalived_vrrp[57]: Reset promote_secondaries counter 0
    336. Tue Aug 2 05:49:08 2022: Tracking VRRP instances = 1
    337. Keepalived_vrrp[57]: Tracking VRRP instances = 1
    338. Tue Aug 2 05:49:08 2022: VI_1, weight 0
    339. Keepalived_vrrp[57]: VI_1, weight 0
    340. Tue Aug 2 05:49:08 2022: (VI_1) Entering BACKUP STATE (init)
    341. Keepalived_vrrp[57]: (VI_1) Entering BACKUP STATE (init)
    342. Tue Aug 2 05:49:08 2022: VRRP sockpool: [ifindex(23), family(IPv4), proto(112), unicast(1), fd(11,12)]
    343. Keepalived_vrrp[57]: VRRP sockpool: [ifindex(23), family(IPv4), proto(112), unicast(1), fd(11,12)]
    344. # 当前节点为backup节点
    345. Ok, i'm just a backup, great.

                            

                                   

                                        

    openresty keepalived

            

    *************

    创建镜像

             

    下载安装包:https://www.keepalived.org/download.html

    1. huli@hudeMacBook-Pro source % pwd
    2. /Users/huli/lua/openresty/keep/source
    3. huli@hudeMacBook-Pro source % ls
    4. keepalived-2.2.7.tar.gz

              

    镜像包含keepalived

    1. # 创建基础容器
    2. docker run -it -d --net fixed --ip 172.18.0.81 -p 9001:80 --privileged \
    3. -v /Users/huli/lua/openresty/keep/source:/source \
    4. --name open-keepalived lihu12344/openresty init
    5. # 进入容器
    6. docker exec -it open-keepalived bash
    7. # 依次执行以下命令
    8. yum -y install openssl-devel gcc gcc-c++ libnl libnl-devel libstdc++.i686 initscripts
    9. yum -y install rsyslog
    10. systemctl start rsyslog
    11. mkdir -p /var/run/openresty/
    12. touch /var/run/openresty/nginx-client-body
    13. mkdir -p /tmp/keepalived
    14. cp /source/* /tmp/keepalived
    15. cd /tmp/keepalived
    16. tar -zxvf keepalived-2.2.7.tar.gz
    17. mv keepalived-2.2.7 /usr/local/keepalived
    18. cd /usr/local/keepalived
    19. ./configure --prefix=/usr/local/keepalived
    20. make && make install
    21. cp etc/sysconfig/keepalived /etc/sysconfig/keepalived
    22. cp sbin/keepalived /usr/sbin/keepalived
    23. cp keepalived/etc/init.d/keepalived /etc/rc.d/init.d/keepalived
    24. mkdir -p /etc/keepalived
    25. * keepalived配置文件
    26. vi /etc/keepalived/keepalived.conf
    27. * 添加并开启keepalived服务,设置为开机自启
    28. chkconfig --add keepalived
    29. chkconfig keepalived on
    30. systemctl start keepalived
    31. # 退出容器后,创建镜像文件
    32. docker commit open-keepalived lihu12344/open-keepalived

               

    keepalived配置文件

    1. global_defs {
    2. default_interface eth0
    3. }
    4. vrrp_instance VI_1 {
    5. interface eth0
    6. state BACKUP
    7. virtual_router_id 50
    8. priority 150
    9. nopreempt
    10. unicast_peer {
    11. 172.18.0.81
    12. 172.18.0.82
    13. }
    14. virtual_ipaddress {
    15. 172.18.0.83
    16. }
    17. authentication {
    18. auth_type PASS
    19. auth_pass d0cker
    20. }
    21. notify "/container/service/keepalived/assets/notify.sh"
    22. }

             

    *************

    主备服务器

           

    default.conf

    1. server {
    2. listen 80;
    3. server_name localhost;
    4. location / {
    5. root /usr/local/openresty/nginx/html;
    6. index index.html index.htm;
    7. }
    8. location /test {
    9. echo "172.18.0.81";
    10. }
    11. error_page 500 502 503 504 /50x.html;
    12. location = /50x.html {
    13. root /usr/local/openresty/nginx/html;
    14. }
    15. }

              

    default2.conf

    1. server {
    2. listen 80;
    3. server_name localhost;
    4. location / {
    5. root /usr/local/openresty/nginx/html;
    6. index index.html index.htm;
    7. }
    8. location /test {
    9. echo "172.18.0.82";
    10. }
    11. error_page 500 502 503 504 /50x.html;
    12. location = /50x.html {
    13. root /usr/local/openresty/nginx/html;
    14. }
    15. }

               

    创建openresty主备容器

    1. docker run -it -d --net fixed --ip 172.18.0.81 -p 6001:80 --privileged \
    2. -v /Users/huli/lua/openresty/keep/default.conf:/etc/nginx/conf.d/default.conf \
    3. --name open-keepalived lihu12344/open-keepalived init
    4. docker run -it -d --net fixed --ip 172.18.0.82 -p 6002:80 --privileged \
    5. -v /Users/huli/lua/openresty/keep/default2.conf:/etc/nginx/conf.d/default.conf \
    6. --name open-keepalived2 lihu12344/open-keepalived init
    7. # 进入容器,开启openresty服务
    8. mkdir -p /var/run/openresty
    9. touch /var/run/openresty/nginx-client-body
    10. ./usr/bin/openresty

            

    open-keepalived、open-keepalived2均正常工作

    1. # keepalived
    2. [root@1a6fc3b15c7a /]# curl localhost:80/test
    3. 127.0.0.1 - - [03/Aug/2022:01:36:03 +0000] "GET /test HTTP/1.1" 200 22 "-" "curl/7.29.0"
    4. 172.18.0.81
    5. [root@1a6fc3b15c7a /]# curl 172.18.0.83:80/test
    6. 172.18.0.83 - - [03/Aug/2022:01:36:12 +0000] "GET /test HTTP/1.1" 200 22 "-" "curl/7.29.0"
    7. 172.18.0.81
    8. # keepalived2
    9. [root@75bb0cc675f5 /]# curl localhost:80/test
    10. 127.0.0.1 - - [03/Aug/2022:01:37:12 +0000] "GET /test HTTP/1.1" 200 22 "-" "curl/7.29.0"
    11. 172.18.0.82
    12. [root@75bb0cc675f5 /]# curl 172.18.0.83:80/test
    13. 172.18.0.81

             

    open-keepalived关闭、open-kepalived2正常工作

    1. # open-keepalived2
    2. [root@75bb0cc675f5 /]# curl localhost:80/test
    3. 127.0.0.1 - - [03/Aug/2022:02:13:20 +0000] "GET /test HTTP/1.1" 200 22 "-" "curl/7.29.0"
    4. 172.18.0.82
    5. [root@75bb0cc675f5 /]# curl 172.18.0.83:80/test
    6. 172.18.0.83 - - [03/Aug/2022:02:13:24 +0000] "GET /test HTTP/1.1" 200 22 "-" "curl/7.29.0"
    7. 172.18.0.82

    open-keepalived2切换为master服务器,使用虚拟ip调用,输出open-keepalived2接口

               

                             

  • 相关阅读:
    猿创征文 |【算法入门必刷】数据结构-栈(四)
    华为机试 - 信道分配
    蓝桥杯动态规划拿金币
    Electron的学习
    LeetCode每日一题——754. 到达终点数字
    SORA 到底是什么?如何用bitget wallet购买?
    SQL注入之order by注入与limit注入
    vue数据监听 -key的作用
    基于接口而非实现编程
    菜鸟踩坑之MybatisPlus查询时过滤不想要的字段
  • 原文地址:https://blog.csdn.net/weixin_43931625/article/details/126088062