高可用 HAproxy 节点

在每个 HAproxy 节点上安装和配置 keepalived 来实现浮动 IP 地址。

CentOS 7:

  1. yum install keepalived

假设配置了两个 HAproxy 节点:node1、node2

在node1上修改 keepalived 配置文件(/etc/keepalived/keepalived.conf),写入如下内容:

  1. ! Configuration File for keepalived
  2. global_defs {
  3. notification_email {
  4. root@localhost
  5. }
  6. notification_email_from keepalived@localhost
  7. smtp_server 127.0.0.1
  8. smtp_connect_timeout 30
  9. router_id node1
  10. vrrp_mcast_group4 224.0.100.19
  11. }
  12. vrrp_instance VI_1 {
  13. state MASTER
  14. interface eno16777736
  15. virtual_router_id 51
  16. priority 100
  17. advert_int 1
  18. authentication {
  19. auth_type PASS
  20. auth_pass hello123
  21. }
  22. virtual_ipaddress {
  23. 172.26.154.45/24 dev eno16777736
  24. }
  25. }

在node2上修改 keepalived 配置文件(/etc/keepalived/keepalived.conf),写入如下内容:

  1. ! Configuration File for keepalived
  2. global_defs {
  3. notification_email {
  4. root@localhost
  5. }
  6. notification_email_from keepalived@localhost
  7. smtp_server 127.0.0.1
  8. smtp_connect_timeout 30
  9. router_id node2
  10. vrrp_mcast_group4 224.0.100.19
  11. }
  12. vrrp_instance VI_1 {
  13. state BACKUP
  14. interface eno16777736
  15. virtual_router_id 51
  16. priority 98
  17. advert_int 1
  18. authentication {
  19. auth_type PASS
  20. auth_pass hello123
  21. }
  22. virtual_ipaddress {
  23. 172.26.154.45/24 dev eno16777736
  24. }
  25. }
  • 注意:以上配置中interface指定该节点的网卡设备名称,请根据实际情况配置。virtual_ipaddress配置HAproxy集群的虚拟IP地址,也需要根据实际情况配置。

    修改 SERVICE_URL 和 FILE_SERVER_ROOT

下面还需要更新 SERVICE_URL 和 FILE_SERVER_ROOT 这两个配置项。否则无法通过 Web 正常的上传和下载文件。

5.0 版本开始,您可以直接通过管理员 Web 界面来设置这两个值 (注意,如果同时在 Web 界面和配置文件中设置了这个值,以 Web 界面的配置为准。建议在Web界面修改此配置。):

  1. SERVICE_URL: http://<ip of virtual_ipaddress>
  2. FILE_SERVER_ROOT: http://<ip of virtual_ipaddress>/seafhttp

原文: https://manual-cn.seafile.com/deploy_pro/setup_keepalived_with_haproxy.html