本人当时搭建seafile的时候版本号是6.1.1现在版本更新到了6.3.4了,打算升级一下。文章脑袋思路不是特别有思路,写的不好希望理解。
简述一下:之前的seafile服务是搭建在192.168.1.102上的/home/seafile目录下的,之前的数据MySQL并没有放在这个机器上而是放在了192.168.1.103上。
新机器上部署原有环境(192.168.1.108)
在新机器上拉去之前的版本软件和数据
新机器上搭建原来seafile环境的常见错误1
2
3
4
5
6
7
8
9
10rsync -aP --exclude '*data' root@192.168.1.102:/home/seafile /home/
cd /home/seafile/
rm -rf ccnet/
rm seafile-server-latest
这个目录是一个软连接目录删除软连接目录的时候千万记得不要再软连接目录的后面加/不然删除的是真实目录下的所有文件
注意:删除这两个文件只为了在搭建环境的时候不出错,出现的错误提示我会放在下面
cd seafile-server-6.1.1
./setup-seafile-mysql.sh
运行安装脚本并回答预设问题- 提示缺少依赖环境,根据提示运行命令
- 上面我们使用rm命令删除ccnet如果你删除就会提示下面错误
如果不删除seafile-server-latest链接文件会提示下面的错误
命令./setup-seafile-mysql.sh回答的问题
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147[root@localhost seafile-server-6.1.1]# ./setup-seafile-mysql.sh
Checking python on this machine ...
Checking python module: setuptools ... Done.
Checking python module: python-imaging ... Done.
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
输入之前seafile的名字
[ server name ] seafile
What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
输入本机IP地址
[ This server's ip or domain ] 192.168.1.108
Where do you want to put your seafile data?
Please use a volume with enough free space
存储文件确定放在提示的目录里面吗?是直接回车
[ default "/home/seafile/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创建新的数据库不要使用原来的
[ 1 or 2 ] 1
What is the host of mysql server?
输入之前数据库的IP地址
[ default "localhost" ] 192.168.1.103
From which hosts could the mysql account be used?
允许那些用户可以访问数据库
[ default "%" ]
What is the port of mysql server?
确定MySQL的端口
[ default "3306" ]
What is the password of the mysql root user?
输入MySQL root用户的密码
[ root password ]
verifying password of user root ... done
Enter the name for mysql user of seafile. It would be created if not exists.
[ default "seafile" ]
Enter the password for mysql user "seafile":
输入MySQL的用户名的密码
[ password for seafile ]
verifying password of user seafile ... done
Enter the database name for ccnet-server:
创建的库名,默认直接回车
[ default "ccnet-db" ]
Enter the database name for seafile-server:
创建的库名,默认直接回车
[ default "seafile-db" ]
Enter the database name for seahub:
创建的库名,默认直接回车
[ default "seahub-db" ]
---------------------------------
This is your configuration
---------------------------------
确定输入的信息是否有错,有错按ctrl+c取消再次从新输入
server name: seafile
server ip/domain: 192.168.1.93
seafile data dir: /home/seafile/seafile-data
fileserver port: 8082
database: create new
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/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.启动seafile服务
注意:到这里就已经算是安装好之前的环境了,你可以使用http://ip:8000访问看看是否成功。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39[root@localhost seafile-server-6.1.1]# ./seafile.sh start
[05/22/19 06:53:14] ../common/session.c(132): using config file /home/seafile/conf/ccnet.conf
Starting seafile server, please wait ...
Seafile server started
Done.
[root@localhost seafile-server-6.1.1]# ./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 ] open@163.com
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.
备份数据并恢复新的数据(192.168.1.103)
停止seafile服务
1
2
3cd /home/seafile/seafile-server-6.1.1
./seafile.sh stop
./seahub.sh stop备份原来的数据库
1
2
3mysqldump -uroot -pPasswd lod-ccnet > /tmp/ccnet.sql
mysqldump -uroot -pPasswd lod-seahub > /tmp/seahub.sql
mysqldump -uroot -pPasswd lod-seafile > /tmp/seafile.sql恢复新的数据库
1
2
3mysql -uroot -pPasswd ccnet-db < /tmp/ccnet.sql
mysql -uroot -pPasswd seahub-db < /tmp/seahub.sql
mysql -uroot -pPasswd seafile-db < /tmp/deafile.sql
安装和配置Nginx(192.168.1.108)
安装依赖的包
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24cd /usr/local/src/
yum install -y gcc gcc-c++ autoconf automake pcre pcre-devel openssl* zlib* libtool
wget https://github.com/jemalloc/jemalloc/releases/download/5.1.0/jemalloc-5.1.0.tar.bz2
tar jxvf jemalloc-5.1.0.tar.bz2
cd jemalloc-5.1.0
./configure --prefix=/usr/local/jemalloc
make && make install
useradd -s /sbin/nologin -M nginx
cd ../
tar xzf tengine-2.3.0.tar.gz # 把tengine-2.3.0.tar.gz包上传到/usr/local/src/
cd tengine-2.3.0
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-pcre --with-http_ssl_module --with-jemalloc=/usr/local/src/jemalloc-5.1.0/ --with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_concat_module # 如果提示没有--with-http_concat_module模块可以不要
make && make install修改nginx的配置文件
1
2cd /usr/local/nginx/conf/
vim nginx.conf=删除之前的文件内容写入下面的内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41user nginx;
worker_processes auto;
pid logs/nginx.pid;
events {
worker_connections 768;
multi_accept on;
}
http {
#
Basic Settings
#
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
server_names_hash_bucket_size 64;
server_name_in_redirect off;
include mime.types;
default_type application/octet-stream;
client_max_body_size 100m;
#
Logging Settings
#
access_log logs/access.log;
error_log logs/error.log;
include sites-enable/*;
}
1
2mkdir sites-enable
vim default写入下面的内容
注意:此处的配置是原来的配置,之前的版本是支持 ./seahub.sh start-fastcgi 启动服务。现在测试阶段配置原来的配置文件。你也可以不用测试直接使用下面的配置文件。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39server {
listen 80;
server_name localhost;
proxy_set_header X-Forwarded-For $remote_addr;
location / {
fastcgi_pass 127.0.0.1:8000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_ADDR $remote_addr;
access_log logs/seahub.access.log;
error_log logs/seahub.error.log;
}
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_request_buffering off;
}
location /media {
root /home/seafile/seafile-server-latest/seahub;
}
}
修改nginx的default配置文件
注意:升级完成之后 ./seahub.sh 是不在支持 fastcgi 方式启动的。修改完成文件之后可以直接使用 ./seafile.sh start 启动1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35server {
listen 80;
server_name localhost;
proxy_set_header X-Forwarded-For $remote_addr;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_read_timeout 1200s;
# used for view/edit office file via Office Online Server
client_max_body_size 0;
access_log logs/seahub.access.log;
error_log logs/seahub.error.log;
}
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_request_buffering off;
}
location /media {
root /home/seafile/seafile-server-latest/seahub;
}
}- 开始升级seafile。具体方法请查看官方文档 :升级
拉取数据(192.168.1.108)
把原有的文件拉回到新的机器上。
1
rsync -aP root@192.168.1.205:/home/seafile/*data /home/seafile/
修改配置文件 /home/seafile/conf/seahub_settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46-*- coding: utf-8 -*-
SECRET_KEY = "gss=bf%!(g9t))i(pbkta4s8#$33v8a71#_t+g9)o6h20f-_fy"
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'seahub-db6',
'USER': 'seafile',
'PASSWORD': 'seafile',
'HOST': '192.168.1.208',
'PORT': '3306'
}
}
#下面的这些东西是设置邮件服务器。需要填写对
EMAIL_USE_TLS = False
EMAIL_HOST = 'smtp.mxhichina.com' # smpt 服务器
EMAIL_HOST_USER = 'opadmin@51signing.com' # 用户名和域名
EMAIL_HOST_PASSWORD = '@bjzqkj2015col!' # 密码
EMAIL_PORT = '25'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
##the below is 设置用户是否能注册等信息的
ENABLE_SIGNUP = True ####是否开启注册
ACTIVATE_AFTER_REGISTRATION = True ###注册后是否立即激活
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True ####管理员新增用户后是否给用户发送邮件
SEND_EMAIL_ON_RESETTING_USER_PASSWD = True ###管理员重置用户密码后是否给用户发送邮件
LOGIN_ATTEMPT_LIMIT = 3 ###用户输入密码错误次数超过改设置后,显示验证码
USER_PASSWORD_MIN_LENGTH = 6 ###用户密码最小长度
FORCE_PASSWORD_CHANGE = True ####管理员增加用户,第一次登录强制修改密码
ENABLE_WIKI = True #是否开启个人wiki
是否使用 pdf.js 来在线查看文件. 默认为 `True`
USE_PDFJS = True
FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024 ##默认查看文档大小
FILE_SERVER_ROOT = 'http://192.168.1.108/seafhttp'
TEXT_PREVIEW_EXT = """ac, am, bat, c, cc, cmake, cpp, cs, css, d
iff, el, h, html,
htm, java, js, json, less, make, org, php, pl, properties, py, r
b,
scala, script, sh, sql, txt, text, tex, vi, vim, xhtml, xml, log
, csv,
groovy, rst, patch, go, docx, doc""" wiki的配置文件内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45server {
listen 81;
server_name localhost;
location / {
root /var/www/html;
index index.html index.htm;
}
#error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~*^/dokuwiki/.*$ { #请求的url过滤,正则匹配,~为区分大小写,~*为不区分大小写。
#root path; #根目录
#index vv.txt; #设置默认页
proxy_pass http://test; #请求转向mysvr 定义的服务器列表
#deny 127.0.0.1; #拒绝的ip
#allow 172.18.5.54; #允许的ip
}
proxy_set_header X-Forwarded-For $remote_addr;
location / {
root html;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /usr/local/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}