GitLab 如何降級安裝?

极狐GitLab發表於2024-11-13

本分分享 GitLab 降級的流程和注意事項。極狐GitLab 為 GitLab 的中文發行版,本文以私有化部署的極狐GitLab 為例來演示整個過程。

【極狐GitLab 推出 GitLab 老舊版本的專業升級服務https://dl.gitlab.cn/et1zcbjj 】,可以讓 12.x、13.x、14.x、15.x 等老舊版本的升級平滑不出問題】

首先確定當前的版本資訊,在例項 URL 後面加 /help就可以檢視:

file

當前例項為 17.5.1-jh。我們降級到 17.4.0-jh。

降級之前需要做好備份,執行 gitlab-backup create即可開始備份。

# 開始備份
gitlab-backup create
2024-11-13 04:43:09 UTC -- Dumping database ...
2024-11-13 04:43:09 UTC -- Dumping PostgreSQL database gitlabhq_production ...
2024-11-13 04:43:44 UTC -- [DONE]
2024-11-13 04:43:44 UTC -- Dumping database ... done
2024-11-13 04:43:44 UTC -- Dumping repositories ...
{"command":"create","gl_project_path":"devsecops.wiki","level":"info","msg":"started create","pid":321034,"relative_path":"@groups/4f/c8/4fc82b26aecb47d2868c4efbe3581732a3e7cbcc6c2efb32062c08170a05eeb8.wiki.git","storage_name":"default","time":"2024-11-13T04:43:45.332Z"}
......太長刪除......
Please back them up manually.
2024-11-13 04:43:46 UTC -- Backup 1731472989_2024_11_13_17.5.1-jh is done.
2024-11-13 04:43:46 UTC -- Deleting backup and restore PID file at [/opt/gitlab/embedded/service/gitlab-rails/tmp/backup_restore.pid] ... done

# 檢視備份
ls -ltr /var/opt/gitlab/backups/
-rw------- 1 git git 379535360 Nov 13 04:43 /var/opt/gitlab/backups/1731472989_2024_11_13_17.5.1-jh_gitlab_backup.tar

接著執行降級的步驟,大體為:

  • 停止極狐GitLab
  • 移除當前的軟體包
  • 安裝降級之後的安裝包
  • 重新配置極狐GitLab
  • 恢復備份
  • 啟動極狐GitLab

下面我們一步步演示在 ubuntu 22.04 上如何降級安裝好的極狐GitLab 例項。

整體步驟

停止極狐GitLab

# If running Puma
sudo gitlab-ctl stop puma

# Stop sidekiq
sudo gitlab-ctl stop sidekiq

移除當前的安裝包

# If on Ubuntu: remove the current package
sudo dpkg -r gitlab-jh

安裝降級之後的安裝包

可以執行 apt-cache madison gitlab-jh找到需要降級的對應安裝包資訊。本文選擇降級到 17.4.0-jh.0

接著執行安裝命令進行低版本極狐GitLab 的安裝:

apt install gitlab-jh=17.4.0-jh.0

安裝成功會顯示如下介面:

重新配置極狐GitLab

執行 reconfigure命令重新配置極狐GitLab

# 重新配置例項
gitlab-ctl reconfigure

# 檢視元件狀態
gitlab-ctl status
run: alertmanager: (pid 323277) 151s; run: log: (pid 323259) 152s
run: gitaly: (pid 323275) 151s; run: log: (pid 323261) 152s
run: gitlab-exporter: (pid 323274) 151s; run: log: (pid 323270) 151s
run: gitlab-kas: (pid 323237) 152s; run: log: (pid 323217) 152s
run: gitlab-workhorse: (pid 323238) 152s; run: log: (pid 323218) 152s
run: logrotate: (pid 323314) 151s; run: log: (pid 323260) 152s
run: nginx: (pid 323315) 151s; run: log: (pid 323263) 152s
run: node-exporter: (pid 323258) 152s; run: log: (pid 323256) 152s
run: postgres-exporter: (pid 323273) 151s; run: log: (pid 323271) 151s
run: postgresql: (pid 323264) 152s; run: log: (pid 323257) 152s
run: prometheus: (pid 323272) 151s; run: log: (pid 323254) 152s
run: puma: (pid 323220) 152s; run: log: (pid 323219) 152s
run: redis: (pid 323223) 152s; run: log: (pid 323221) 152s
run: redis-exporter: (pid 323276) 151s; run: log: (pid 323262) 152s
run: sidekiq: (pid 323224) 152s; run: log: (pid 323222) 152s

恢復資料

# 找到對應的備份檔案,恢復資料
gitlab-backup restore BACKUP=1730349575_2024_10_31_17.4.0-jh
2024-11-13 06:09:17 UTC -- Unpacking backup ...
2024-11-13 06:09:18 UTC -- Unpacking backup ... done
2024-11-13 06:09:18 UTC -- Restoring database ...
2024-11-13 06:09:18 UTC -- Be sure to stop Puma, Sidekiq, and any other process that
connects to the database before proceeding. For Omnibus
installs, see the following link for more information:
http://jhma.jihulab.net/help/raketasks/backup_restore.html#restore-for-omnibus-gitlab-installations
......太長刪除......
2024-11-13 06:13:09 UTC -- Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data
and are not included in this backup. You will need to restore these files manually.
2024-11-13 06:13:09 UTC -- Restore task is done.
2024-11-13 06:13:09 UTC -- Deleting backup and restore PID file at [/opt/gitlab/embedded/service/gitlab-rails/tmp/backup_restore.pid] ... done

接著訪問極狐GitLab 例項,檢視對應的版本即可

file

注意事項

對於極狐GitLab 的降級操作一定是要慎之又慎,而且要確保做好了資料備份。如果在整個過程中出現問題,可以尋求極狐GitLab 專業升級服務

相關文章