利用两个下午时间把服务器从11升级到12,因为是虚拟机部署自用的,觉得docker部署占用资源,特别是存储资源,所以采用非docker方式部署,升级之路坎坷。
记录下来:
1.1.下载docker镜像,复制出seafile-pro-mc_12.0 和sdoc-server_1.0安装文件,顺便把notification-server也复制出来。
1.2.上传到ubuntu22.4虚拟机,防止出错,先备份三个数据库。
1.3.根据手册,创建python环境,安装seafile-pro,一路没啥问题,运行seafile.sh的时候无法启动,提示glibc版本要求2.38,升级呗,找度娘,有人说是自己编译升级的话可能会出问题,果断使用seaf-fsck.sh导出文件。保存到本地电脑上,果然编译安装后ssh无法连接了,重启虚拟机还是无法启动,凉了,好在数据库和资料全部保存到本地电脑。
重新安装系统,这次使用ubuntu24.04,安装系统完毕后,开启ssh服务,检查glibc版本版本,2.39,满足要求,接下来就是参照手册 按部就班操作
2.1.更新系统,设置时区;
2.2.安装Memcached,安装mariadb,安装Python环境;
2.3.创建/opt/seafile目录,在目录下创建python虚拟环境;
2.4.启动虚拟环境后使用pip安装依赖;
2.5.创建数据库,恢复数据库,上传安装文件,配置文件,上传seafile-data文件夹,运行安装脚本,选择使用存在的数据库,结果提示说数据库已经存在,本来就是选择已经存在的数据库呀,为啥还要创建呢?算了,不折腾了,直接全新安装吧,安装完毕后进入在虚拟环境中启动seafile和seahub,成功。
2.6.登录网盘后看了一圈,感受一下12的新界面,感觉还不错,吐槽一下相册功能还是不强。本来计划跟以前一样,不安装sdoc,没想到转了一圈发现知识库功能必须安装sdoc,都忙了这么久,继续折腾sdoc吧。
安装sdoc
3.1打开docker镜像文件,翻看了一下sdoc-server目录结构,有用的文件是opt目录下的seadoc-server和根目录下的scripts目录,为啥初始化、启动和监控脚本要放在根目录下的scripts目录里面呢?
3.2参照seafile的目录结构,重建seadoc-server目录,把seadoc-server-1.0.3放到/opt/seafile/目录下,同时新建/opt/seafile/seadoc-data/目录,新建seadoc-server-latest,指向/opt/seafile/seadoc-server-1.0.3/,
3.3相关配置,在/opt/seafile/conf目录下新建sdoc_server_config.json文件,配置如下:
{
"seahub_service_url": "http://192.168.3.201",
"server_port": 7070,
"save_interval": 10000,
"private_key": "ih58tXT2UFQUVXpQ5EPDAzhPyqU3Ct1wreRtCaTl",
"host": "127.0.0.1",
"user": "seafile",
"password": "你的密码",
"database": "seahub_db",
"port": "3306",
"connection_limit": 5
}
private_key与/opt/seafile/conf/.env文件中的JWT_PRIVATE_KEY相同
其他内容根据实际填写。
3.4在opt/seafile/seadoc-server-1.0.3/目录下创建seadoc-monitor.sh和seadoc-server.sh两个脚本
seadoc-monitor.sh脚本内容
#!/bin/bash
export SDOC_SERVER_CONFIG=/opt/seafile/conf/sdoc_server_config.json
export LOG_DIR=/opt/seafile/logs/
# log function
function log() {
local time=$(date +"%F %T")
echo "[$time] $1 "
echo "[$time] $1 " &>> /opt/seafile/logs/monitor.log
}
# check process number
# $1 : process name
function check_process() {
if [ -z $1 ]; then
log "Input parameter is empty."
return 0
fi
process_num=$(ps -ef | grep "$1" | grep -v "grep" | wc -l)
echo $process_num
}
# start
function start_sdoc_server() {
cd /
cd /opt/seafile/sdoc-server-latest/seadoc
if [[ $NON_ROOT == "true" ]] ;then
su seafile -c "node --max-old-space-size=4096 ./dist/_bin/www.js &"
else
node --max-old-space-size=4096 ./dist/_bin/www.js &
fi
sleep 1
}
function start_seadoc_converter() {
cd /
cd /opt/seafile/sdoc-server-latest/seadoc-converter
if [[ $NON_ROOT == "true" ]] ;then
su seafile -c "python3 -u seadoc_converter/main.py &"
else
python3 -u seadoc_converter/main.py &
fi
sleep 1
}
# monitor
function monitor_sdoc_server() {
process_name="www.js"
check_num=$(check_process $process_name)
if [ $check_num -eq 0 ]; then
log "Start $process_name"
start_sdoc_server
fi
}
function monitor_seadoc_converter() {
process_name="seadoc_converter/main.py"
check_num=$(check_process $process_name)
if [ $check_num -eq 0 ]; then
log "Start $process_name"
start_seadoc_converter
fi
}
log "Start Monitor"
while [ 1 ]; do
monitor_sdoc_server
monitor_seadoc_converter
sleep 30
done
seadoc-server.sh内容如下:
#!/bin/bash
function stop_server() {
pkill -9 -f www.js
pkill -9 -f seadoc_converter/main.py
pkill -9 -f seadoc-monitor.sh
}
function set_env() {
export SDOC_SERVER_CONFIG=/opt/seafile/conf/sdoc_server_config.json
export LOG_DIR=/opt/seafile/logs/
export CONF_PATH=/opt/seafile/conf/
}
function start_server() {
stop_server
sleep 0.5
set_env
if [[ $NON_ROOT == "true" ]] ;then
cd /
cd /opt/seafile/seadoc-server-latest/seadoc
su seafile -c "node --max-old-space-size=4096 ./dist/_bin/www.js &"
sleep 0.2
cd /
cd /opt/seafile/seadoc-server-latest/seadoc-converter
su seafile -c "python3 -u seadoc_converter/main.py &"
sleep 0.2
else
cd /
cd /opt/seafile/seadoc-server-latest/seadoc
node --max-old-space-size=4096 ./dist/_bin/www.js &
sleep 0.2
cd /
cd /opt/seafile/seadoc-server-latest/seadoc-converter
python3 -u seadoc_converter/main.py &
sleep 0.2
fi
/opt/seafile/seadoc-server-latest/seadoc-monitor.sh &
echo "sdoc-server started"
echo
}
case $1 in
"start")
start_server
;;
"stop")
stop_server
;;
*)
start_server
;;
esac
注意,上面涉及路径和文件名的地方按照实际修改,如果按照我的目录结构的话就不需要修改了。
3.4修改nginx配置文件,/etc/nginx/sites-enabled/seafile.conf,在/media{}代理location 块下面添加sdoc 、socket.io、converter 、notification 和notification/ping几个代理
location /sdoc {
#add_header Access-Control-Allow-Origin *;
#add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
#add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
#if ($request_method = 'OPTIONS') {
# add_header Access-Control-Allow-Origin *;
# add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
# add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
# return 204;
#}
proxy_pass http://192.168.3.201:7070;
client_max_body_size 100m;
access_log /opt/seafile/logs/nginx-sdoc-server.access.log sdoc-serverformat;
error_log /opt/seafile/logs/nginx-sdoc-server.error.log;
}
location /socket.io {
proxy_pass http://192.168.3.201:7070;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_redirect off;
proxy_buffers 8 32k;
proxy_buffer_size 64k;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
access_log /opt/seafile/logs/nginx-socket-io.access.log sdoc-serverformat;
error_log /opt/seafile/logs/nginx-socket-io.error.log;
}
location /converter {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
return 204;
}
proxy_pass http://192.168.3.201:8888/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 100m;
access_log /opt/seafile/logs/nginx-converter.access.log sdoc-serverformat;
error_log /opt/seafile/logs/nginx-converter.error.log;
}
location /notification/ping {
proxy_pass http://192.168.3.201:8083/ping;
access_log /opt/seafile/logs/notification-ping.access.log;
error_log /opt/seafile/logs/notification-ping.error.log;
}
location /notification {
proxy_pass http://192.168.3.201:8083;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
access_log /opt/seafile/logs/notification.access.log;
error_log /opt/seafile/logs/notification.error.log;
}
这个配置文件还是有点问题,有些地方没有验证成功,但是日志文件是正常的,本来打算删掉的,后来检查日志文件的时候发现记录正常,可以辅助排故障。
3.5激活虚拟环境,到/opt/seafile/seadoc-server-1.0.3/seadoc-converter目录下使用pip install -r requirements.txt安装seadoc-converter依赖。
3.6安装node,
cd ~
curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs
3.7在python虚拟环境下使用seafile用户运行seadoc-server.sh,然后启动seafile和seahub,灯登录网盘发现sdoc功能可以正常使用了,nginx中socket.io和seadoc-converter块的配置是否正确我也不清楚,使用浏览器开发者工具看socket.io访问正常,seadoc转换docx时提示没有权限,具体什么情况明天再看看吧。
翻看了notification-server的docker镜像,没看到配置文件和启动文件,手册上主要是针对docker部署将的,再加上以前也没用过这个功能,所以放弃琢磨了。
本人不是专业运维人员或者程序员,仅仅是兴趣爱好,觉得seafile还不错,以上安装以及配置如有错误的地方请大家批评指正,见笑了。
onlyoffice和ElasticSearch只能用docker部署了,实在是pull不了啊,