优米格
分享有营养的

CentOS 7搭建seafile服务端(远程连接mysql数据库)

BraUndress.png

环境准备

  • CentOS Linux release 7.6.1810 (Core);
  • seafile-server_7.0.4_x86-64.tar.gz;
  • 远程数据库为mysql community 8.0.17;

1.新建目录

在合适的位置(这里为/home/inspur/),创建一个假设叫netdisk的目录,然后接下来将seafile相关的文件都放在这个目录。

2.下载服务端文件

下载地址:https://www.seafile.com/download/

创建/home/inspur/netdisk/installed目录,将下载好的seafile-server_7.0.4_x86-64.tar.gz文件放在这个目录

3.解压

tar xzvf ./seafile-server_7.0.4_x86-64.tar.gz -C ../

现在的目录结构:

netdisk
├── installed
│   └── seafile-server_1.8.2_x86-64.tar.gz
└── seafile-server_7.0.4
    ├── check_init_admin.py
    ├── reset-admin.sh
    ├── runtime
    ├── seaf-fsck.sh
    ├── seaf-fuse.sh
    ├── seaf-gc.sh
    ├── seafile
    ├── seafile.sh
    ├── seahub
    ├── seahub.sh
    ├── setup-seafile-mysql.py
    ├── setup-seafile-mysql.sh
    ├── setup-seafile.sh
    └── upgrade

这样设计目录的好处:

  • 和seafile相关的配置文件都可以放在netdisk目录下,便于集中管理。
  • 后续升级时,你只需要解压最新的安装包到netdisk目录下。

4.安装环境依赖

如果你远程数据库为mysql 8.0.17,则需要安装以下依赖:

mysql-community-libs-8.0.17-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.17-1.el7.x86_64.rpm
mysql-community-common-8.0.17-1.el7.x86_64.rpm
MySQL-python-1.2.5-1.el7.x86_64.rpm

可以使用rpm –qa命令查看安装没,安装过的就可以跳过了。

rpm –ivh mysql-community-*
rpm –ivh  MySQL-python-1.2.5-1.el7.x86_64.rpm

如果你的是mariadb,则需要安装mariadb对应的版本依赖即可。

5.安装seafile服务端

1)创建相关数据库和用户

可以事先创建好数据库,也可以安装过程中,根据安装脚本的提示进行创建,这里先创建好三个数据库,安装的过程中直接输入即可。
假设三个数据库的名字分别为ccnet-dbseafile-dbseahub-db

由于seafile不能使用root数据库用户,因此之前先创建一个seafile数据库用户,并赋予远程连接权限。

CREATE USER 'seafile' IDENTIFIED BY 'Passw0rd';
GRANT ALL ON *.* TO 'seafile'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
ALTER USER 'seafile'@'%' IDENTIFIED WITH mysql_native_password BY 'Passw0rd';

我用的是mysql 8所以赋权方式有所不同,具体参考:mysql创建用户及赋予权限

2)执行安装

[inspur@localhost seafile-server-7.0.4]$ ./setup-seafile-mysql.sh 
Checking python on this machine ...
  Checking python module: python-mysqldb ... Done.

-----------------------------------------------------------------
This script will guide you to setup your seafile server using MySQL.
Make sure you have read seafile server manual at

        https://github.com/haiwen/seafile/wiki

Press ENTER to continue
-----------------------------------------------------------------

What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ] seafile

What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] 10.47.0.172

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/home/inspur/netdisk/seafile-data" ] 

Which port do you want to use for the seafile fileserver?
[ default "8082" ] 

-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------

