从windows迁移到Linux并转换数据库为mysql

1、完全停止Windows上 Seafile进程,选择退出并停止 Seafile Server 。
2、复制 seafile-data 和 seafile-server 到 Linux服务器的 /root目录

注:Windows服务器版本此文用的是6.0.7

## Linux服务器操作

#准备一个同版本的 Seafile服务器使用 SQLite 部署

wget http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.0.7_x86-64.tar.gz

tar -zxvf seafile-server_6.0.7_x86-64.tar.gz

mv seafile-server-6.0.7 /home

cd /home/seafile-server-6.0.7

./setup-seafile-sh

#删除Linux的配置文件和数据

rm /home/conf/seahub_settings.py

rm /home/seahub.db

rm -rf /home/seafile-data

cp /home/ccnet/seafile.ini /home

rm -rf /home/ccnet

#拷贝原配置文件和数据

cp /root/seafile-server/conf/seahub_settings.py /home/conf/

cp /root/seafile-server/seahub.db /home/

cp -r /root/seafile-data /home/

cp -r /root/seafile-server/ccnet /home/

cp /home/seafile.ini /home/ccnet

cp /home/conf/ccnet.conf /home/ccnet/ \此命令为了之后的转换数据库

##启动测试

cd /home/seafile-server-latest

./seafile.sh start

./seahub.sh start

PS: 开放防火墙并测试网页访问和文件上传下载。

##转换数据库为 Mariadb\Mysql

./seafile.sh stop

./seahub.sh stop

cd /home

wget https://raw.githubusercontent.com/haiwen/seafile-server/master/scripts/sqlite2mysql.py

wget https://raw.githubusercontent.com/haiwen/seafile-server/master/scripts/sqlite2mysql.sh

#此时的目录

├── ccnet
├── conf
├── seafile-data
├── seafile-server-6.0.7
├── seafile-server-latest -> seafile-server-6.0.7
├── seahub-data
├── seahub.db
├── sqlite2mysql.py
└── sqlite2mysql.sh

chmod +x sqlite2mysql.sh

./sqlite2mysql.sh

ll *.sql -h \会生成以下文件

-rw-r–r-- 1 root root 2.1K 11月 29 14:47 ccnet-db.sql
-rw-r–r-- 1 root root 7.4K 11月 29 14:47 seafile-db.sql
-rw-r–r-- 1 root root 29K 11月 29 14:47 seahub-db.sql

mysql -uroot -p \进入mysql命令行(提前安装好并设置好UTF8编码)

#创建数据库

create database ccnet-db character set = ‘utf8’;

create database seafile-db character set = ‘utf8’;

create database seahub-db character set = ‘utf8’;

#导入数据

use ccnet-db

source ccnet-db.sql

use seafile-db

source seafile-db.sql

use seahub-db

source seahub-db.sql

quit;

##将Seafile接入数据库,修改配置文件按照下列配置添加。

vim /home/conf/ccnet.conf

[Database]
ENGINE=mysql
HOST=127.0.0.1
USER=root
PASSWD=root
DB=ccnet-db
CONNECTION_CHARSET=utf8

vim /home/conf/seafile.conf

[database]
type=mysql
host=127.0.0.1
user=root
password=root
db_name=seafile-db
CONNECTION_CHARSET=utf8

vim /home/conf/seahub_settings.py

DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.mysql’,
‘USER’ : ‘root’,
‘PASSWORD’ : ‘root’,
‘NAME’ : ‘seahub-db’,
‘HOST’ : ‘127.0.0.1’,
‘OPTIONS’: {
“init_command”: “SET storage_engine=INNODB”,
}
}
}

##启动测试

cd /home/seafile-server-latest

./seafile.sh start

./seahub.sh start

PS:测试网页访问和文件上传下载。

##升级Seafile(建议先升级到较近版本,版本相差太多若以出错)

#cd /root

wget http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.1.2_x86-64.tar.gz

tar -zxvf seafile-server_6.1.2_x86-64.tar.gz

mv seafile-server-6.1.2 /home

cd /home/seafile-server-latest

./seafile.sh stop

./seahub.sh stop

cd /home/seafile-server-6.1.2/upgrade

./upgrade_6.0_6.1.sh

cd /home/seafile-server-latest

./seafile.sh start

./seahub.sh start

PS: 测试网页和客户端上传下载。

全文所需文件百度云链接:https://pan.baidu.com/s/1o7Q62oU 密码:jcf2