当前位置: 首页 >> 原创·技术 >> 202010041452 记Seafile-pro-server-7.1.7一键脚本部署(国庆节快乐) >> 正文

202010041452 记Seafile-pro-server-7.1.7一键脚本部署(国庆节快乐)

4年前 (2020-10-04)     作者:iMoke     分类:原创·技术     阅读次数:4677     评论(2)    

我之前一直用Seafile6.2.9,Seafile7系列一直就没部署成功过。最近借着国庆节,再次部署失败。

忽然发现官方居然有一键脚本,结果在实际部署中,一键脚本也有一堆的坑。

那么在这,我就把我的踩坑经历写出来,供后人绕过~


一、前言

更新时间:2020年10月04日 15:27:03

我之前一直用Seafile6.2.9,Seafile7系列一直就没部署成功过。最近借着国庆节,再次部署失败。

忽然发现官方居然有一键脚本,结果在实际部署中,一键脚本也有一堆的坑。

那么在这,我就把我的踩坑经历写出来,供后人绕过~

二、参考资料

下载和安装 Seafile 专业版【官方部署文档】

haiwen/seafile-server-installer-cn【官方一键脚本】


三、前期准备

1.一个干干净净的CentOS8,没错,是CentOS8。我用的是minumal安装的最小化,不带任何软件。(太坑了)

# imoke自用
yum install -y mlocate lrzsz net-tools wget

2.【建议】将源换成清华源,速度会快很多。【学渣致敬清华】

# centos
sed -i "s/^#baseurl/baseurl/g" /etc/yum.repos.d/CentOS-*
sed -i "s/^mirrorlist/#mirrorlist/g" /etc/yum.repos.d/CentOS-*
sed -i "s/mirror.centos.org/mirrors.tuna.tsinghua.edu.cn/g" /etc/yum.repos.d/CentOS-*

# epel
yum install -y https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-8.noarch.rpm
sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.tuna.tsinghua.edu.cn|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
sed -i "s/https/http/g" /etc/yum.repos.d/epel*

# pip
mkdir -p ~/.pip/
touch ~/.pip/pip.conf
cat >~/.pip/pip.conf<<EOF
[global]
index-url = https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

[install]
trusted-host=mirrors.tuna.tsinghua.edu.cn
EOF

3.官方安装包:seafile-pro-server_7.1.7_x86-64_CentOS.tar.gz

wget -O /opt/seafile-pro-server_7.1.7_x86-64.tar.gz https://download.seafile.com/d/6e5297246c/files/?p=%2Fpro%2Fseafile-pro-server_7.1.7_x86-64_CentOS.tar.gz&dl=1
# wget -O /opt/seafile-pro-server_7.1.7_x86-64.tar.gz http://d.rc.it/Server/seafile/seafile-pro-server_7.1.7_x86-64_CentOS.tar.gz

4.【官方的一键脚本】seafile-server-7.1-centos-amd64-http

wget -O /opt/seafile-server-7.1-centos-amd64-http https://raw.githubusercontent.com/haiwen/seafile-server-installer-cn/master/seafile-server-7.1-centos-amd64-http
# wget -O /opt/seafile-server-7.1-centos-amd64-http http://d.rc.it/Server/seafile/seafile-server-7.1-centos-amd64-http 
chmod +x /opt/seafile-server-7.1-centos-amd64-http

四、开始部署

坑1:纯净版系统需要先安装一些东西,不然一键脚本会失败!

yum install -y gcc-c++ platform-python-devel.x86_64 tar


坑2:需改官方脚本,自定义一些内容

# 自定义管理员账号:行101【可选修改】
SEAFILE_ADMIN=admin@seafile.local
sed -i "s/admin@seafile.local/admin@imoke.org/g" /opt/seafile-server-7.1-centos-amd64-http

# 自定义新建用户:行102【可选修改】
SEAFILE_SERVER_USER=seafile
sed -i "s/SEAFILE_SERVER_USER=seafile/SEAFILE_SERVER_USER=imoke/g" /opt/seafile-server-7.1-centos-amd64-http

# 自定义域名:行104【建议修改】
IP_OR_DOMAIN=127.0.0.1
sed -i "s/IP_OR_DOMAIN=127.0.0.1/IP_OR_DOMAIN=seafile.imoke.org/g" /opt/seafile-server-7.1-centos-amd64-http

# 自定义发件账号:行476:行482,启用别忘了取消注释【建议修改】
# EMAIL_USE_TLS                       = False
# EMAIL_HOST                          = 'localhost'
# EMAIL_HOST_USER                     = ''
# EMAIL_HOST_PASSWORD                 = ''
# EMAIL_PORT                          = '25'
# DEFAULT_FROM_EMAIL                  = EMAIL_HOST_USER
# SERVER_EMAIL                        = EMAIL_HOST_USER


坑3:这个脚本默认会在/opt/seafile/aio_seafile-server.log显示你的账号信息,但是实际上,并没有。因此建议配置邮箱,可以自行找回密码。

补充:经过仔细查,在行524有一行“pkill -9 -u seafile”,导致后面的Fix permissions、Restart seafile server、Final report都未执行,因此无法输出最终报告。

解决方法1:注释掉这条【推荐】

sed -i "s/pkill -9 -u seafile/# pkill -9 -u seafile/g" /opt/seafile-server-7.1-centos-amd64-http

解决方法2:自定义密码【如果你知道自己在做什么】

# 在行107添加一个自定义密码变量,password就是自定义密码。
sed -i "107i CUSTOM_PASSWORD='password'" /opt/seafile-server-7.1-centos-amd64-http

