gitlab 跨版本升級至docker

Policewomen_ZH-CN9260416327_1920x1080.jpg

背景:由于公司原有g(shù)itlab為gitlab-ce-8.13.0-ce.0的版本,因為版本比較老,無法部署ci/cd持續(xù)化集成。所以打算把公司的gilab升級一下。由于公司的服務(wù)器系統(tǒng)也比較老了是centos6的版本打算同時把系統(tǒng)升級為centos7
說明:有問題大家可以加微信(yudianguo)或者發(fā)郵箱(yu_dianguo@163.com)共同交流
過程:
1、備份原有g(shù)itlab數(shù)據(jù)

# 備份數(shù)據(jù)
gitlab-rake gitlab:backup:create
# 由于升級系統(tǒng),下載數(shù)據(jù)到本地(如果下載速度比較慢建議上傳到阿里云圖床)
scp root@<您的ip>:/var/opt/gitlab/backups/1555903057_gitlab_backup.tar ./

2、 更換鏡像源(如果系統(tǒng)沒有更新鏡像源)

3、安裝一個和線上同版本的gitlab

# 下載安裝包
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.13.0-ce.0.el7.x86_64.rpm
# 配置gitlab并啟動
sudo gitlab-ctl reconfigure
# 重新啟動
sudo gitlab-ctl restart

4、恢復(fù)備份文件

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
# 復(fù)制備份文件到  /var/opt/gitlab/backups
mv 1555554634_gitlab_backup.tar /var/opt/gitlab/backups
# 更改所屬文件  git:git
chown git:git 1555926452_2019_04_22_11.3.4_gitlab_backup.tar 
gitlab-rake gitlab:backup:restore BACKUP="1555926452_2019_04_22_11.3.4"

5、由于gitlab不支持直接升級到最高版本,要逐步升級

# 官方規(guī)定升級路線([https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations](https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations))

6、逐步升級

# 下載對應(yīng)升級路徑的鏡像(由于升級過程中按照官方路徑提示版本不一致,下面是我調(diào)整后的)
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.13.5-ce.0.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.17.7-ce.0.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.5.10-ce.0.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.8.7-ce.0.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.3.4-ce.0.el7.x86_64.rpm

# 以下部分循環(huán)執(zhí)行 一步步升級
### 開始 ###
rpm -Uvh gitlab-ce-8.13.5-ce.0.el7.x86_64.rpm (對應(yīng)版本)
gitlab-ctl reconfigure
gitlab-ctl restart
### 結(jié)束 ### 

# 安裝包 這個執(zhí)行 有一個版本需要安裝該擴展
yum install -y curl policycoreutils-python openssh-server openssh-clients

7、執(zhí)行到最后一步后備份阿里云

8、docker-composer 配置 這個是配置的nginx轉(zhuǎn)發(fā),由于gitlab使用ssh端口,所以把服務(wù)器登錄的端口可以改掉,注意下恢復(fù)版本到docker的時候 一開始要把image的版本 和你備份的版本號一致恢復(fù)?;謴?fù)完成后在該你的版本。

    gitlab:
      image: 'gitlab/gitlab-ce:latest'
      container_name: gitlab
      restart: always
      hostname: 'gitlab.xxx.com'
      environment:
        GITLAB_OMNIBUS_CONFIG: |
          external_url 'http://gitlab.xxx.com'
      ports:
        - '83:80'
        - '444:443'
        - '22:22'
      volumes:
        - /etc/localtime:/etc/localtime
        - './gitlab/config:/etc/gitlab'
        - './gitlab/logs:/var/log/gitlab'
        - './gitlab/data:/var/opt/gitlab'
      extra_hosts:
         - "gitlab.xxx.com:127.0.0.1"
      networks:
          - backend
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

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