后台任务节点高可用

配置keepalived服务

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

CentOS 7:

  1. yum install keepalived -y

假设配置了两个seafile后台任务节点:background1、background2

在background1上修改 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 background1
  10. vrrp_mcast_group4 224.0.100.18
  11. }
  12. vrrp_instance VI_1 {
  13. state MASTER
  14. interface eno16777736
  15. virtual_router_id 52
  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.43/24 dev eno16777736
  24. }
  25. notify_master "/opt/seafile/seafile-server-latest/seafile-background-tasks.sh start"
  26. notify_backup "/opt/seafile/seafile-server-latest/seafile-background-tasks.sh stop"
  27. }

在background2上修改 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 background2
  10. vrrp_mcast_group4 224.0.100.18
  11. }
  12. vrrp_instance VI_1 {
  13. state BACKUP
  14. interface eno16777736
  15. virtual_router_id 52
  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.43/24 dev eno16777736
  24. }
  25. notify_master "/opt/seafile/seafile-server-latest/seafile-background-tasks.sh start"
  26. notify_backup "/opt/seafile/seafile-server-latest/seafile-background-tasks.sh stop"
  27. }
  • 注意:以上配置中interface指定该节点的网卡设备名称,请根据实际情况配置。virtual_ipaddress 是后台服务的虚拟IP地址,也需要根据实际情况配置。

分别在两个后端节点上重启keepalived服务:

  1. systemctl restart keepalived.service

重启成功后查看background1节点是否成功启用了相应的VIP。

修改seafile前端服务器相关配置

当配置好keepalived实现了虚拟IP漂移后,需要将seafile前端服务器里的相关配置指向后端服务器的虚拟IP。
在各seafile前端服务器节点上:
编辑seafevents.conf,修改以下配置信息:

  1. [INDEX FILES]
  2. ...
  3. es_host = <vip of nodes background>
  4. ...

编辑seahub_settings.py,修改以下配置信息:

  1. ...
  2. OFFICE_CONVERTOR_ROOT = 'http://<vip of nodes background>'
  3. ...
  • 注意:以上配置文件中的'vip'指的是keepalived服务上配置的虚拟IP地址。

重启前端节点上的seafile、seahub服务:

  1. ./seafile.sh restart
  2. ./seahub.sh restart # 如果你使用 fastcgi 请使用此命令`./seahub.sh restart-fastcgi`