[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases

[ 1 or 2 ] 2

What is the host of mysql server?
[ default "localhost" ] 10.47.0.238

From which hosts could the mysql account be used?
[ default "%" ] 

What is the port of mysql server?
[ default "3306" ] 

Which mysql user to use for seafile?
[ mysql user for seafile ] seafile

What is the password for mysql user "seafile"?
[ password for seafile ] 

verifying password of user seafile ...  done

Enter the existing database name for ccnet:
[ ccnet database ] ccnet-db

verifying user "seafile" access to database ccnet-db ...  done

Enter the existing database name for seafile:
[ seafile database ] seafile-db

verifying user "seafile" access to database seafile-db ...  done

Enter the existing database name for seahub:
[ seahub database ] seahub-db

verifying user "seafile" access to database seahub-db ...  done

---------------------------------
This is your configuration
---------------------------------

    server name:            seafile
    server ip/domain:       10.47.0.172

    seafile data dir:       /home/inspur/netdisk/seafile-data
    fileserver port:        8082

    database:               use existing
    ccnet database:         ccnet-db
    seafile database:       seafile-db
    seahub database:        seahub-db
    database user:          seafile

---------------------------------
Press ENTER to continue, or Ctrl-C to abort
---------------------------------

Generating ccnet configuration ...

done
Successly create configuration dir /home/inspur/netdisk/ccnet.
Generating seafile configuration ...

Done.
done
Generating seahub configuration ...

----------------------------------------
Now creating ccnet database tables ...

----------------------------------------
----------------------------------------
Now creating seafile database tables ...

----------------------------------------
----------------------------------------
Now creating seahub database tables ...

----------------------------------------

creating seafile-server-latest symbolic link ...  done

-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------

run seafile server:     ./seafile.sh { start | stop | restart }
run seahub  server:     ./seahub.sh  { start <port> | stop | restart <port> }

-----------------------------------------------------------------
If you are behind a firewall, remember to allow input/output of these tcp ports:
-----------------------------------------------------------------

port of seafile fileserver:   8082
port of seahub:               8000

When problems occur, Refer to

        https://github.com/haiwen/seafile/wiki

for information.

6.启动服务

  • 启动 Seafile:
./seafile.sh start
  • 启动 Seahub
./seahub.sh start 8000 (这里8000是访问的端口,默认是8000,你可以改为自己想要的端口)

启动过程中会让你输入管理员账号邮箱和密码。

7.测试浏览

然后打开浏览器,使用204.48.24.202:8000进行访问,账号是你前面输入的邮箱,密码是自己设置的密码。

开机自启

需要编辑两个文件,分别是seafile服务文件:/etc/systemd/system/seafile.service和seahub服务文件/etc/systemd/system/seahub.service

1.配置seafile服务

编辑文件/etc/systemd/system/seafile.service,内容如下:

[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
After=network.target

[Service]
Type=oneshot
ExecStart=/home/inspur/netdisk/seafile-server-7.0.4/seafile.sh start
ExecStop=/home/inspur/netdisk/seafile-server-7.0.4/seafile.sh stop
RemainAfterExit=yes
User=inspur
Group=inspur

[Install]
WantedBy=multi-user.target

/home/inspur/netdisk/seafile-server-7.0.4/修改为自己的路径。

2.配置seahub服务

编辑文件/etc/systemd/system/seahub.service内容如下:

[Unit]
Description=Seafile hub
After=network.target seafile.service

[Service]
# change start to start-fastcgi if you want to run fastcgi
ExecStart=/home/inspur/netdisk/seafile-server-7.0.4/seahub.sh start
ExecStop=/home/inspur/netdisk/seafile-server-7.0.4/seahub.sh stop
User=root
Group=root
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

此服务配置root用户。

3.启动服务

启动:

sudo systemctl start seafile.service
sudo systemctl start seahub.service

设置开机自启:

sudo systemctl enable seafile.service
sudo systemctl enable seahub.service

其他问题

1.启动seafile服务后,只能在本地访问,其他机器无法访问?

解决方式:修改conf/gunicorn.conf文件,将bind = "127.0.0.1:8000"修改为bind = "0.0.0.0:8000"

此系列的其他文章

  1. Centos 7基于seafile搭建个人网盘服务端(mysql环境)
  2. Centos 7基于seafile离线搭建个人网盘服务端(mariadb环境)
  3. Seafile Java API接口实现示例
  4. CentOS 7搭建seafile服务端(远程连接mysql数据库)
赞(0)
未经允许禁止转载:优米格 » CentOS 7搭建seafile服务端(远程连接mysql数据库)

评论 抢沙发

合作&反馈&投稿

商务合作、问题反馈、投稿,欢迎联系

广告合作侵权联系