docker+seafile+maridb部署

docker+seafile+mysql部署

==備注==:默認(rèn)構(gòu)建的鏡像maridb不允許外部連接轩缤,需要修改maridb啟動(dòng)腳本構(gòu)建本地鏡像

本次部署包括初次安裝和升級(jí)版本怀浆,升級(jí)版本從6.0.9升級(jí)到6.1.1恬叹,maridb默認(rèn)已經(jīng)集成到docker鏡像里面腹躁,建議使用默認(rèn)的maridb退个,如果使用外部mysql募壕,升級(jí)很麻煩,升級(jí)過程可能存在數(shù)據(jù)庫(kù)結(jié)構(gòu)的變化语盈。

操作步驟

  • 更新構(gòu)建seafile代碼庫(kù)
[root@localhost var]# git clone https://github.com/haiwen/seafile-docker.git /var/seafile/
正克隆到 '/var/seafile'...
remote: Counting objects: 652, done.
remote: Total 652 (delta 0), reused 0 (delta 0), pack-reused 652
接收對(duì)象中: 100% (652/652), 110.65 KiB | 143.00 KiB/s, done.
處理 delta 中: 100% (362/362), done.
[root@localhost var]# 

  • 代碼庫(kù)目前最新版本是6.1.1舱馅,因?yàn)楹竺嬉v升級(jí)操作,所以先把版本切換到6.0.9刀荒,然后再升級(jí)到6.1.1
[root@localhost var]# cd seafile/    #切換到代碼目錄
[root@localhost seafile]# git tag   # 參看標(biāo)簽版本
v6.0.7
v6.0.9
v6.1.1
[root@localhost seafile]# git checkout v6.0.9 #切換到v6.0.9
Note: checking out 'v6.0.9'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD 目前位于 5f89412... Updated to seafile server 6.0.9
[root@localhost seafile]# git status #查看當(dāng)前代碼庫(kù)的標(biāo)簽版本
# 頭指針分離于 v6.0.9
無(wú)文件要提交习柠,干凈的工作區(qū)
[root@localhost seafile]# 

  • 復(fù)制服務(wù)配置文件到bootstrap目錄匀谣,根據(jù)需求,修改配置文件內(nèi)容
[root@localhost seafile]# pwd
/var/seafile
[root@localhost seafile]# cp samples/server.conf bootstrap/bootstrap.conf
[root@localhost seafile]# ls -la bootstrap/
總用量 8
drwxr-xr-x.  2 root root   44 10月 10 11:00 .
drwxr-xr-x. 11 root root 4096 10月 10 10:54 ..
-rw-r--r--.  1 root root  351 10月 10 11:00 bootstrap.conf
-rwxr-xr-x.  1 root root    0 10月 10 10:52 .gitkeep
[root@localhost seafile]# 
[root@localhost seafile]# cat bootstrap/bootstrap.conf 
# If you edit this file, remember to run ./launcher rebuild
[server]
server.hostname = seafile.example.com #修改主機(jī)名為服務(wù)器的ip地址
admin.email = me@example.com #修改管理員郵件
admin.password = asecret #修改管理員密碼

# Comment out this line and uncomment the two lines below to use letsencrypt SSL certificate
server.port_mappings = 80:80 #nginx端口映射资溃,mysql端口映射
# server.letsencrypt = true
# server.port_mappings = 80:80,443:443
[root@localhost seafile]# 
#修改后的內(nèi)容如下

[root@localhost seafile]# cat bootstrap/bootstrap.conf 
# If you edit this file, remember to run ./launcher rebuild
[server]
server.hostname = 192.168.100.196
admin.email = huangmeng4520@163.com
admin.password = password

# Comment out this line and uncomment the two lines below to use letsencrypt SSL certificate
server.port_mappings = 80:80,3316:3306
# server.letsencrypt = true
# server.port_mappings = 80:80,443:443
[root@localhost seafile]# 


  • 修改maridb啟動(dòng)腳本和dockerfile默認(rèn)的模板武翎,目的讓外部能夠訪問maridb
# /var/seafile/templates/Dockerfile.template 文件最后增加如下內(nèi)容
&& \
   cat /app/image/base/services/mysql.sh > /etc/service/mysql/run
#maridb啟動(dòng)腳本增加 --bind-address=0.0.0.0
/var/seafile/image/base/services/mysql.sh文件內(nèi)容修改如下

/sbin/setuser mysql /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --skip-log-error --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock  --bind-address=0.0.0.0 --port=3306 >/var/log/mysql.log 2>&1

  • 執(zhí)行構(gòu)建seafile本地docker鏡像,此過程先pull seafile基礎(chǔ)鏡像(seafileltd/seafile 6.0.9)溶锭,然后創(chuàng)建數(shù)據(jù)庫(kù)目錄宝恶,初始化數(shù)據(jù)庫(kù),構(gòu)建本地seafile鏡像(local_seafile/server latest)
