升级到 9.0.x
主要变更
9.0 版本主要的变更项目包括
- SERVICE_URL 现在放在了 seahub_settings.py,升级脚本会自动从 ccnet.conf 读取旧的配置并写入到 seahub_settings.py
- ElasticSearch 升级到 7.x 版本
- ElasticSearch 需要单独安装和维护 (因为版权的原因,ElasticSearch 7.x 版本开始无法带入 Seafile 包中),单独安装和维护也有其他的好处,包括: 减少安装包的大小,可以单独的调整 ElasticSearch 的各项参数。
- 内置的 Office 文件预览使用单独的 Docker Image 来实现。便于维护和解决和操作系统兼容性的问题。
- CentOS 包不再维护,建议迁移到 Docker 方式来使用 Seafile
- 提供了一个用 Go 语言重新实现的 fileserver 程序。默认依然使用原先 seaf-server 程序中提供的 fileserver 模块,可以通过选项切换到 Go fileserver。相比原有的 fileserver 模块,Go fileserver 有以下优势:
- 在高并发的环境下性能更好,避免由于部分请求处理时间过长而导致无法处理其他请求。
- 支持目录打包下载的 chunked 传输,无需等待整个目录打包完成再下载,而是打包和下载同时进行。这意味着不存在打包下载目录的大小上限。
- 支持对文件上传、下载进行限速。
安装 Python 依赖
注意,需要使用 root 用户或者 sudo 命令在系统范围内来安装 Python 依赖。
- Ubuntu 18.04/20.04
pip3 install pycryptodome==3.12.0 cffi==1.14.0升级到 9.0.x
- 停止 Seafile-8.0.x 服务.
- 进入 Seafile-9.0.x 目录, 运行以下脚本:
- 开启 Seafile-9.0.x 服务.
ElasticSearch 升级
方法一,重建索引,弃用旧的索引数据
如果你的数据量不大,建议部署 ElasticSearch 最新的 7.x 版本,然后重建新的索引。具体步骤如下
拉取 ElasticSearch 镜像
docker pull elasticsearch:7.16.2创建 Elasticsearch 数据映射目录,并给目录 777 权限,否则 elasticsearch 启动会报路径权限问题
mkdir -p /opt/seafile-elasticsearch/data && chmod -R 777 /opt/seafile-elasticsearch/data/启动 ElasticSearch 容器
sudo docker run -d --name es -p 9200:9200 -e "discovery.type=single-node" -e "bootstrap.memory_lock=true" -e "ES_JAVA_OPTS=-Xms1g -Xmx1g" -e "xpack.security.enabled=false" --restart=always -v /opt/seafile-elasticsearch/data:/usr/share/elasticsearch/data -d elasticsearch:7.16.2删除旧的索引数据
rm -rf /opt/seafile/pro-data/search/data/*修改 seafevents.conf
[INDEX FILES]external_es_server = truees_host = 127.0.0.1es_port = 9200重启seafile服务
su seafilecd seafile-server-latest/./seafile.sh stop && ./seahub.stop ./seafile.sh start && ./seahub.start方法二,升级已有的索引数据
如果你的数据量比较大,给所有的 Seafile 资料库重建索引会消耗比较长的时间,那么你可以升级已有的索引数据。这需要以下的步骤
- 下载和启动 ElasticSearch 7.x 版
- 利用已有的数据执行 ElasticSearch Reindex,以便建立 7.x 版本可以使用的索引
具体过程如下
下载 ES 镜像:
docker pull elasticsearch:7.16.2PS:seafile 9.0 版本,需要手动在宿主机上创建 elasticsearch 的映射路径,并且给 777 权限,否则 elasticsearch 启动会报路径权限问题,命令如下
mkdir -p /opt/seafile-elasticsearch/data把原来的索引数据放在/opt/seafile-elasticsearch/data/并授权
mv /opt/seafile/pro-data/search/data/* /opt/seafile-elasticsearch/data/chmod -R 777 /opt/seafile-elasticsearch/data/运行镜像
sudo docker run -d --name es -p 9200:9200 -e "discovery.type=single-node" -e "bootstrap.memory_lock=true" -e "ES_JAVA_OPTS=-Xms1g -Xmx1g" -e "xpack.security.enabled=false" --restart=always -v /opt/seafile-elasticsearch/data:/usr/share/elasticsearch/data -d elasticsearch:7.16.2PS: ES_JAVA_OPTS的值可以根据需求来更改大小
创建兼容 7.x 版本 mapping 的索引
curl -X PUT -H 'Content-Type: application/json' 'http{s}://{es server IP}:9200/new_repo_head?include_type_name=false&pretty=true' -d '{ "mappings" : { "properties" : { "commit" : { "type" : "text", "index" : false }, "repo" : { "type" : "text", "index" : false }, "updatingto" : { "type" : "text", "index" : false } } }}'curl -X PUT -H 'Content-Type: application/json' 'http{s}://{es server IP}:9200/new_repofiles/?include_type_name=false&pretty=true' -d '{ "settings" : { "index" : { "number_of_shards" : 5, "number_of_replicas" : 1, "analysis" : { "analyzer" : { "seafile_file_name_ngram_analyzer" : { "filter" : [ "lowercase" ], "type" : "custom", "tokenizer" : "seafile_file_name_ngram_tokenizer" } }, "tokenizer" : { "seafile_file_name_ngram_tokenizer" : { "type" : "ngram", "min_gram" : "3", "max_gram" : "4" } } } } }, "mappings" : { "properties" : { "content" : { "type" : "text", "term_vector" : "with_positions_offsets" }, "filename" : { "type" : "text", "fields" : { "ngram" : { "type" : "text", "analyzer" : "seafile_file_name_ngram_analyzer" } } }, "is_dir" : { "type" : "boolean" }, "mtime" : { "type" : "date" }, "path" : { "type" : "keyword" }, "repo" : { "type" : "keyword" }, "size" : { "type" : "long" }, "suffix" : { "type" : "keyword" } } }}'将 refresh_interval 设置为 -1、 number_of_replicas 设置为 0,以提高 reindex 的效率:
curl -X PUT -H 'Content-Type: application/json' 'http{s}://{es server IP}:9200/new_repo_head/_settings?pretty' -d '{ "index" : { "refresh_interval" : "-1", "number_of_replicas" : 0 }}'curl -X PUT -H 'Content-Type: application/json' 'http{s}://{es server IP}:9200/new_repofiles/_settings?pretty' -d '{ "index" : { "refresh_interval" : "-1", "number_of_replicas" : 0 }}'curl -X POST -H 'Content-Type: application/json' 'http{s}://{es server IP}:9200/_reindex/?pretty' -d '{ "source": { "index": "repo_head", "type": "repo_commit" }, "dest": { "index": "new_repo_head", "type": "_doc" }}'curl -X POST -H 'Content-Type: application/json' 'http{s}://{es server IP}:9200/_reindex/?pretty' -d '{ "source": { "index": "repofiles", "type": "file" }, "dest": { "index": "new_repofiles", "type": "_doc" }}'将 refresh_interval 和 number_of_replicas 重置为旧索引中使用的值。
curl -X PUT -H 'Content-Type: application/json' 'http{s}://{es server IP}:9200/new_repo_head/_settings?pretty' -d '{ "index" : { "refresh_interval" : null, "number_of_replicas" : 1 }}'curl -X PUT -H 'Content-Type: application/json' 'http{s}://{es server IP}:9200/new_repofiles/_settings?pretty' -d '{ "index" : { "refresh_interval" : null, "number_of_replicas" : 1 }}'等待索引健康状态变为green。
curl http{s}://{es server IP}:9200/_cluster/health?prettycurl -X POST -H 'Content-Type: application/json' 'http{s}://{es server IP}:9200/_aliases?pretty' -d '{ "actions": [ {"remove_index": {"index": "repo_head"}}, {"remove_index": {"index": "repofiles"}}, {"add": {"index": "new_repo_head", "alias": "repo_head"}}, {"add": {"index": "new_repofiles", "alias": "repofiles"}} ]}'升级完索引后,修改 Seafile 中的配置。
修改 seafevents.conf
[INDEX FILES]external_es_server = truees_host = 127.0.0.1es_port = 9200重启 seafile 服务
su seafilecd seafile-server-latest/./seafile.sh stop && ./seahub.stop ./seafile.sh start && ./seahub.start方法三,如果你是集群环境
部署一个新的 ElasticSeach 7.x 服务,使用 Seafile 9.0 版本部署一个新的后台节点,并对接 ElasticSeach 7.x 。后台节点不启动 Seafile 后台服务,只手工运行命令 ./pro/pro.py search --update ,建立完索引后再把其他节点升级到 Seafile 9.0 版,并使用新的 ElasticSeach 7.x。然后停用旧的后台节点和旧版的 ElasticSeach。
从 9.0.2 升级到 9.0.3+
如果你已经从 8.0 版本升级到了 9.0.2 版,9.0.2 版使用的是 ElasticSearch 6.8.20,在升级到 9.0.3+ 版时,需要按照上面的步骤升级一下索引。
如果你是全新部署的 9.0.2 版,那么你只需要把 ElasticSearch 的版本升级为 7.x 版,不需要升级索引。
内置 Office 文件预览 升级
如果你使用 OnlyOffice 来进行 Office 文件的预览和编辑,可以跳过这个步骤。
(可选)启用 Go fileserver
如需启用 Go fileserver,需要在 seafile.conf 中加入一个配置:
[fileserver]use_go_fileserver = true启动 seafile 之后,可以观察到有一个 fileserver 进程,监听的端口与原来的 fileserver 模块一致(默认 8082)。