gitlab 11.10.4升級至12.3.4碰到的坑

起因:ACME客戶端版本過舊導致無法更新Lets Encrypt證書

lets encrypt證書的有效期是90天,使用以下兩個命令都無法更新證書

sudo gitlab-ctl renew-le-certs

sudo gitlab-ctl reconfigure

錯誤提示ACME v1版本已被廢棄:

Running handlers:
There was an error running gitlab-ctl reconfigure:

letsencrypt_certificate[gitlab.<redacted>.com] (letsencrypt::http_authorization line 3) had an error: Acme::Client::Error::Unauthorized: acme_certificate[staging] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/letsencrypt/resources/certificate.rb line 20) had an error: Acme::Client::Error::Unauthorized: Account creation on ACMEv1 is disabled. Please upgrade your ACME client to a version that supports ACMEv2 / RFC 8555. See https://community.letsencrypt.org/t/end-of-life-plan-for-acmev1/88430 for details.

Gitlab 12.1.x版本更新了ACME Client的版本,只能升級了。

升級gitlab的曲折之路

服務器操作系統CentOS 7,當前Gitlab的版本是11.10.4,使用Ominbus Gitlab Package安裝。根據官網的要求,先升級到11.11.8。先下載rpm包後,後進行離線更新:

# CentOS/RHEL
rpm -Uvh gitlab-ce-XXX.rpm

坑1:錯誤的跳過了中間版本的reconfigure

由於11.11.8中並沒有更新ACME,所以執行 'gitlab-ctl reconfigure’失敗。這時我犯了一個致命的錯誤:

sudo touch /etc/gitlab/skip-auto-reconfigure

禁用了自動reconfigure使得跳過了數據庫升級,接下來升級12.3.4失敗:

Your current database version is too old to be migrated. You should upgrade to GitLab 11.11.0 before moving to this version.

官方建議卸載Gitlab後安裝11.11.x版本。不過,服務器上有Gitlab備份,所以直接回滾到最初的11.10.4版本,從頭再來。

坑2:11.11.x至12.3.4提示數據庫缺少字段

爲了避免更新過程中reconfigure失敗,編輯‘/etc/gitlab/gitlab.rb’,禁用lets encrypt:

letsencrypt['enable'] = false

但是在升級到12.3.4時,提示以下錯誤:

Exception: Your database is missing the 'parent_id' column from the 'epics' table that is present for GitLab EE.
Even though it looks like you're running a CE installation, it appears
you may have installed GitLab EE at some point. To migrate to GitLab 12.0:

 1. Install GitLab 11.11.3 EE
 2. Install GitLab 12.0.x CE

因爲從沒用過Gitlab EE版本,而且是從11.11.8 CE回退到11.11.3 EE,所以這個提示很莫名奇妙。基於這個討論中的信息,加上有備份,所以還是試了試。
同時參考官方的建議更新順序,先升到12.0.2後。

總結

  1. 升級前一定要:備份!備份!備份!
  2. 關閉‘/etc/gitlab/gitlab.rb’中的Lets Encrypt開關
  3. 升級順序:11.10.4(初始版本)-> 11.11.8 CE -> 11.11.3 EE -> 12.0.2 CE -> 12.3.4 CE(20191006最新版)
  4. 開啓Lets Encrypt開關,執行’gitlab-ctl reconfigure’更新證書

檢查版本

sudo gitlab-rake gitlab:env:info
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章