[root@localhost seafile]# ./launcher bootstrap
[2017-10-09 15:19:00] Pulling Seafile server image 6.0.9, this may take a while.
6.0.9: Pulling from seafileltd/seafile # 1趴捅、pull6.0.9版本基礎(chǔ)鏡像
f069f1d21059: Pull complete 
ecbeec5633cf: Pull complete 
ea6f18256d63: Pull complete 
54bde7b02897: Pull complete 
a3ed95caeb02: Pull complete 
ce9e695a6234: Pull complete 
346026b9659b: Pull complete 
5416dcf47cda: Pull complete 
5822c8cc29ab: Pull complete 
d96fa9a845b5: Pull complete 
867a50b477be: Pull complete 
d4a99a640cd4: Pull complete 
Digest: sha256:38ec596f3a6fbcf03a17ab8a62fdcd413fb3247ae66ebaa97b0b07d93bd6079c
Status: Downloaded newer image for seafileltd/seafile:6.0.9
[2017-10-09 15:27:46] Seafile server image 6.0.9 pulled. Now bootstrapping the server ...
Rebuilding mysql data dir #構(gòu)建mysql數(shù)據(jù)庫(kù)存儲(chǔ)目錄
Starting mysqld
Waiting for mysqld to come online
Fixing root password
Shutting down mysqld
[2017-10-09 07:28:04] Generating local Dockerfile ... #構(gòu)建本地docker images
[2017-10-09 07:28:06] Now running setup-seafile-mysql.py in auto mode.
Checking python on this machine ...
  Checking python module: setuptools ... Done.
  Checking python module: python-imaging ... Done.
  Checking python module: python-mysqldb ... Done.


verifying password of user root ...  
verifying password of user root ...  done

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

    server name:            seafile
    server ip/domain:       seafile.example.com

    seafile data dir:       /opt/seafile/seafile-data
    fileserver port:        8082

    database:               create new
    ccnet database:         ccnet_db
    seafile database:       seafile_db
    seahub database:        seahub_db
    database user:          seafile


Generating ccnet configuration ...

done
Successly create configuration dir /opt/seafile/ccnet.
Generating seafile configuration ...

Done.
done
Generating seahub configuration ...

----------------------------------------
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.


[2017-10-09 07:28:33] Updating version stamp
[2017-10-09 07:28:33] Generated local config.
[2017-10-09 15:28:37] Now building the local docker image.
[2017-10-09 15:28:48] Image built.


[root@localhost seafile]# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
local_seafile/server   latest              d6289863c8b5        31 seconds ago      824MB
seafileltd/seafile     6.0.9               0d630bc508cc        4 months ago        823MB
[root@localhost seafile]#  


  • 啟動(dòng)seafile服務(wù)
[root@localhost seafile]# ./launcher -v start
[2017-10-10 11:22:58] [debug] Your version: 6.0.9, latest version: 6.0.9
[2017-10-10 11:22:59] Starting up new seafile server container
+ docker run -d --name seafile -h seafile -e SEAFILE_DOCKER_VERBOSE=true -v /var/seafile/shared:/shared -v /var/seafile/shared/logs/var-log:/var/log -v /var/seafile/shared/db:/var/lib/mysql -v /var/seafile/shared/.bash_history:/root/.bash_history -p 80:80 -p 3316:3306 local_seafile/server:latest
fafcbd53bbb6af27eb2d882b6c39960534bd83c8841ad16a21ff9d3954f3037f
[root@localhost seafile]# 


  • 默認(rèn)maridb不支持root遠(yuǎn)程連接垫毙,可以通過一下操作外部訪問
[root@localhost seafile]# docker exec -it seafile bash #進(jìn)入容器命令
root@seafile:/opt/seafile# mysql #登陸mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.0.27-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; #授權(quán)root遠(yuǎn)程登陸和設(shè)置密碼
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> 

此時(shí)可以通過宿主機(jī)ip+3316端口登陸mysql(3個(gè)庫(kù)ccnet_db,seafile_db,seahub_db)

目錄結(jié)構(gòu)

[root@localhost shared]# pwd
/var/seafile/shared
[root@localhost shared]# tree -L 2
.
├── db #數(shù)據(jù)庫(kù)存儲(chǔ)目錄
│   ├── aria_log.00000001
│   ├── aria_log_control
│   ├── ccnet_db
│   ├── ibdata1
│   ├── ib_logfile0
│   ├── ib_logfile1
│   ├── multi-master.info
│   ├── mysql
│   ├── performance_schema
│   ├── seafile_db
│   └── seahub_db
├── logs #日志文件目錄
│   ├── seafile
│   └── var-log
└── seafile 
    ├── ccnet #配置文件
    ├── conf   # 配置文件
    ├── seafile-data # 數(shù)據(jù)存儲(chǔ)目錄
    └── seahub-data #數(shù)據(jù)存儲(chǔ)目錄