# 将文中所有随机密码的地方全部换成自定义密码变量
sed -i "s/\$(pwgen)/\$CUSTOM_PASSWORD/g" /opt/seafile-server-7.1-centos-amd64-http

注意:这种方式有一种风险,就是你的【坑2:自定义新建用户】【MYSQL ROOT用户】【Seafile管理员用户】都变成统一的。

避免这种风险也有一个办法,就是定义三个密码,分别替换三个不同位置的$(pwgen)变量。这里不再细讲。


4:绕过了所有的坑,我们就可以执行官方一键脚本,PRO版选2。

cd /opt
./seafile-server-7.1-centos-amd64-http 7.1.7<<EOF
2
EOF


5:去找那些“随机”的账号们

# 查看mysql的账号和密码
cat $HOME/.my.cnf

#系统会新建一个用户名,在【坑2:自定义新建用户:行102】处定义的。查看这个用户的密码
cat /opt/seafile.my.cnf

# 查看Seafile的账号和密码【坑4】,正常会在这里显示你的账号信息,但是实际上,并没有。因此建议配置邮箱,可以自行找回密码。
cat /opt/seafile/aio_seafile-server.log

# nginx Seafile配置文件
cat /etc/nginx/conf.d/seafile.conf


五、补充

其实到【四】,至少上传下载之类的已经可以用了。但是还有一些官方自己的坑。比如说:

1.无法在线预览

参考链接:https://cloud.seafile.com/published/seafile-manual-cn/deploy_pro/office_documents_preview.md#user-content-7.1%20%E4%BB%A5%E5%8F%8A%E4%B9%8B%E5%90%8E%E7%89%88%E6%9C%AC

yum remove --setopt=clean_requirements_on_remove=0 libreoffice-* -y
mkdir -p /usr/libreoffice
cd /usr/libreoffice
wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/7.0.1/rpm/x86_64/LibreOffice_7.0.1_Linux_x86-64_rpm.tar.gz
# wget http://d.rc.it/Server/libreOffice/LibreOffice_7.0.1_Linux_x86-64_rpm.tar.gz
tar -zxvf LibreOffice_*_Linux_x86-64_rpm.tar.gz -C /usr/libreoffice/
cd LibreOffice_7.0.1.2_Linux_x86-64_rpm/RPMS/
yum localinstall -y *.rpm

yum install -y libSM-devel

打开 conf/seafevents.conf,添加:

[OFFICE CONVERTER]
enabled = true
host = 127.0.0.1  # 本机的IP地址,默认 127.0.0.1
port = 6000  # 端口,默认6000


打开conf/seahub_settings.py,添加:

OFFICE_CONVERTOR_ROOT = 'http://127.0.0.1:6000/'
# 与seafevents.conf中的 host 和 port 保持一致


保存 seafevents.conf 与seahub_settings.py后,重启 Seafile 服务 ./seafile.sh restart

其他配置选项

[OFFICE CONVERTER]

## 并发运行 libreoffice 的进程数
workers = 1

## 转换后的 office/pdf 文件的缓存路径。 默认是 /tmp/。/tmp/seafile-office-output/是一键脚本的路径。
outputdir = /tmp/seafile-office-output/


六、总的来说,官方的一键脚本已经非常强大了。但是出现如【四、坑1】这类的低端问题,真的不太应该。

只能用nginx,对我们这种apache专业户也不太实用。我打算一键安装完,再手动去修改成apache反向代理。这里也不细说了。

  Your Seafile server is installed
  -----------------------------------------------------------------

  Server Address:      http://pan.imoke.org

  Seafile Admin:       admin@imoke.org
  Admin Password:      roh1Zeig

  Seafile Data Dir:    /opt/seafile/seafile-data

  Seafile DB Credentials:  Check /opt/seafile.my.cnf
  Root DB Credentials:     Check /root/.my.cnf

  This report is also saved to /opt/seafile/aio_seafile-server.log



  Next you should manually complete the following steps
  -----------------------------------------------------------------

  1) Log in to Seafile and configure your server domain via the system
     admin area if applicable.

  2) If this server is behind a firewall, you need to ensure that
     tcp port 80 is open.

  3) Seahub tries to send emails via the local server. Install and
     configure Postfix for this to work or
     check https://cloud.seafile.com/published/seafile-manual-cn/config/sending_email.md
     for instructions on how to use an existing email account via SMTP.




  Optional steps
  -----------------------------------------------------------------

  1) Check seahub_settings.py and customize it to fit your needs. Consult
     https://cloud.seafile.com/published/seafile-manual-cn/config/seahub_settings_py.md
     for possible switches.

  2) Setup NGINX with official SSL certificate.

  3) Secure server with iptables based firewall. For instance: UFW or shorewall

  4) Harden system with port knocking, fail2ban, etc.

  5) Enable unattended installation of security updates. Check
     https://wiki.Ubuntu.org/UnattendedUpgrades for details.

  6) Implement a backup routine for your Seafile server.

  7) Update NGINX worker processes to reflect the number of CPU cores.




  Seafile support options
  -----------------------------------------------------------------

  For free community support visit:   https://bbs.seafile.com
  For paid commercial support visit:  https://seafile.com

[root@Seafile opt]#
除非注明,发表在“傲孤漠客”的文章『202010041452 记Seafile-pro-server-7.1.7一键脚本部署(国庆节快乐)』版权归iMoke所有。 转载请注明出处为“本文转载于『傲孤漠客』原地址https://www.imoke.org/post/20201004271.html

评论

发表评论   

昵称*

E-mail*(建议输入,以便收到博主回复的提示邮件)

网站

  • 访客
    • 访客  POST:2021-04-12 14:54:18 与TA同吐槽
    • 官方一键脚本获取拒绝链接是什么问题