Redmine版本升級(jí)之?dāng)?shù)據(jù)庫(kù)遷移--遠(yuǎn)沒(méi)你想的那么復(fù)雜

上篇文章已經(jīng)講了如何在Centos6.4下安裝Redmine1.0并升級(jí)到3.3版本,那么應(yīng)用的升級(jí)完成之后,最重要的步驟,應(yīng)該就是數(shù)據(jù)庫(kù)的遷移了吧,畢竟數(shù)據(jù)才是整個(gè)過(guò)程中最重要的。

這一篇,就將數(shù)據(jù)庫(kù)的遷移分為兩部分來(lái)介紹過(guò)程,分別是本地升級(jí)和異地升級(jí)和遷移。

首先講講數(shù)據(jù)庫(kù)的本地升級(jí)吧:

redmine3.3版本升級(jí)完畢之后,此時(shí)本地的數(shù)據(jù)庫(kù)應(yīng)該是已經(jīng)初始化為3.3版本的數(shù)據(jù)庫(kù)結(jié)構(gòu)了之前這個(gè)命令創(chuàng)建的:RAILS_ENV=production bundle exec rake db:migrate

接下來(lái)要做的:

第一步.刪除3.3版本的redmine數(shù)據(jù)庫(kù),然后再新建數(shù)據(jù)庫(kù)

mysql -uroot -p

drop database redmine;

創(chuàng)建數(shù)據(jù)庫(kù)redmine和數(shù)據(jù)庫(kù):

create?database?redmine?character?set?utf8;

然后導(dǎo)入redmine1.0版本的數(shù)據(jù)庫(kù)sql文件

mysql -uusername -ppassword databasename < backupfile.sql

username =root,password = 自己設(shè)置的密碼

第二步:進(jìn)入redmine3.3目錄下,同步數(shù)據(jù)庫(kù)結(jié)構(gòu)

RAILS_ENV=production bundle exec rake db:migrate

然后就可以啟動(dòng)redmine了,進(jìn)入redmine3.3目錄下:

ruby bin/rails server webrick -e production



第二種:數(shù)據(jù)庫(kù)的異地升級(jí)和遷移:

我們把數(shù)據(jù)庫(kù)服務(wù)器叫服務(wù)器A,應(yīng)用服務(wù)器稱(chēng)為服務(wù)器B

首先,在服務(wù)器A上安裝mysql并創(chuàng)建Redmine數(shù)據(jù)庫(kù)和redmine用戶(hù)。

1.第一步:在數(shù)據(jù)庫(kù)服務(wù)器上安裝mysql并創(chuàng)建Redmine數(shù)據(jù)庫(kù)和redmine用戶(hù)。

yum -y install mysql mysql-server

chkconfig mysqld on

service mysqld start

給mysql數(shù)據(jù)庫(kù)設(shè)置密碼:命令:

/usr/bin/mysql_secure_installation

Because we not have a password for the root account so you press Enter to skip.

Enter current password for root (enter for none):

Select Yes to set the password for the MySQL root account.

Set root password? [Y/n] y

Enter and confirm your password, remove the anonymous user, select Yes

Remove anonymous users? [Y/n] y

Allow remote login to MySQL as root account, select No.

Disallow root login remotely? [Y/n] n

Delete the test database, select Yes

Remove test database and access to it? [Y/n] y

Reload privilege tables, select Yes

Reload privilege tables now? [Y/n] y

創(chuàng)建redmine數(shù)據(jù)庫(kù)和用戶(hù):因?yàn)閞edmine的web服務(wù)器和數(shù)據(jù)庫(kù)服務(wù)器不在同一臺(tái)機(jī)器上,所以使用%代替了localhost

1.mysql?-uroot?-p?#首次mysql的密碼為空

2.create?database?redmine?character?set?utf8;

3.create?user?'redmine'@'%'?IDENTIFIED?BY?'pwd';?#用戶(hù)名:?redmine;?密碼:pwd

4.grant?all?privileges?on?redmine.*?to?'redmine'@'%';?#最大權(quán)限

5.flush?privileges;

在服務(wù)器B上修改database.yml文件:

host改為服務(wù)器A的地址。

至此,數(shù)據(jù)庫(kù)服務(wù)器上產(chǎn)生了redmine的表。

第二步:數(shù)據(jù)庫(kù)的導(dǎo)入

在原redmine服務(wù)器上x(chóng)p系統(tǒng)上,關(guān)閉redmine服務(wù),以免備份過(guò)程中數(shù)據(jù)不完整

關(guān)掉下列服務(wù):

redmineApache

redmineSubversion

redmineThin1

redmineThin2

進(jìn)入mysql/bin目錄下:備份現(xiàn)有的數(shù)據(jù)庫(kù)

mysqldump -uusername -ppassword databasename > backupfile.sql

***username =root,password =自己設(shè)置的密碼

導(dǎo)入到目標(biāo)數(shù)據(jù)庫(kù)服務(wù)器:

mysql -hhostname -uusername -ppassword databasename < backupfile.sql

***Hostname=目標(biāo)服務(wù)器A的地址,

***username=redmine,password= pwd;

第三步:

在web服務(wù)器下的

redmine目錄下執(zhí)行:

RAILS_ENV=production bundle exec rake db:migrate//創(chuàng)建數(shù)據(jù)庫(kù)結(jié)構(gòu)

RAILS_ENV=production bundle exec rake redmine:load_default_data//初始化表結(jié)構(gòu)

將原redmine目錄下的file文件拷貝至redmine3.3版本的file文件夾下。

rm -rf /usr/local/redmine3.3/files

mv /files的路徑/files /usr/local/redmine3.3/

至此,redmine的數(shù)據(jù)庫(kù)異地升級(jí)和遷移完成。

小結(jié):先導(dǎo)入數(shù)據(jù)庫(kù).sql文件,再執(zhí)行RAILS_ENV=production bundle exec rake db:migrate,可實(shí)現(xiàn)數(shù)據(jù)庫(kù)的結(jié)構(gòu)升級(jí)。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 【MySQL】Linux下MySQL 5.5、5.6和5.7的RPM、二進(jìn)制和源碼安裝 1.1BLOG文檔結(jié)構(gòu)圖 ...
    小麥苗DB寶閱讀 10,886評(píng)論 0 31
  • CentOs6.4上安裝升級(jí)redmine1.0手冊(cè) 第一步:安裝依賴(lài)包 第二步:安裝MySQL,命令 第三步:安...
    靜候輪回silly閱讀 1,251評(píng)論 0 0
  • Spring Cloud為開(kāi)發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見(jiàn)模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,564評(píng)論 19 139
  • Redmine 安裝記錄 Requirements 本文用到的系統(tǒng)為64位的 Windows, 使用的數(shù)據(jù)庫(kù)為SQ...
    飛多學(xué)堂閱讀 1,971評(píng)論 0 1
  • 什么是數(shù)據(jù)庫(kù)? 數(shù)據(jù)庫(kù)是存儲(chǔ)數(shù)據(jù)的集合的單獨(dú)的應(yīng)用程序。每個(gè)數(shù)據(jù)庫(kù)具有一個(gè)或多個(gè)不同的API,用于創(chuàng)建,訪問(wèn),管理...
    chen_000閱讀 4,143評(píng)論 0 19

友情鏈接更多精彩內(nèi)容