# 前言
Dropbox 被墙的不行, 有时候想同步个东西都不行,不得不同步点文件什么的,真是不方便,国内的各种某盘又不放心,就想到自己在树莓派架设私有云试试。
找了https://www.v2ex.com/t/47445这个帖子,提到了Seafile和sersync。看了这两个项目的介绍,其实sersync更符我要求,我基本不想要什么web,但是很久没更新了,而Seafile是公司在做,而且开源,感觉应该 不错,就选它来试试 。
# Seafile
Seafile 是一个面向团队的文件同步和协作平台 。 它有 Dropbox 类似的文件同步功能 , 但是针对团队文件同步和协作做了优化 .目前客户端支持所有主流平台 , 包括 Windows, Linux, Mac,Andoird 和 iOS。 服务器支持 Linux 平台 , 可以跑在 Raspberry Pi 平台上 。同时也是分布式
# Server 安装
所有安装包都可以在Seafile官方下载,这些我们下载Raspberry Pi 版本。
下载并解压
wget https://github.com/haiwen/seafile-rpi/releases/download/v4.2.2/seafile-server_4.2.2_pi.tar.gz
tar zxf seafile-server_4.2.2_pi.tar.gz
这里安装我们参照官方文档来
首先执行 1
yaourt -S python-setuptools python2-setuptools python2-imaging mysql-python
如果没安装 yaourt 请参考Raspberry Pi安装Archlinux后的一些配置
# 初始化数据库(mysql)
./setup-seafile-mysql.sh
按照提示会提示输入servername domain 端口默认,接着创建数据库一路回车默认就行了。
但是最后会出现错误:
/seafile-server/seafile/bin/ccnet-init: error while loading shared libraries: libselinux.so.1: cannot open shared object file: No such file or directory
Error: Failed to generate ccnet configuration
放狗找了半天,果然好几个都是安装seafile出现的这个,实际上就是缺少libselinux.so.1,那好我们就来安装libselinux.
# 安装libselinux
pacman是找不到这个包的,所以 我们用yaourt 从 AUR下载编译。
yaourt -S libselinux
这里如果 是root 会提示
Running makepkg as root is not allowed as it can cause permanent,
catastrophic damage to your system.
但是会提示依赖libsepol这个包,同样也是从AUR下载,但是编译这个包的时候又会提示错误:
ERROR: libsepol is not available for the 'armv6h' architecture.
Note that many packages may need a line added to their PKGBUILD
such as arch=('armv6h').
妈蛋,好坑,没有arm配置,放狗找了半天 也没找出结果http://archlinuxarm.org/forum/viewtopic.php?f=59&t=6673,既然没有, 我们就源码自己来编译吧。
# 编译libsepol
打开https://aur.archlinux.org/packages/libsepol/找到源代码下载,然后:
tar zxf libsepol-2.4
cd libsepol-2.4
make
make install
一切正常,然后我们又回到上一步继续安装libselinux 但是坑人的地方又出现了,还是提示没找到libsepol包, 这不是坑人嘛!!!!
那好,我们就源码编译libselinux 吧, 很可惜,Error:
compilation terminated.
Makefile:130: recipe for target 'load_policy.o' failed
make[1]: *** [load_policy.o] Error 1
继续放狗找,无果。
# 修改 PKGBUILD编译
既然 need a line added to their PKGBUILD such as arch=('armv6h'). 那么我们就ADD吧
下载PKGBUILD
wget https://aur.archlinux.org/packages/li/libsepol/libsepol.tar.gz
tar zxf libsepol.tar.gz
cd libsepol
vi PKGBUILD
在这里加入armv6h:
arch=('i686' 'x86_64' 'armv6h')
保存,然后执行:
makepkg -si
Good 安装成功,接着我们也可以同样的方法安装libselinux ,其实也可以用yaourt 安装
yaourt -S libselinux
再回去安装
$ ./setup-seafile-mysql.sh
安装完毕
# 启动 Seafile 服务器和 Seahub 网站
-
启动 Seafile:
./seafile.sh start # 启动 Seafile 服务
-
启动 Seahub
./seahub.sh start 8004 # 启动 Seahub 网站 (默认运行在8000端口上)
这里会提示输入管理账号和密码
- 打开网站,输入账号密码,登录就可以了:
在Pi上跑这个网站还是非常吃力的,启动都 要半天,够抽半只烟的时间了。4核版raspberry的应该 好多了。
# Client 安装使用
直接官方下载安装即可,非常简单。 打开就是这个界面。
登录后就可以使用了:
# 防火墙及开机启动
-
Seahub 8000
-
FileServer 8082
-
Ccnet Daemon 10001
-
Seafile Daemon 12001
开机启动这里参考 :http://blog.eldajani.net/banana-pi-arch-linux-seafile/
创建/usr/lib/systemd/system/seafile.service
[Unit]
Description=seafile
After=network.target mysqld.service
[Service]
Type=oneshot
RemainAfterExit=yes
User=seafile
ExecStart=/home/seafile/seafile-server-latest/seafile.sh start
ExecStart=/home/seafile/seafile-server-latest/seahub.sh start-fastcgi
ExecStop=/home/seafile/seafile-server-latest/seafile.sh stop
ExecStop=/home/seafile/seafile-server-latest/seahub.sh stop
[Install]
WantedBy=multi-user.target
然后 保存后设置
systemctl daemon-reload
systemctl enable seafile
systemctl start seafile
# 使用感受
客户端还是很全面的,我这里只使用了 Linux 下的。功能很全面,加密分享都有。但是短时间使用也发现了些小bug:
- 如果在网页端上传文件或删除文件后,有时候客户端不同步,有时候正常。
- 客户端的云浏览器上传文件失败,而直接拖文件夹(新的资料库)为正常。
- 当在云端删除了资料文件夹时,本地文件夹及文件不会删除,但是如果重新添该文件夹时会提示冲突,已经存在。
# 总结
Seafile是款非常好的开源软件 ,感谢作者及其团队开源给大众,通过放狗找资料的时候,发现该软件在国外使用量还是很大的。
它有 Dropbox 类似的文件同步功能 , 但是针对团队文件同步和协作做了优化 ,有账号管理,上传文件也不单纯的直接存储(有点像微信的手机图片那种方式,我是个盲,不懂),所以也不能直接同步服务器端的文件,必须通过客户端来操作才行。这跟我想要的还是有一点不一样。另外是分布式的架构,更稳定,而且同步算法更好。总体上是非常棒的。
参考地址: