Seafile - 个人/团队/公司专属私有文件同步服务搭建

因为我本人曾参与过基于本开源应用的云存储应用的开发,时过一年,看到开源的版本已经走了很远,所以来探测一番新功能,并从中学习学习(安装后大部分源码都可以看到)

Seafile 是一款开源的企业云盘,注重可靠性和性能。支持 Windows, Mac, Linux, iOS, Android 平台。支持文件同步或者直接挂载到本地访问。——来自官网

以下操作平台为rhel7.2 x86_64bit
部署 Seafile 服务器(使用 SQLite)

1.下载

官网->下载->服务器端
Seafile - 个人/团队/公司专属私有文件同步服务搭建_第1张图片

2. 部署和目录结构

假设你公司的名称为”seahub”,你也已经下载seafile-server_6.2.2_x86-64.tar.gz到你的home 目录下。 我们建议使用这样的目录结构:

mkdir seahub
mv seafile-server_* seahub
cd seahub
 #将 seafile-server_* 移动到 seahub 目录下后
tar -xzf seafile-server_*
mkdir installed
mv seafile-server_* installed

以上操作使得你的目录看起来类似以下:

[root@lockey41 seahub]# tree . -L 2

.
├── installed
│   └── seafile-server_6.2.2_x86-64.tar.gz
└── seafile-server-6.2.2
    ├── 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

6 directories, 11 files

这样设计目录的好处在于

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

3. 安装 Seafile 服务器

安装 Seafile 服务器之前,请确认已安装以下软件

python 2.7
python-setuptools
python-imaging
python-ldap
python-urllib3
sqlite3

on rhel7/CentOS 7

yum -y install epel-release
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
yum -y install python-imaging MySQL-python python-memcached python-ldap python-urllib3 ffmpeg ffmpeg-devel
pip install pillow moviepy

开始安装

cd seafile-server-*
./setup-seafile.sh #运行安装脚本并回答预设问题

如果你的系统中没有安装上面的某个软件,那么 Seafile 初始化脚本会提醒你安装相应的软件包。 该脚本会依次询问你一些问题,从而一步步引导你配置 Seafile 的各项参数。

Seafile - 个人/团队/公司专属私有文件同步服务搭建_第2张图片

如果安装正确完成,会打印成功消息

[root@lockey41 seafile-server-6.2.2]# ./setup-seafile.sh
-----------------------------------------------------------------
This script will guide you to config and setup your seafile server.

Make sure you have read seafile server manual at 

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

Note: This script will guide your to setup seafile server using sqlite3,
which may have problems if your disk is on a NFS/CIFS/USB.
In these cases, we sugguest you setup seafile server using MySQL.

Press [ENTER] to continue
-----------------------------------------------------------------


Checking packages needed by seafile ...

Checking python on this machine ...
Find python: python2.7

  Checking python module: setuptools ... Done.
  Checking python module: python-imaging ... Done.
  Checking python module: python-sqlite3 ... Done.

Checking for sqlite3 ...Done.

Checking Done.


What would you like to use as the name of this seafile server?
Your seafile users will be able to see the name in their seafile client.
You can use a-z, A-Z, 0-9, _ and -, and the length should be 3 ~ 15
[server name]: Lockey23

What is the ip or domain of this server?
For example, www.mycompany.com, or, 192.168.1.101

