close

環境:
    OS: CentOS 7.6
    原本的GitLab IP: 1.1.1.1
    新的GitLab IP: 2.2.2.2


準備2.2.2.2的環境:
1. 安裝EPEL YUM repo,然後update系統,並重開機
sudo yum install -y epel-release
sudo yum -y update && sudo reboot


2. 安裝所需的工具
sudo yum install -y curl policycoreutils-python openssh-server openssh-clients postfix rsync


3. 設定工具與開啟防火牆的Service Ports
sudo systemctl enable postfix.service
sudo systemctl start postfix.service
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --permanent --add-service=smtp
sudo firewall-cmd --permanent --add-service=pop3
sudo firewall-cmd --permanent --add-service=imap
sudo firewall-cmd --permanent --add-service=smtps
sudo firewall-cmd --permanent --add-service=pop3s
sudo firewall-cmd --permanent --add-service=imaps
sudo firewall-cmd --reload
sudo systemctl reload firewalld.service

 

開始安裝與升級新的GitLab:

在新的GitLab 2.2.2.2下動作:
1. 安裝與舊的GitLab 1.1.1.1的版本一致的GitLab Version 8.1.3
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
yum install --nopgpcheck gitlab-ce-8.1.3
sudo gitlab-ctl reconfigure
sudo gitlab-ctl start

 

在原本的GitLab 1.1.1.1下動作:

1. 確定GitLab沒有人在使用與Change資料時,進行備份
gitlab-rake gitlab:backup:create


2. 複製備份資料到新的GitLab 2.2.2.2
scp /var/opt/gitlab/backups/1562667658_gitlab_backup.tar gitlab@2.2.2.2:/tmp


3. 複製/etc/ssh與/etc/gitlab的資料到新的GitLab 2.2.2.2
scp -r /etc/ssh /etc/gitlab gitlab@2.2.2.2:/tmp


4. 使用rsync去複製repositories資料到新的GitLab 2.2.2.2
rsync -avz /var/opt/gitlab/git-data/repositories/ gitlab@2.2.2.2:/var/opt/gitlab/git-data/repositories

 

在新的GitLab 2.2.2.2下動作:

1. 備份原本的/etc/ssh,並更新成舊有的ssh與gitlab資料
mv /etc/ssh /etc/ssh.bak
cp -R /tmp/ssh /tmp/gitlab /etc
chgrp ssh_keys /etc/ssh/*_key


2. 將GitLab的備份資料放到對應的位置與權限
cp -a /tmp/1562667658_gitlab_backup.tar /var/opt/gitlab/backups/
chown git:git /var/opt/gitlab/backups/1562667658_gitlab_backup.tar


3. 停掉unicom與sidekiq服務
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq


4.確認unicom與sidekiq服務是否有真的停止運作
gitlab-ctl status


5. 將備份檔案還原到新的GitLab 2.2.2.2
gitlab-rake gitlab:backup:restore BACKUP=1562667658


6. 我們是使用CentOS 7,所以將所有的 "initctl" 的字眼都換成 "systemctl"
vim /opt/gitlab/embedded/cookbooks/runit/recipes/upstart.rb


7. Reconfigure與Start服務
gitlab-ctl reconfigure
gitlab-ctl start


8.安裝gitlab-ce 8的最新release 8.17.7與更新database,若不確定最新release版本可以下指令查看(yum --showduplicates list gitlab-ce)
yum install --nogpgcheck gitlab-ce-8.17.7
gitlab-ctl pg-upgrade
gitlab-ctl reconfigure
gitlab-ctl start


9. 安裝gitlab-ce 9的最新release 9.5.10
yum install --nogpgcheck gitlab-ce-9.5.10
gitlab-ctl reconfigure
gitlab-ctl start


10. 安裝gitlab-ce 10的最新release 10.8.7
yum install --nogpgcheck gitlab-ce-10.8.7


11. 由於後來的版本就不支援git_data_dir的語法,所以我們要手動換成git_data_dirs
vim /etc/gitlab/gitlab.rb
================================
git_data_dir /var/opt/gitlab/git-data
================================
變更為如下
================================
git_data_dirs({
    "default" => {
        "path" => "/var/opt/gitlab/git-data"
    }
})

================================


12. Reconfigure與Start服務
gitlab-ctl reconfigure
gitlab-ctl start


13. 安裝gitlab-ce 11的最新release 11.11.5與更新database
yum install --nogpgcheck gitlab-ce-11.11.5
gitlab-ctl pg-upgrade
gitlab-ctl reconfigure
gitlab-ctl restart


14. 安裝gitlab-ce目前最新release的版本12.0.3
yum install gitlab-ce
gitlab-ctl reconfigure
gitlab-ctl restart

 

在原本的GitLab 1.1.1.1下動作:

1. 對原本的GitLab進行下線的動作
sudo shutdown -h now

 

在新的GitLab 2.2.2.2下動作:

1. 將GitLab 2.2.2.2的CentOS 7 IP換成1.1.1.1取代原本的GitLab 1.1.1.1

 

大功告成!

 

Reference:
https://www.vultr.com/docs/how-to-install-gitlab-community-edition-ce-11-x-on-centos-7
https://fak3r.com/2017/12/11/upgrading-gitlab-from-6x-to-10x/
https://docs.gitlab.com/12.0/ee/policy/maintenance.html#upgrade-recommendations
https://unix.stackexchange.com/questions/6263/how-to-check-available-package-versions-in-rpm-systems

arrow
arrow
    全站熱搜

    dreamtails 發表在 痞客邦 留言(0) 人氣()