原來裝的 Bitnami Gitlab Virtual Machine是 Gitlab 6.8,因為我手賤升級Ubuntu就不太正常,要把原來的Gitlab升級。
先看了GitLab Upgrader發覺不太夠,再看6.9 to 7.0,確認 Ruby版本也要新版,於是抓了新版的 Bitnami Gitlab Virtual Machine,打算直接連OS一併升級。
Bitnami原廠的升級步驟在這裡,但是不完全足夠,所以我整理成一篇筆記。
我會利用到ssh,所以必須啟動ssh
sudo mv /etc/init/ssh.conf.back /etc/init/ssh.conf
sudo service ssh start
首先要知道 mysql的密碼,root預設是 bitnami1。至於bitnami的mysql密碼則要看database.yml
grep password /opt/bitnami/apps/gitlab/htdocs/config/database.yml
先用bitnami登入
sudo su -
cd /opt/bitnami
./use_gitlab
export PATH_TO_BACKUP=/opt/backup
cd /opt/bitnami
sudo ./use_gitlab
if [ ! -d $PATH_TO_BACKUP ]
then
mkdir $PATH_TO_BACKUP
fi
cd /opt/bitnami/mysql/bin/
mysqldump -u bitnami -p bitnami_gitlab > $PATH_TO_BACKUP/bitnami_gitlab_bk.sql
mysqldump -u bitnami -p bitnami_gitlabci > $PATH_TO_BACKUP/bitnami_gitlabci_bk.sql
if [ ! -d $PATH_TO_BACKUP/git ]
then
mkdir $PATH_TO_BACKUP/git
fi
if [ ! -d $PATH_TO_BACKUP/gitlab_ci ]
then
mkdir $PATH_TO_BACKUP/gitlab_ci
fi
cp -r /home/git/.ssh $PATH_TO_BACKUP/git/.ssh
cp -r /home/gitlab_ci/.ssh $PATH_TO_BACKUP/gitlab_ci/.ssh
cd /opt/bitnami/apps/gitlab
tar czf $PATH_TO_BACKUP/repositories.tgz repositories
cd /opt/bitnami/apps/gitlabci/conf
tar czf $PATH_TO_BACKUP/certs.tgz certs
備份完成後,到新建好的VM,查出bitnami的mysql密碼 (同樣是利用 grep password /opt/bitnami/apps/gitlab/htdocs/config/database.yml )
同樣要啟動ssh
sudo mv /etc/init/ssh.conf.back /etc/init/ssh.conf
sudo service ssh start
接著
sudo su -
scp -r root@舊的server:/opt/backup /opt
grep password /opt/bitnami/apps/gitlab/htdocs/config/database.yml
/opt/bitnami/ctlscript.sh stop
/opt/bitnami/ctlscript.sh start mysql
/opt/bitnami/use_gitlab
mysql -u root -p
drop database bitnami_gitlab;
drop database bitnami_gitlabci;
create database bitnami_gitlab;
create database bitnami_gitlabci;
grant all privileges on bitnami_gitlab.* to 'bitnami'@'localhost' identified by 'bitnami密碼';
grant all privileges on bitnami_gitlab.* to 'gitlab'@'localhost' identified by 'bitnami密碼';
grant all privileges on bitnami_gitlabci.* to 'bitnami'@'localhost' identified by 'bitnami密碼';
grant all privileges on bitnami_gitlabci.* to 'gitlab'@'localhost' identified by 'bitnami密碼';
flush privileges;
export PATH_TO_BACKUP=/opt/backup
mysql -u root -pbitnami1 bitnami_gitlab < $PATH_TO_BACKUP/bitnami_gitlab_bk.sql
mysql -u root -pbitnami1 bitnami_gitlabci < $PATH_TO_BACKUP/bitnami_gitlabci_bk.sql
cp -r $PATH_TO_BACKUP/git /home
cp -r $PATH_TO_BACKUP/gitlab_ci /home
cd /opt/bitnami/apps/gitlab
tar xzf $PATH_TO_BACKUP/repositories.tgz
cd /opt/bitnami/apps/gitlabci/conf
tar xzf $PATH_TO_BACKUP/certs.tgz
chown -Rf git:git /home/git/.ssh
chown -Rf gitlab_ci:gitlab_ci /home/gitlab_ci/.ssh
hown -Rf gitlab_ci:gitlab_ci /opt/bitnami/apps/gitlabci/conf/certs
cd /opt/bitnami/apps/gitlab/htdocs
sudo -u git -H bundle install --deployment --without development test postgres --binstubs
cd /opt/bitnami/apps/gitlabci/htdocs
sudo -u git -H ruby bin/rake db:migrate RAILS_ENV=production
cd /opt/bitnami/apps/gitlab/htdocs
sudo -u git -H ruby bin/rake db:migrate migrate_iids RAILS_ENV=production
/opt/bitnami/ctlscript.sh restart
sudo -u git -H ruby bin/rake assets:clean assets:precompile cache:clear RAILS_ENV=production
/opt/bitnami//ctlscript.sh restart
萬一遇到問題,再用這招
cd /opt/bitnami/apps/gitlab/htdocs
sudo -u git -H ruby bin/rake gitlab:check RAILS_ENV=production
我的步驟是做了
sudo chmod u+rwx,g=rx,o-rwx /opt/bitnami/apps/gitlab/gitlab-satellites
cd /opt/bitnami/apps/gitlab/htdocs
sudo -u git -H /opt/bitnami/apps/gitlab/gitlab-shell/bin/create-hooks
最後再用這招檢查,沒問題再重啟apache
cd /opt/bitnami/apps/gitlab/htdocs
sudo -u git -H ruby bin/rake gitlab:check RAILS_ENV=production
先看了GitLab Upgrader發覺不太夠,再看6.9 to 7.0,確認 Ruby版本也要新版,於是抓了新版的 Bitnami Gitlab Virtual Machine,打算直接連OS一併升級。
Bitnami原廠的升級步驟在這裡,但是不完全足夠,所以我整理成一篇筆記。
我會利用到ssh,所以必須啟動ssh
sudo mv /etc/init/ssh.conf.back /etc/init/ssh.conf
sudo service ssh start
首先要知道 mysql的密碼,root預設是 bitnami1。至於bitnami的mysql密碼則要看database.yml
grep password /opt/bitnami/apps/gitlab/htdocs/config/database.yml
先用bitnami登入
sudo su -
cd /opt/bitnami
./use_gitlab
export PATH_TO_BACKUP=/opt/backup
cd /opt/bitnami
sudo ./use_gitlab
if [ ! -d $PATH_TO_BACKUP ]
then
mkdir $PATH_TO_BACKUP
fi
cd /opt/bitnami/mysql/bin/
mysqldump -u bitnami -p bitnami_gitlab > $PATH_TO_BACKUP/bitnami_gitlab_bk.sql
mysqldump -u bitnami -p bitnami_gitlabci > $PATH_TO_BACKUP/bitnami_gitlabci_bk.sql
if [ ! -d $PATH_TO_BACKUP/git ]
then
mkdir $PATH_TO_BACKUP/git
fi
if [ ! -d $PATH_TO_BACKUP/gitlab_ci ]
then
mkdir $PATH_TO_BACKUP/gitlab_ci
fi
cp -r /home/git/.ssh $PATH_TO_BACKUP/git/.ssh
cp -r /home/gitlab_ci/.ssh $PATH_TO_BACKUP/gitlab_ci/.ssh
cd /opt/bitnami/apps/gitlab
tar czf $PATH_TO_BACKUP/repositories.tgz repositories
cd /opt/bitnami/apps/gitlabci/conf
tar czf $PATH_TO_BACKUP/certs.tgz certs
備份完成後,到新建好的VM,查出bitnami的mysql密碼 (同樣是利用 grep password /opt/bitnami/apps/gitlab/htdocs/config/database.yml )
同樣要啟動ssh
sudo mv /etc/init/ssh.conf.back /etc/init/ssh.conf
sudo service ssh start
接著
sudo su -
scp -r root@舊的server:/opt/backup /opt
grep password /opt/bitnami/apps/gitlab/htdocs/config/database.yml
/opt/bitnami/ctlscript.sh stop
/opt/bitnami/ctlscript.sh start mysql
/opt/bitnami/use_gitlab
mysql -u root -p
drop database bitnami_gitlab;
drop database bitnami_gitlabci;
create database bitnami_gitlab;
create database bitnami_gitlabci;
grant all privileges on bitnami_gitlab.* to 'bitnami'@'localhost' identified by 'bitnami密碼';
grant all privileges on bitnami_gitlab.* to 'gitlab'@'localhost' identified by 'bitnami密碼';
grant all privileges on bitnami_gitlabci.* to 'bitnami'@'localhost' identified by 'bitnami密碼';
grant all privileges on bitnami_gitlabci.* to 'gitlab'@'localhost' identified by 'bitnami密碼';
flush privileges;
\q
export PATH_TO_BACKUP=/opt/backup
mysql -u root -pbitnami1 bitnami_gitlab < $PATH_TO_BACKUP/bitnami_gitlab_bk.sql
mysql -u root -pbitnami1 bitnami_gitlabci < $PATH_TO_BACKUP/bitnami_gitlabci_bk.sql
cp -r $PATH_TO_BACKUP/git /home
cp -r $PATH_TO_BACKUP/gitlab_ci /home
cd /opt/bitnami/apps/gitlab
tar xzf $PATH_TO_BACKUP/repositories.tgz
cd /opt/bitnami/apps/gitlabci/conf
tar xzf $PATH_TO_BACKUP/certs.tgz
chown -Rf git:git /home/git/.ssh
chown -Rf gitlab_ci:gitlab_ci /home/gitlab_ci/.ssh
hown -Rf gitlab_ci:gitlab_ci /opt/bitnami/apps/gitlabci/conf/certs
cd /opt/bitnami/apps/gitlab/htdocs
sudo -u git -H bundle install --deployment --without development test postgres --binstubs
cd /opt/bitnami/apps/gitlabci/htdocs
sudo -u git -H ruby bin/rake db:migrate RAILS_ENV=production
cd /opt/bitnami/apps/gitlab/htdocs
sudo -u git -H ruby bin/rake db:migrate migrate_iids RAILS_ENV=production
/opt/bitnami/ctlscript.sh restart
sudo -u git -H ruby bin/rake assets:clean assets:precompile cache:clear RAILS_ENV=production
/opt/bitnami//ctlscript.sh restart
萬一遇到問題,再用這招
cd /opt/bitnami/apps/gitlab/htdocs
sudo -u git -H ruby bin/rake gitlab:check RAILS_ENV=production
我的步驟是做了
sudo chmod u+rwx,g=rx,o-rwx /opt/bitnami/apps/gitlab/gitlab-satellites
cd /opt/bitnami/apps/gitlab/htdocs
sudo -u git -H /opt/bitnami/apps/gitlab/gitlab-shell/bin/create-hooks
最後再用這招檢查,沒問題再重啟apache
cd /opt/bitnami/apps/gitlab/htdocs
sudo -u git -H ruby bin/rake gitlab:check RAILS_ENV=production
同場加映:修改Ubuntu 14.04 hostname與 改為固定IP
改hostname很簡單
sudo vi /etc/hostname
接下來改固定IP
sudo vi /etc/network/interfaces
sudo vi /etc/network/interfaces
把原本的iface eth0 inet dhcp 改成
iface eth0 inet static
address 192.168.1.111[你的IP]
netmask 255.255.255.0[你的netmask]
gateway 192.168.1.254[你的gateway]
network 192.168.1.0[你的network]
broadcast 192.168.1.255[你的broadcast]
dns-nameservers 8.8.8.8 8.8.4.4
VMware現在推薦使用open-vm-tools instead of VMware Tools for Linux,所以:
sudo apt-get install open-vm-tools
改完hostname後,再去改 /opt/bitnami/apps/gitlab/htdocs/config/gitlab.yml ,將host: 後面的IP改成hostname。但是只要重開機或重新執行/opt/bitnami/ctlscript.sh後 在gitlab的 hostname 還是會變成IP,所以完成後要刪掉Bitnami做的 /opt/bitnami/apps/gitlab/bnconfig ,才不會一直改 gitlab.yml。
改好後,只要 sudo /opt/bitnami/apache2/bin/apachectl restart 就會生效。
留言