[This server's ip or domain]: 192.168.0.41

Where would you like to store your seafile data? 
Note: Please use a volume with enough free space.
[default: /root/seahub/seafile-data ] 

What tcp port do you want to use for seafile fileserver?
8082 is the recommended port.
[default: 8082 ] 


This is your config information:

server name:        Lockey23
server ip/domain:   192.168.0.41
seafile data dir:   /root/seahub/seafile-data
fileserver port:    8082

If you are OK with the configuration, press [ENTER] to continue.

Generating ccnet configuration in /root/seahub/ccnet...

done
Successly create configuration dir /root/seahub/ccnet.

Generating seafile configuration in /root/seahub/seafile-data ...

Done.

-----------------------------------------------------------------
Seahub is the web interface for seafile server.
Now let's setup seahub configuration. Press [ENTER] to continue
-----------------------------------------------------------------


Creating seahub database now, it may take one minute, please wait... 


Done.

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


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

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

-----------------------------------------------------------------
If the server is behind a firewall, remember to open these tcp ports:
-----------------------------------------------------------------

port of seafile fileserver:   8082
port of seahub:               8000

When problems occur, refer to

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

for more information.

启动运行 Seafile 服务器

在 seafile-server-1.4.0 目录下,运行如下命令:

启动 Seafile:

   ./seafile.sh start # 启动 Seafile 服务

启动 Seahub

  ./seahub.sh start  # 启动 Seahub 网站 (默认运行在8000端口上)

小贴士: 你第一次启动 seahub 时,seahub.sh 脚本会提示你创建一个 seafile 管理员帐号。

[root@lockey41 seafile-server-6.2.2]# ./seahub.sh start

LC_ALL is not set in ENV, set to en_US.UTF-8
Starting seahub at port 8000 ...

----------------------------------------
It's the first time you start the seafile server. Now let's create the admin account
----------------------------------------

What is the email for the admin account?
[ admin email ] [email protected]

What is the password for the admin account?
[ admin password ] 

Enter the password again:
[ admin password again ] 


----------------------------------------
Successfully created seafile admin
----------------------------------------


Seahub is started

Done.

4. 测试服务器是否正常运行

http://192.168.0.41:8000/

你会被重定向到登陆页面。输入你在之前创建的 Seafile 管理员帐号的用户名/密码即可。
Seafile - 个人/团队/公司专属私有文件同步服务搭建_第3张图片

登录成功后:
Seafile - 个人/团队/公司专属私有文件同步服务搭建_第4张图片

如果你不想在默认的 8000 端口上运行 Seahub, 而是想自定义端口(比如8001)中运行,请按以下步骤操作:

关闭 Seafile 服务器

  ./seahub.sh stop # 停止 Seafile 进程
  ./seafile.sh stop # 停止 Seahub

更改seahub/conf/ccnet.conf文件中SERVICE_URL 的值(假设你的 ip 或者域名时192.168.0.41), 如下 (从 5.0 版本开始,可以直接在管理员界面中设置。注意,如果同时在 Web 界面和配置文件中设置了这个值,以 Web 界面的配置为准。):

  SERVICE_URL = http://192.168.0.41:8001

重启 Seafile 服务器

  ./seafile.sh start # 启动 Seafile 服务
  ./seahub.sh start 8001 # 启动 Seahub 网站 (运行在8001端口上)

关闭/重启 Seafile 和 Seahub
关闭

./seahub.sh stop # 停止 Seahub
./seafile.sh stop # 停止 Seafile 进程

重启

./seafile.sh restart # 停止当前的 Seafile 进程,然后重启 Seafile
./seahub.sh restart  # 停止当前的 Seahub 进程,并在 8000 端口重新启动 Seahub

如果停止/重启的脚本运行失败

大多数情况下 seafile.sh seahub.sh 脚本可以正常工作。如果遇到问题:

使用 pgrep 命令检查 seafile/seahub 进程是否还在运行中

  pgrep -f seafile-controller # 查看 Seafile 进程
  pgrep -f "seahub" # 查看 Seahub 进程

使用 pkill 命令杀掉相关进程

pkill -f seafile-controller # 结束 Seafile 进程
pkill -f "seahub" # 结束 Seafile 进程

5. 下篇预告

  • 用户管理,系统管理
  • 资料创建,资料库创建
  • 文件共享
  • 文件以及文件夹上传
  • 资料和库管理
  • 共享管理,etc

Seafile - 个人/团队/公司专属私有文件同步服务搭建_第5张图片

你可能感兴趣的:(运维,网络)