layout: post
title: keepalived—主主模型实现LVS的DR模型
date: 2018-03-13
tags: [“Cluster services”,”软件服务”]


1 proxy1

  1. cat keepalived.conf
  2. ! Configuration File for keepalived
  3. global_defs {
  4. notification_email {
  5. root@localhost
  6. }
  7. notification_email_from keepalived@localhost
  8. smtp_server 127.0.0.1
  9. smtp_connect_timeout 30
  10. router_id proxy1
  11. vrrp_mcast_group4 224.1.1.1
  12. }
  13. vrrp_instance VI_1 {
  14. state MASTER
  15. interface eth0
  16. virtual_router_id 66
  17. priority 100
  18. advert_int 1
  19. authentication {
  20. auth_type PASS
  21. auth_pass 123456
  22. }
  23. virtual_ipaddress {
  24. 192.168.27.100/24
  25. }
  26. notify_master "/etc/keepalived/notify.sh master"
  27. notify_backup "/etc/keepalived/notify.sh backup"
  28. notify_fault "/etc/keepalived/notify.sh fault"
  29. }
  30. virtual_server 192.168.27.100 80 {
  31. delay_loop 6
  32. lb_algo rr
  33. lb_kind DR
  34. #persistence_timeout 50
  35. protocol TCP
  36. sorry_server 127.0.0.1 80
  37. real_server 192.168.27.27 80 {
  38. weight 1
  39. HTTP_GET {
  40. url {
  41. path /
  42. status_code 200
  43. }
  44. connect_timeout 3
  45. nb_get_retry 3
  46. delay_before_retry 3
  47. }
  48. }
  49. real_server 192.168.27.37 80 {
  50. weight 1
  51. HTTP_GET {
  52. url {
  53. path /
  54. status_code 200
  55. }
  56. connect_timeout 3
  57. nb_get_retry 3
  58. delay_before_retry 3
  59. }
  60. }
  61. }
  62. vrrp_instance VI_2{
  63. state BACKUP
  64. interface eth0
  65. virtual_router_id 88
  66. priority 80
  67. advert_int 1
  68. authentication {
  69. auth_type PASS
  70. auth_pass 123456
  71. }
  72. virtual_ipaddress {
  73. 192.168.27.200/24
  74. }
  75. notify_master "/etc/keepalived/notify.sh master"
  76. notify_backup "/etc/keepalived/notify.sh backup"
  77. notify_fault "/etc/keepalived/notify.sh fault"
  78. }
  79. virtual_server 192.168.27.200 80 {
  80. delay_loop 6
  81. lb_algo rr
  82. lb_kind DR
  83. #persistence_timeout 50
  84. protocol TCP
  85. sorry_server 127.0.0.1 80
  86. real_server 192.168.27.28 80 {
  87. weight 1
  88. HTTP_GET {
  89. url {
  90. path /
  91. status_code 200
  92. }
  93. connect_timeout 3
  94. nb_get_retry 3
  95. delay_before_retry 3
  96. }
  97. }
  98. real_server 192.168.27.38 80 {
  99. weight 1
  100. HTTP_GET {
  101. url {
  102. path /
  103. status_code 200
  104. }
  105. connect_timeout 3
  106. nb_get_retry 3
  107. delay_before_retry 3
  108. }
  109. }
  110. }

2 proxy2

  1. cat keepalived.conf
  2. ! Configuration File for keepalived
  3. global_defs {
  4. notification_email {
  5. root@localhost
  6. }
  7. notification_email_from keepalived@localhost
  8. smtp_server 127.0.0.1
  9. smtp_connect_timeout 30
  10. router_id proxy2
  11. vrrp_mcast_group4 224.1.1.1
  12. }
  13. vrrp_instance VI_1 {
  14. state BACKUP
  15. interface eth0
  16. virtual_router_id 66
  17. priority 80
  18. advert_int 1
  19. authentication {
  20. auth_type PASS
  21. auth_pass 123456
  22. }
  23. virtual_ipaddress {
  24. 192.168.27.100/24
  25. }
  26. notify_master "/etc/keepalived/notify.sh master"
  27. notify_backup "/etc/keepalived/notify.sh backup"
  28. notify_fault "/etc/keepalived/notify.sh fault"
  29. }
  30. virtual_server 192.168.27.100 80 {
  31. delay_loop 6
  32. lb_algo rr
  33. lb_kind DR
  34. #persistence_timeout 50
  35. protocol TCP
  36. sorry_server 127.0.0.1 80
  37. real_server 192.168.27.27 80 {
  38. weight 1
  39. HTTP_GET {
  40. url {
  41. path /
  42. status_code 200
  43. }
  44. connect_timeout 3
  45. nb_get_retry 3
  46. delay_before_retry 3
  47. }
  48. }
  49. real_server 192.168.27.37 80 {
  50. weight 1
  51. HTTP_GET {
  52. url {
  53. path /
  54. status_code 200
  55. }
  56. connect_timeout 3
  57. nb_get_retry 3
  58. delay_before_retry 3
  59. }
  60. }
  61. }
  62. vrrp_instance VI_2 {
  63. state MASTER
  64. interface eth0
  65. virtual_router_id 88
  66. priority 100
  67. advert_int 1
  68. authentication {
  69. auth_type PASS
  70. auth_pass 123456
  71. }
  72. virtual_ipaddress {
  73. 192.168.27.200/24
  74. }
  75. notify_master "/etc/keepalived/notify.sh master"
  76. notify_backup "/etc/keepalived/notify.sh backup"
  77. notify_fault "/etc/keepalived/notify.sh fault"
  78. }
  79. virtual_server 192.168.27.200 80 {
  80. delay_loop 6
  81. lb_algo rr
  82. lb_kind DR
  83. #persistence_timeout 50
  84. protocol TCP
  85. sorry_server 127.0.0.1 80
  86. real_server 192.168.27.28 80 {
  87. weight 1
  88. HTTP_GET {
  89. url {
  90. path /
  91. status_code 200
  92. }
  93. connect_timeout 3
  94. nb_get_retry 3
  95. delay_before_retry 3
  96. }
  97. }
  98. real_server 192.168.27.38 80 {
  99. weight 1
  100. HTTP_GET {
  101. url {
  102. path /
  103. status_code 200
  104. }
  105. connect_timeout 3
  106. nb_get_retry 3
  107. delay_before_retry 3
  108. }
  109. }
  110. }
文档更新时间: 2018-12-20 11:18   作者:张尚