实操指南:档案软件高可用的零 downtime 落地配置步骤

一、前置准备(需严格执行)

需2台同配置服务器(主节点+备用节点):每台2核4G vCPU、50G 系统盘、100G 数据盘,系统为CentOS 7.9,内网互通且时间同步(执行ntpdate cn.pool.ntp.org同步时间)。

1. 基础依赖安装

所有节点执行以下命令,确保依赖完整:

``` yum install -y mariadb-server mariadb-client memcached python36 rsync keepalived ```

务必验证:执行seafile-server -v无报错,若提示命令不存在,需重新配置环境变量。

二、主节点核心部署

1. Seafile软件安装

主节点执行以下命令下载并解压对应版本(选8.0.6稳定版,兼容性最强):

``` wget https://download.seafile.com/published/seafile-server/8.0.6/seafile-server_8.0.6_x86_64.tar.gz tar -zxvf seafile-server_8.0.6_x86_64.tar.gz -C /opt/ cd /opt/seafile-server-8.0.6/ ```

执行初始化脚本,按提示输入:

``` ./setup-seafile.sh ```

输入参数时严格按以下填写:服务器名seafile-main、内网IP192.168.1.10(替换为你主节点内网IP)、存储路径/opt/seafile-data、数据库类型mysql、数据库密码seafile_pass_2024(自定义但需记住)、管理员邮箱admin@test.com、管理员密码Admin@123456

2. 主节点配置调整

修改/opt/seafile/ccnet/ccnet.conf,找到以下字段,修改为:

``` [General] SERVICE_URL = http://192.168.1.100:8000 此处填Keepalived虚拟IP,后续会配置 FILE_SERVER_ROOT = http://192.168.1.100:8082 ```

修改/opt/seafile/conf/seafile.conf,添加高可用标识:

``` [database] host = 127.0.0.1 port = 3306 user = seafile password = seafile_pass_2024 db_name = seafile [fileserver] port = 8082 [cluster] enabled = true ```

启动主节点服务:

``` ./seafile.sh start ./seafile.sh start ```

务必验证:访问http://192.168.1.100:8000(虚拟IP)能正常登录,服务无报错。

三、备用节点部署与数据同步

备用节点需与主节点完全一致配置,执行同样的依赖安装、Seafile解压步骤,但跳过初始化脚本(复用主节点数据库)。

1. 数据同步配置

在主节点配置免密登录备用节点(备用节点IP为192.168.1.11):

``` ssh-keygen -t rsa -P "" -f /root/.ssh/id_rsa ssh-copy-id root@192.168.1.11 ```

在主节点创建定时同步任务,每5分钟同步Seafile数据:

``` crontab -e ```

实操指南:档案软件高可用的零 downtime 落地配置步骤

添加以下内容:

``` /5 rsync -avz --delete /opt/seafile/seafile-data/ root@192.168.1.11:/opt/seafile/seafile-data/ ```

2. 备用节点配置

备用节点修改/opt/seafile/ccnet/ccnet.conf,SERVICE_URL同主节点,数据库配置指向主节点IP(192.168.1.10):

``` [database] host = 192.168.1.10 port = 3306 user = seafile password = seafile_pass_2024 db_name = seafile ```

停止备用节点默认启动的服务,确保服务未运行:

``` ./seafile.sh stop ./seafile.sh stop ```

务必验证:主节点执行rsync命令无报错,备用节点数据目录已同步主节点最新内容。

四、Keepalived虚拟IP配置(核心高可用)

所有节点配置Keepalived,主节点优先级高于备用,虚拟IP漂移触发自动切换。

1. 主节点Keepalived配置

编辑/etc/keepalived/keepalived.conf,完整内容如下:

``` global_defs { router_id SEAFILE_HA_MAIN } vrrp_instance VI_1 { state MASTER interface eth0 替换为你的网卡名,执行ifconfig查看 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.1.100/24 虚拟IP,需在同网段 } notify_master "/usr/bin/systemctl start seafile" notify_backup "/usr/bin/systemctl stop seafile" } ```

2. 备用节点Keepalived配置

编辑/etc/keepalived/keepalived.conf,仅修改以下内容:

``` global_defs { router_id SEAFILE_HA_BACKUP } vrrp_instance VI_1 { state BACKUP interface eth0 同主节点网卡名 virtual_router_id 51 priority 90 优先级低于主节点 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.1.100/24 } notify_master "/usr/bin/systemctl start seafile" notify_backup "/usr/bin/systemctl stop seafile" } ```

启动所有节点的Keepalived服务:

``` systemctl start keepalived systemctl enable keepalived ```

务必验证:主节点执行ip a能看到虚拟IP192.168.1.100,备用节点无该IP。

五、故障自动切换验证

执行以下步骤,验证高可用是否生效:

  1. 在主节点执行systemctl stop seafile,停止主节点服务;
  2. 等待30秒,执行ip a查看备用节点,确认虚拟IP已漂移到备用节点;
  3. 访问http://192.168.1.100:8000,正常登录且档案数据完整;
  4. 重启主节点服务,虚拟IP自动漂移回主节点,服务恢复正常。

关键提示:切换过程无服务中断,符合零 downtime 要求。

六、细节优化(避免后续问题)

1. 防火墙配置:所有节点开放相关端口,执行:

``` firewall-cmd --add-port=8000/tcp --permanent firewall-cmd --add-port=8082/tcp --permanent firewall-cmd --add-port=112/udp --permanent Keepalived VRRP端口 firewall-cmd --reload ```

2. 时间同步:确保主备节点时间差小于1秒,避免VRRP通信异常;

3. 备份配置:每周备份主节点的/opt/seafile-data目录和数据库,执行:

``` mysqldump -u seafile -pseafile_pass_2024 seafile > seafile_db_backup.sql tar -zcvf seafile_data_backup.tar.gz /opt/seafile/seafile-data/ ```
AI咨询
热线电话

028-85154420

15388110056

全国售前咨询电话

扫码咨询
安答联动微信公众号二维码

微信扫码关注安答联动

申请试用
热线电话
申请试用

安答联动档案管理系统