星期五, 12月 12, 2014

升級 Bitnami Redmine

因為不好升級的 Gitlab 都升級成功,就想順便把 Redmine 也升級,畢竟是兩年前的版本。

  1. 在舊機 啟動ssh
    sudo mv /etc/init/ssh.conf.back
    /etc/init/ssh.conf
    sudo service ssh start
  2. 匯出 MySQL database
    先找出密碼
    grep password /opt/bitnami/apps/redmine/htdocs/config/database.yml
    mkdir /opt/backup
    /opt/bitnami/mysql/bin/mysqldump bitnami_redmine -u bitnami -p找出的密碼 > /opt/backup/bitnami_redmine.sql
  3. 備份已上傳檔案
    cd /opt/bitnami/apps/redmine/htdocs
    sudo tar czf /opt/backup/files.tgz files
  4. 換到新機 同樣  啟動ssh
    sudo mv /etc/init/ssh.conf.back
    /etc/init/ssh.conf
    sudo service ssh start
  5. 停止服務
    sudo sh /opt/bitnami/ctlscript.sh
    啟動MySQL
    sudo sh /opt/bitnami/ctlscript.sh mysql
  6. 匯入MySQL database
    先找出密碼
    grep password /opt/bitnami/apps/redmine/htdocs/config/database.yml
    mkdir /opt/backup
    scp root@舊機:/opt/backup/bitnami_redmine.sql /opt/backup
    這次新版Bitnami Redmine 的 Mysql root密碼是 bitnami 而不是 bitnami1
    /opt/bitnami/mysql/bin/mysql -u root -p
    進入MySQL shell後輸入
    drop database bitnami_redmine;
    create database bitnami_redmine;
    grant all privileges on bitnami_redmine.* to 'bitnami'@'localhost' identified by 'bitnami密碼';
    grant all privileges on bitnami_redmine.* to 'redmine'@'localhost' identified by 'bitnami密碼';
    flush privileges;
    \q
  7. 真正從備份檔匯入
    /opt/bitnami/mysql/bin/mysql -u bitnami -p找出的密碼 bitnami_redmine < /opt/backup/bitnami_redmine.sql
  8. 接下來要做Database Migration
    cd /opt/bitnami/apps/redmine/htdocs
    sudo ruby bin/rake db:migrate RAILS_ENV=production
  9. 匯入檔案
    scp root@舊機:/opt/backup/files.tgz /opt/backup
    cd /opt/bitnami/apps/redmine/htdocs
    sudo tar xzf /opt/backup/files.tgz
    必要時得改權限 chmod -R g+w /opt/bitnami/apps/redmine/htdocs/files
  10. 最後重啟服務
    sudo sh /opt/bitnami/ctlscript.sh restart
確認修改成功後就可以關閉舊機,修改 Hostname 與IP,取代原來的Redmine VM。

1 則留言:

Daniel Chou 提到...

感謝! 因參考您的文章讓我的Redmine MySQL 可以重啟成功。