
Seafile是一個開源、專業、可靠的云存儲平臺;解決文件集中存儲、共享和跨平臺訪問等問題,由北京海文互知網絡有限公司開發,發布于2012年10月;除了一般網盤所提供的云存儲以及共享功能外,Seafile還提供消息通信、群組討論等輔助功能,幫助更好的圍繞文件展開協同工作。---來源百度百科
網上有相關詳細教程,鏈接如下:
- 官網:詳情
- 部署 Seafile 服務器(使用 MySQL):https://ewgo.net/2016/05/21/371
- 官方文檔:部署 Seafile 服務器(使用 MySQL/MariaDB)
以下文章來源于:https://ewgo.net/2016/05/21/371
?下載
到下載頁面下載最新的服務器安裝包.
部署和目錄設計
假設你公司的名稱為 haiwen,你也已經下載 seafile-server_1.4.0_* 到你的 home 目錄下。 我們建議這樣的目錄結構:
- mkdir haiwen
- mv seafile-server_* haiwen
- cd haiwen
- #將 seafile-server_* 移動到 haiwen 目錄下后
- tar -xzf seafile-server_*
- mkdir installed
- mv seafile-server_* installed
復制代碼
現在,你的目錄看起來應該像這樣:
- #tree haiwen -L 2
- haiwen
- ├── installed
- │??└── seafile-server_1.8.2_x86-64.tar.gz
- └── seafile-server-1.8.2
- ??├── reset-admin.sh
- ??├── runtime
- ??├── seafile
- ??├── seafile.sh
- ??├── seahub
- ??├── seahub.sh
- ??├── setup-seafile.sh
- ??└── upgrade
復制代碼
這樣設計目錄的好處在于
- 和 seafile 相關的配置文件都可以放在 haiwen 目錄下,便于集中管理.
- 后續升級時,你只需要解壓最新的安裝包到 haiwen 目錄下.
這樣你可以重用 haiwen 目錄下已經存在的配置文件,而不用重新配置.
準備 MySQL 數據庫
Seafile 服務器有三個組件需要擁有自己的數據庫:
- ccnet server
- seafile server
- seahub
Seafile 服務器組件更多信息請看[[Seafile服務器組件概覽]].
有兩種方法可以初始化數據庫:
- 通過setup-seafile-mysql.sh腳本創建數據庫.
- 自己或其他人(比如數據庫管理員)創建
我們建議采用第一種方法. 腳本會要求你提供 MySQL 數據庫的的根密碼,之后創建:
- ccnet/seafile/seahub 數據庫
- 一個可以連接到這些數據庫的用戶
然而,有時你不得不使用第二種方法. 如果你沒有根密碼,你需要通過擁有這種權限的人(比如數據庫管理員)來幫助你創建三個數據庫,和一個能連接這三個數據庫的用戶. 例如,為 ccnet/seafile/seahub 分別創建如下三個數據庫: ccnet-db / seafile-db / seahub-db, 和一個可以連接這三個數據庫的 MySQL 用戶seafile:
- create database `ccnet-db` character set = ‘utf8’;
- create database `seafile-db` character set = ‘utf8’;
- create database `seahub-db` character set = ‘utf8’;
- ?
- create user ‘seafile’@’localhost’ identified by ‘seafile’;
- ?
- GRANT ALL PRIVILEGES ON `ccnet-db`.* to `seafile`;
- GRANT ALL PRIVILEGES ON `seafile-db`.* to `seafile`;
- GRANT ALL PRIVILEGES ON `seahub-db`.* to `seafile`;
復制代碼
安裝 Seafile 服務器
安裝前的準備工作
安裝 Seafile 服務器之前,請確認已安裝以下軟件
- python 2.7
- python-setuptools
- python-imaging
- python-mysqldb
- #在Debian/Ubuntu系統下
- apt-get update
- apt-get install python2.7 python-setuptools python-imaging python-mysqldb
復制代碼
安裝
- cd seafile-server-*
- ./setup-seafile-mysql.sh??#運行安裝腳本并回答預設問題
復制代碼
如果你的系統中沒有安裝上面的某個軟件,那么 Seafile初始化腳本會提醒你安裝相應的軟件包.
/1.png)
該腳本會依次詢問你一些問題,從而一步步引導你配置 Seafile 的各項參數
參數作用說明seafile server name
seafile 服務器的名字,將來在客戶端會顯示為這個名字
3 ~ 15 個字符,可以用英文字母,數字,下劃線
seafile server ip or domain
seafile 服務器的 IP 地址或者域名
客戶端將通過這個 IP 或者地址來訪問你的 Seafile 服務
ccnet server port
ccnet 使用的 TCP 端口
一般使用默認的10001 端口,如果已經被占用,可以設置為其他的端口
seafile data dir
seafile 數據存放的目錄,用上面的例子,默認將是 /data/haiwen/seafile-data
seafile 數據將隨著使用而逐漸增加,請把它放在一個有足夠大空閑空間的分區上
seafile server port
seafile 服務器 使用的 TCP 端口
一般使用默認的 12001 端口,如果已經被占用,可以設置為其他的端口
seafile fileserver port
seafile fileserver 使用的 TCP 端口
一般使用默認的 8082 端口,如果已經被占用,可以設置為其他的端口
seahub admin email
sehaub管理員的登錄帳戶名
使用一個 email 地址
seahub admin password
seahub 管理員的密碼
在這里, 你會被要求選擇一種創建 Seafile 數據庫的方式:
- ——————————————————-
- Please choose a way to initialize seafile databases:
- ——————————————————-
- ?
- [1] Create new ccnet/seafile/seahub databases
- [2] Use existing ccnet/seafile/seahub databases
復制代碼
具體選擇哪項, 取決于你是否擁有根密碼.
- 如果選擇1, 你需要提供根密碼. 腳本程序會創建數據庫和用戶。
- 如果選擇2, ccnet/seafile/seahub 數據庫應該已經被你(或者其他人)提前創建。
如果選擇 [1] Create new ccnet/seafile/seahub databases,你會被問三個問題:
/2.png)
QuestionDescriptionNotemysql server host
the host address of the mysql server
the default is localhost
mysql server port
the port of the mysql server
the default is 3306. Almost every mysql server uses this port.
root password
the password of mysql root account
the root password is required to create new databases and a new user
mysql user for seafile
the username for seafile programs to use to access MySQL server
if the user does not exist, it would be created
password for seafile mysql user
the password for the user above
?ccnet dabase name
the name of the database used by ccnet, default is “ccnet-db”
the database would be created if not existing
seafile dabase name
the name of the database used by seafile, default is “seafile-db”
the database would be created if not existing
seahub dabase name
the name of the database used by seahub, default is “seahub-db”
the database would be created if not existing
如果你選擇[2] Use existing ccnet/seafile/seahub databases, 你會被問到如下三個問題:
/3.png)
QuestionDescriptionNotemysql server host
the host address of the mysql server
the default is localhost
mysql server port
the port of the mysql server
the default is 3306. Almost every mysql server uses this port
mysql user for seafile
the user for seafile programs to use to access MySQL server
the user must already exists
password for seafile mysql user
the password for the user above
?ccnet dabase name
the name of the database used by ccnet
this database must already exist
seafile dabase name
the name of the database used by seafile, default is “seafile-db”
this database must already exist
seahub dabase name
the name of the database used by seahub, default is “seahub-db”
this database must already exist
如果安裝正確完成,你會看到下面這樣的輸出
/4.png)
現在你的目錄結構看起來應該是這樣:
- #tree haiwen -L 2
- haiwen
- ├── ccnet??????????# configuration files
- │??├── ccnet.conf
- │??├── mykey.peer
- │??├── PeerMgr
- │??└── seafile.ini
- ├── installed
- │??└── seafile-server_1.8.2_x86-64.tar.gz
- ├── seafile-data
- │??└── seafile.conf
- ├── seafile-server-1.8.2??# active version
- │??├── reset-admin.sh
- │??├── runtime
- │??├── seafile
- │??├── seafile.sh
- │??├── seahub
- │??├── seahub.sh
- │??├── setup-seafile.sh
- │??└── upgrade
- ├── seafile-server-latest??# symbolic link to seafile-server-1.8.2
- ├── seahub-data
- │??└── avatars
- ├── seahub_settings.py??# optional config file
- └── seahub_settings.pyc
復制代碼
seafile-server-latest文件夾為指向當前 Seafile 服務器文件夾的符號鏈接. 將來你升級到新版本后, 升級腳本會自動更新使其始終指向最新的 Seafile 服務器文件夾..
啟動 Seafile 服務器
啟動之前
因為 Seafile 在客戶端和服務器之間使用持續連接,如果你的客戶端數量巨大, 你應該在啟動 Seafile 之前修改你的 Linux 文件最大打開數,如下:
ulimit -n 30000
啟動 Seafile 服務器和 Seahub 網站
在 seafile-server-1.8.2 目錄下,運行如下命令
- 啟動 Seafile:
./seafile.sh start # 啟動 Seafile 服務
復制代碼
- 啟動 Seahub
./seahub.sh start <port>??# 啟動 Seahub 網站 (默認運行在8000端口上)
復制代碼
小貼士: 你第一次啟動 seahub 時,seahub.sh 腳本會提示你創建一個 seafile 管理員帳號。
服務啟動后, 打開瀏覽器并輸入以下地址
http://192.168.1.111:8000/
你會被重定向到登陸頁面. 輸入你在安裝 Seafile 時提供的用戶名和密碼后,你會進入 Myhome 頁面,新建資料庫.
恭喜! 現在你已經成功的安裝了 Seafile 服務器.
在另一端口上運行 Seahub
如果你不想在默認的 8000 端口上運行 Seahub, 而是想自定義端口(比如8001)中運行,請按以下步驟操作:
- 關閉 Seafile 服務器
./seahub.sh stop # 停止 Seafile 進程
./seafile.sh stop # 停止 Seahub
復制代碼
- 更改haiwen/ccnet/ccnet.conf文件中SERVICE_URL 的值(假設你的 ip 或者域名時192.168.1.100), 如下:
- SERVICE_URL = http://192.168.1.100:8001
復制代碼
- 重啟 Seafile 服務器
./seafile.sh start # 啟動 Seafile 服務
./seahub.sh start 8001 # 啟動 Seahub 網站 (運行在8001端口上)
復制代碼
ccnet.conf更多細節請看(server_configuration.md) .
關閉/重啟 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 “manage.py run_gunicorn” # 查看 Seahub 進程
復制代碼
- 使用pkill命令殺掉相關進程
pkill -f seafile-controller # 結束 Seafile 進程
pkill -f “manage.py run_gunicorn” # 結束 Seafile 進程
復制代碼
OK!