14 directories, 6 files
[root@localhost shared]#

升級(jí)seafile(6.0.9->6.1.1)

為了保證升級(jí)逼真,先在目前的6.0.9版本中創(chuàng)建幾個(gè)用戶拱绑,上傳一些文件综芥。

  • 切換git庫(kù)到v6.1.1版本
[root@localhost seafile]# git checkout v6.1.1
警告:您正丟下 1 個(gè)提交,未和任何分支關(guān)聯(lián):

  cfcbfaa xiuga

如果您想要通過創(chuàng)建新分支保存他們猎拨,這可能是一個(gè)好時(shí)候膀藐。
如下操作:

 git branch new_branch_name cfcbfaa

HEAD 目前位于 6333307... docker image: move up infrequently-changed layers
[root@localhost seafile]# git status
# 頭指針分離于 v6.1.1
無(wú)文件要提交,干凈的工作區(qū)
[root@localhost seafile]# 

  • 修改maridb啟動(dòng)腳本和dockerfile默認(rèn)的模板红省,目的讓外部能夠訪問maridb
# /var/seafile/templates/Dockerfile.template 文件最后增加如下內(nèi)容
&& \
   cat /app/image/base/services/mysql.sh > /etc/service/mysql/run
#maridb啟動(dòng)腳本增加 --bind-address=0.0.0.0
/var/seafile/image/base/services/mysql.sh文件內(nèi)容修改如下

/sbin/setuser mysql /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --skip-log-error --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock  --bind-address=0.0.0.0 --port=3306 >/var/log/mysql.log 2>&1

  • 執(zhí)行升級(jí)命令
[root@localhost seafile]# ./launcher -v rebuild
fatal: ref HEAD is not a symbolic ref
[2017-10-10 11:42:33] Stopping old container
+ docker stop -t 10 seafile
seafile
*** Running /etc/my_init.d/99_mysql_setup.sh...
*** Running /etc/my_init.d/create_data_links.sh...
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 10
*** Running /scripts/bootstrap.py...
[2017-10-10 03:42:37] Generating local Dockerfile ...
[2017-10-10 03:42:37] [debug] waiting for mysql server to be ready
[2017-10-10 03:42:39] [debug] mysql server is ready
[2017-10-10 03:42:39] Skip running setup-seafile-mysql.py because there is existing seafile-data folder.
[2017-10-10 03:42:39] Generated local config.
*** /scripts/bootstrap.py exited with status 0.
*** Shutting down runit daemon (PID 10)...
*** Killing all processes...
[2017-10-10 11:42:42] Now building the local docker image.
[2017-10-10 11:42:49] Image built.
[2017-10-10 11:42:49] Rebuilt successfully.
[2017-10-10 11:42:49] Removing old container
+ docker rm seafile
seafile
[2017-10-10 11:42:49] Checking if there is major version upgrade
[2017-10-10 11:42:49] ********************************
[2017-10-10 11:42:49] Major upgrade detected: You have 6.0.9, latest is 6.1.1
[2017-10-10 11:42:49] ********************************
[2017-10-10 11:42:49] Going to launch the docker container for manual upgrade
+ docker run -it --rm --name seafile-upgrade -h seafile -e SEAFILE_DOCKER_VERBOSE=true -v /var/seafile/shared:/shared -v /var/seafile/shared/logs/var-log:/var/log -v /var/seafile/shared/db:/var/lib/mysql -v /var/seafile/shared/.bash_history:/root/.bash_history local_seafile/server:latest /sbin/my_init -- /scripts/upgrade.py
*** Running /etc/my_init.d/99_mysql_setup.sh...
*** Running /etc/my_init.d/create_data_links.sh...
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 21
*** Running /scripts/upgrade.py...
[2017-10-10 03:42:50] [debug] waiting for mysql server to be ready
[2017-10-10 03:42:52] [debug] mysql server is ready
[2017-10-10 03:42:52] Running scripts /opt/seafile/seafile-server-6.1.1/upgrade/upgrade_6.0_6.1.sh

-------------------------------------------------------------
This script would upgrade your seafile server from 6.0 to 6.1
Press [ENTER] to contiune
-------------------------------------------------------------


Updating seafile/seahub database ... #自動(dòng)更新數(shù)據(jù)庫(kù)

[INFO] You are using MySQL
[INFO] updating seahub database...
Done

migrating avatars ...

Done

