此文档是关于单个节点的,如果您是集群部署,必须在
所有节点
中执行以下操作(迁移数据库除外)
通常,我们只建议您根据本文档中的解决方案在两台不同的机器上执行迁移作。如果您决定在同一台机器上执行作,请注意文档中的相应提示。
在两台不同计算机上从非 docker 部署迁移到 docker 部署的建议步骤如下:
-
将您的 Seafile 服务器升级到最新版本。
-
关闭 Seafile 和本机的 Nginx,Memcached/Redis
-
备份 Seafile 数据(如果未使用现有的 MySQL 数据库来部署非 Docker 版本的 Seafile,则数据库也需要备份)
-
新机器中部署 Seafile Docker。
-
在新机器中恢复 Seafile 库和 MySQL 数据库。
-
启动 Seafile Docker 并根据您的情况关闭旧的 MySQL(或 Mariadb)。
迁移前
停止服务
停止 Seafile 服务
在
/opt/seafile/seafile-server-latest
中运行以下命令:
su seafile
./seafile.sh stop
./seahub.sh stop
如果使用了 Python 虚拟环境的安装,它尚未处于活动状态,请激活:
source python-venv/bin/activate
如果您在 Seafile 服务器中集成了某些组件(例如,
SeaDoc
),请关闭它们以避免丢失未保存的数据。
停止 Nginx、缓存服务器(例如
Memcached/Redis
)、ElasticSearch
在迁移之前,必须停止上述服务以避免数据丢失:
systemctl stop nginx && systemctl disable nginx
systemctl stop memcached && systemctl disable memcached
#or redis
systemctl stop redis && systemctl disable redis
docker stop es && docker remove es
如果没有使用已存在的 MySQL,那么也必须关闭 MySQL 服务。
备份Seafile
-
备份数据库(仅当您未使用现有数据库部署非 Docker 版本的 Seafile 时需要)
-
备份Seafile资料库数据
下载 docker-compose 文件
你必须下载最新的 Docker-Compose 文件(即一系列的.yml 文件及其配置文件.env),以便启动相关服务。
#12.0 社区版
wget -O .env https://manual.seafile.com/12.0/repo/docker/ce/env
wget https://manual.seafile.com/12.0/repo/docker/ce/seafile-server.yml
wget https://manual.seafile.com/12.0/repo/docker/caddy.yml
#12.0 专业版
wget -O .env https://manual.seafile.com/12.0/repo/docker/pro/env
wget https://manual.seafile.com/12.0/repo/docker/pro/seafile-server.yml
wget https://manual.seafile.com/12.0/repo/docker/caddy.yml
#13.0 社区版
wget -O .env https://manual.seafile.com/13.0/repo/docker/ce/env
wget https://manual.seafile.com/13.0/repo/docker/ce/seafile-server.yml
wget https://manual.seafile.com/13.0/repo/docker/seadoc.yml
wget https://manual.seafile.com/13.0/repo/docker/caddy.yml
#13.0专业版
wget -O .env https://manual.seafile.com/13.0/repo/docker/pro/env
wget https://manual.seafile.com/13.0/repo/docker/pro/seafile-server.yml
wget https://manual.seafile.com/13.0/repo/docker/pro/elasticsearch.yml
wget https://manual.seafile.com/13.0/repo/docker/seadoc.yml
wget https://manual.seafile.com/13.0/repo/docker/caddy.yml
然后根据你的配置修改
.env
。
注意:不要
将非 Docker 版 Seafile 服务器中的
.env
直接用作基于 Docker 的 Seafile 服务器中的
.env
,因为这样会缺少一些运行基于 Docker 的 Seafile 所需的关键变量。否则,Seafile 服务器可能
无法正常工作
。
为 Seafile Docker 创建目录和恢复数据
在基于 Docker 的 Seafile 中,Seafile 的默认工作目录是
/opt/seafile-data
(你可以在
.env
文件中修改它们)。在这里,你必须创建这个目录,并从备份文件中恢复:
mkdir -p /opt/seafile-data/seafile
# recover seafile data
cp /backup/data/* /opt/seafile-data/seafile
恢复数据库(仅当不使用已有的 MySQL 时)
你应该首先启动服务,否则无法连接到 MySQL 服务(
mariadb
在使用 Seafile 的 docker-compose 中):
docker compose up -d
启动 MySQL 服务后,你应该创建 MySQL 用户(例如
seafile
,在
.env
文件中定义)并添加相关权限。
## Note, change the password according to the actual password you use
GRANT ALL PRIVILEGES ON *.* TO 'seafile'@'%' IDENTIFIED BY 'your-password' WITH GRANT OPTION;
## Grant seafile user can connect the database from any IP address
GRANT ALL PRIVILEGES ON `ccnet_db`.* to 'seafile'@'%';
GRANT ALL PRIVILEGES ON `seafile_db`.* to 'seafile'@'%';
GRANT ALL PRIVILEGES ON `seahub_db`.* to 'seafile'@'%';
重启服务
迁移完成后,可以通过重启服务来重启基于 Docker 的 Seafile 服务:
docker compose up -d
启动服务后,可以使用
docker logs -f seafile
来跟踪
Seafile
的日志输出,以检查服务的状态。当服务正常运行时,将收到以下消息:
Starting seafile server, please wait ...
Seafile server started
Done.
Starting seahub at port 8000 ...
Seahub is started
Done.