规则:以一个虚拟ip分组归为同一个路由

主节点配置:

  1. global_defs {
  2. router_id keep_171
  3. }
  4. vrrp_instance VI_1 {
  5. state MASTER
  6. interface ens33
  7. virtual_router_id 51
  8. priority 100
  9. advert_int 1
  10. authentication {
  11. auth_type PASS
  12. auth_pass 1111
  13. }
  14. virtual_ipaddress {
  15. 192.168.1.161
  16. }
  17. }
  18. vrrp_instance VI_2 {
  19. state BACKUP
  20. interface ens33
  21. virtual_router_id 52
  22. priority 80
  23. advert_int 1
  24. authentication {
  25. auth_type PASS
  26. auth_pass 1111
  27. }
  28. virtual_ipaddress {
  29. 192.168.1.162
  30. }
  31. }

备用节点配置

  1. global_defs {
  2. router_id keep_172
  3. }
  4. vrrp_instance VI_1 {
  5. state BACKUP
  6. interface ens33
  7. virtual_router_id 51
  8. priority 80
  9. advert_int 1
  10. authentication {
  11. auth_type PASS
  12. auth_pass 1111
  13. }
  14. virtual_ipaddress {
  15. 192.168.1.161
  16. }
  17. }
  18. vrrp_instance VI_2 {
  19. state MASTER
  20. interface ens33
  21. virtual_router_id 52
  22. priority 100
  23. advert_int 1
  24. authentication {
  25. auth_type PASS
  26. auth_pass 1111
  27. }
  28. virtual_ipaddress {
  29. 192.168.1.162
  30. }
  31. }

别忘记分别重启两条Keepalived

  1. # 重启Keepalived
  2. systemctl restart keepalived