updating /opt/seafile/seafile-server-latest symbolic link to /opt/seafile/seafile-server-6.1.1 ...



-----------------------------------------------------------------
Upgraded your seafile server successfully.
-----------------------------------------------------------------

*** /scripts/upgrade.py exited with status 0.
*** Shutting down runit daemon (PID 21)...
*** Killing all processes...
[2017-10-10 11:42:58] [debug] Your version: 6.1.1, latest version: 6.1.1
[2017-10-10 11:42:59] Starting up new seafile server container
+ docker run -d --name seafile -h seafile -e SEAFILE_DOCKER_VERBOSE=true -v /var/seafile/shared:/shared -v /var/seafile/shared/logs/var-log:/var/log -v /var/seafile/shared/db:/var/lib/mysql -v /var/seafile/shared/.bash_history:/root/.bash_history -p 80:80 -p 3316:3306 local_seafile/server:latest
0375d08222b6031562eb6b296090fd39ea034007a601e51aa6b6debb0056516c
[2017-10-10 11:42:59] Your seafile server is now running.
[root@localhost seafile]# 

  • 訪問seafile服務(wù)器额各,驗(yàn)證文件是否丟失
  • 升級(jí)之前最好備份下數(shù)據(jù)庫(kù)和存儲(chǔ)數(shù)據(jù)

連接外部mysql

修改配置文件下面的mysql連接

[root@localhost conf]# pwd
/var/seafile/shared/seafile/conf
[root@localhost conf]# tree 
.
├── ccnet.conf #修改mysql連接
├── seafdav.conf
├── seafile.conf #修改mysql連接
├── seahub_settings.py #修改mysql連接
└── seahub_settings.pyc

0 directories, 5 files
[root@localhost conf]# 

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市吧恃,隨后出現(xiàn)的幾起案子虾啦,更是在濱河造成了極大的恐慌,老刑警劉巖痕寓,帶你破解...
    沈念sama閱讀 210,914評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件傲醉,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡呻率,警方通過查閱死者的電腦和手機(jī)需频,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 89,935評(píng)論 2 383
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來筷凤,“玉大人,你說我怎么就攤上這事苞七∶晔兀” “怎么了?”我有些...
    開封第一講書人閱讀 156,531評(píng)論 0 345
  • 文/不壞的土叔 我叫張陵蹂风,是天一觀的道長(zhǎng)卢厂。 經(jīng)常有香客問我,道長(zhǎng)惠啄,這世上最難降的妖魔是什么慎恒? 我笑而不...
    開封第一講書人閱讀 56,309評(píng)論 1 282
  • 正文 為了忘掉前任任内,我火速辦了婚禮,結(jié)果婚禮上融柬,老公的妹妹穿的比我還像新娘死嗦。我一直安慰自己,他們只是感情好粒氧,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,381評(píng)論 5 384
  • 文/花漫 我一把揭開白布越除。 她就那樣靜靜地躺著,像睡著了一般外盯。 火紅的嫁衣襯著肌膚如雪摘盆。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,730評(píng)論 1 289
  • 那天饱苟,我揣著相機(jī)與錄音孩擂,去河邊找鬼。 笑死箱熬,一個(gè)胖子當(dāng)著我的面吹牛类垦,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播坦弟,決...
    沈念sama閱讀 38,882評(píng)論 3 404
  • 文/蒼蘭香墨 我猛地睜開眼护锤,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了酿傍?” 一聲冷哼從身側(cè)響起烙懦,我...
    開封第一講書人閱讀 37,643評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎赤炒,沒想到半個(gè)月后氯析,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,095評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡莺褒,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,448評(píng)論 2 325
  • 正文 我和宋清朗相戀三年掩缓,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片遵岩。...
    茶點(diǎn)故事閱讀 38,566評(píng)論 1 339
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡你辣,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出尘执,到底是詐尸還是另有隱情舍哄,我是刑警寧澤,帶...
    沈念sama閱讀 34,253評(píng)論 4 328
  • 正文 年R本政府宣布誊锭,位于F島的核電站表悬,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏丧靡。R本人自食惡果不足惜蟆沫,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,829評(píng)論 3 312
  • 文/蒙蒙 一籽暇、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧饭庞,春花似錦戒悠、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,715評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至捏顺,卻和暖如春六孵,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背幅骄。 一陣腳步聲響...
    開封第一講書人閱讀 31,945評(píng)論 1 264
  • 我被黑心中介騙來泰國(guó)打工劫窒, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人拆座。 一個(gè)月前我還...
    沈念sama閱讀 46,248評(píng)論 2 360
  • 正文 我出身青樓主巍,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親挪凑。 傳聞我的和親對(duì)象是個(gè)殘疾皇子孕索,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,440評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容