LoginSignup
4
0

GitLab 8.14.5 → 16.0.7 へのアップデート

Last updated at Posted at 2023-08-01

前提

だいぶ古いGitLabバージョンを利用していることもあり、使いたい機能がなかったり
セキュリティ的にもよろしくないのでアップデートを行いました。

環境

CentOS7.2
GitLab CE
メモリ16GB
容量 rootディスク 50GB (30GB以上は必要です)

GitLab のアップデートパス

GitLabのアップデートは何度も対象のバージョンを経由する必要があり
8系からのバージョンアップになると中々大変な作業になります。

https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/
公式より、対象バージョンパスルートを指定してくれるツールがあったので、
指定通りに最新まで上げるとなると19回のバージョンアップが必要...

8.14.5(イマココ)
-> 8.17.7
-> 9.5.10
-> 10.8.7
-> 11.11.8
-> 12.0.12 -> 12.1.17 -> 12.10.14
-> 13.0.14 -> 13.1.11 -> 13.8.8 -> 13.12.15
-> 14.0.12 -> 14.3.6 -> 14.9.5 -> 14.10.5
-> 15.0.5 -> 15.4.6 -> 15.11.13
-> 16.0.7

とのことで、頑張って順番にあげていきます。

アップデートの前に

  • バックアップ手順は省略していますがバージョンアップ毎に取るほうがよいです(これだけの量だと現実的じゃないですが・・)
  • メモリが4GBだと不足してスワップ領域必要になったので、8GB以上は体感必要そうです。
  • バージョンアップ時は、サービスを起動した状態で行う必要があります。停止してバージョンアップすると後戻りできない問題が発生します
  • gitlab-ctl reconfigureは コマンドが帰ってきた後でも後ろで動いており、2~3分待つ必要があります。その間にブラウザ確認すると502エラーが返ってきます。
  • 正しくない手順も含まれているかもしれませんのであくまでも参考程度にお願いします

アップデート手順

8.17.7のインストール ※エラー有
8.17.8のインストール
yum install -y gitlab-ce-8.17.8
再構築
gitlab-ctl reconfigure
エラー
==> /var/log/gitlab/gitlab-rails/production.log <==
Errno::EACCES (Permission denied @ rb_sysopen - /opt/gitlab/embedded/service/gitlab-rails/tmp/cache/assets/sprockets/v3.0/Nx/NxfdrxZbqh3UuLESX9ChvLXcMtDlzeXedTyGfWM0AcI.cache.70268829331760.93437.682693):
権限エラーなので対象のディレクトリ全てをgit:gitに変更してみる
chown -R git:git /opt/gitlab/embedded/service/gitlab-rails/tmp/cache/assets/sprockets/v3.0/
Web確認すると別のエラーが
ExecJS::Error (ExecJS disabled)
設定変更
vim /opt/gitlab/embedded/service/gitlab-rails/config/environments/production.rb
- config.assets.compile = true
+ config.assets.compile = false

参考:https://gitlab.com/gitlab-org/gitlab-foss/-/issues/28743

再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Web確認
問題なし
9.5.10のインストール
9.5.10のインストール
yum install -y gitlab-ce-9.5.10
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Web確認
OK
10.8.7のインストール ※エラー有
10.8.7のインストール
yum install -y gitlab-ce-10.8.7
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
エラー
Backup failed
[FAILED]
gitlab preinstall:
gitlab preinstall: Backup failed! If you want to skip this backup, run the following command and
gitlab preinstall: try again:
gitlab preinstall:
gitlab preinstall:   sudo touch /etc/gitlab/skip-auto-migrations
gitlab preinstall:
error: %pre(gitlab-ce-10.8.7-ce.0.el7.x86_64) scriptlet failed, exit status 1
Error in PREIN scriptlet in rpm package gitlab-ce-10.8.7-ce.0.el7.x86_64
エラー内容通りマイグレーションをスキップ
touch /etc/gitlab/skip-auto-migrations
再度 10.8.7のインストール
yum install -y gitlab-ce-10.8.7
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
11.11.8 のインストール ※エラー有
11.11.8 のインストール
yum install -y gitlab-ce-11.11.8
再構築
gitlab-ctl reconfigure
下記のエラー
There was an error running gitlab-ctl reconfigure:
no implicit conversion of nil into String
/etc/gitlab/gitlab.rb を更新
vim /etc/gitlab/gitlab.rb

+ #git_data_dirs({"default" => "/hoge/gitlab/git-data"})
+ git_data_dirs({"default" => { "path" => "/hoge/gitlab/git-data"}})

参考:https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/3189

再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
12.0.12のインストール
12.0.12 のインストール
yum install -y gitlab-ce-12.0.12
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
12.1.17のインストール
12.1.17 のインストール
yum install -y gitlab-ce-12.1.17
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
12.10.14のインストール
12.10.14 のインストール
yum install -y gitlab-ce-12.10.14
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
13.0.14のインストール ※エラー有
13.0.14 のインストール
yum install -y gitlab-ce-13.0.14
下記のエラー
gitlab preinstall: Your version of PostgreSQL is no longer supported. Please upgrade your PostgreSQL version to 11.
gitlab preinstall: Upgrade failed. Retry the upgrade after upgrading your PostgreSQL version.
PostgreSQL のバージョンアップ
gitlab-ctl pg-upgrade -V 11
再度13.0.14 のインストール
yum install -y gitlab-ce-13.0.14
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
13.1.11のインストール
13.1.11 のインストール
yum install -y gitlab-ce-13.1.11
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
13.8.8のインストール
13.8.8 のインストール
yum install -y gitlab-ce-13.8.8
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
13.12.15のインストール
13.12.15 のインストール
yum install -y gitlab-ce-13.12.15
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
14.0.12のインストール ※エラー有
14.0.12のインストール
yum install -y gitlab-ce-14.0.12
下記のエラー
* unicorn['worker_timeout'] has been deprecated since 13.10 and was removed in 14.0. Starting with GitLab 14.0, Unicorn is no longer supported and users must switch to Puma, following https://docs.gitlab.com/ee/administration/operations/puma.html.
* unicorn['worker_memory_limit_max'] has been deprecated since 13.10 and was removed in 14.0. Starting with GitLab 14.0, Unicorn is no longer supported and users must switch to Puma, following https://docs.gitlab.com/ee/administration/operations/puma.html.
Deprecations found. Please correct them and try again.  
unicorn を廃止して Pumaに変更
vim /etc/gitlab/gitlab.rb
+ unicorn['worker_timeout'] = 1800
+ # unicorn['worker_timeout'] = 1800

+ unicorn['worker_memory_limit_max'] = "6500 * 1 << 20"
+ # unicorn['worker_memory_limit_max'] = "6500 * 1 << 20"

※下記新規追加
##################
# GitLab Puma#
##################
puma['worker_timeout'] = 1800
puma['worker_memory_limit_max'] = "6500 * 1 << 20"

再構築
gitlab-ctl reconfigure
再度14.0.12のインストール
yum install -y gitlab-ce-14.0.12
下記のエラー
gitlab preinstall: Your version of PostgreSQL is no longer supported. Please upgrade your PostgreSQL version to 12.
gitlab preinstall: Check https://docs.gitlab.com/omnibus/settings/database.html#upgrade-packaged-postgresql-server for details.
gitlab preinstall:
gitlab preinstall: Upgrade failed. Retry the upgrade after upgrading your PostgreSQL version.
PostgreSQL のバージョンアップ
gitlab-ctl pg-upgrade -V 12
再構築
gitlab-ctl reconfigure
再度14.0.12のインストール
yum install -y gitlab-ce-14.0.12
下記のエラー
unning transaction
gitlab preinstall: Checking for unmigrated data on legacy storage
gitlab preinstall:
gitlab preinstall: Legacy storage is no longer supported. Please migrate your data to hashed storage.
gitlab preinstall: Check https://docs.gitlab.com/ee/administration/raketasks/storage.html#migrate-to-hashed-storage for details.
gitlab preinstall:
gitlab preinstall: If you want to skip this check, run the following command and try again:
gitlab preinstall:
gitlab preinstall:  sudo touch /etc/gitlab/skip-unmigrated-data-check
レガシーデータ移行
gitlab-rake gitlab:storage:migrate_to_hashed
再度14.0.12のインストール
yum install -y gitlab-ce-14.0.12
同様のエラー表示。レガシーデータが移行されていない?
unning transaction
gitlab preinstall: Checking for unmigrated data on legacy storage
gitlab preinstall:
gitlab preinstall: Legacy storage is no longer supported. Please migrate your data to hashed storage.
base_repository_service.rb に読み取り専用を回避するように追記
vim /opt/gitlab/embedded/service/gitlab-rails/app/services/projects/hashed_storage/base_repository_service.rb

+        if err.message == "Repository already read-only"
+          return
+        end

参考:https://gitlab.com/gitlab-org/gitlab/-/issues/289816

再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
レガシーデータ移行
gitlab-rake gitlab:storage:migrate_to_hashed
再度14.0.12のインストール
yum install -y gitlab-ce-14.0.12
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
14.3.6のインストール ※エラー有
14.3.6 のインストール
yum install -y gitlab-ce-14.3.6
再構築
gitlab-ctl reconfigure
下記のエラー
Finalize it manualy by running

sudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,ci_builds,id,'[["id"\, "stage_id"]\, ["id_convert_to_bigint"\, "stage_id_convert_to_bigint"]]']

エラー内容通りにコマンド実行
gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,ci_builds,id,'[["id"\, "stage_id"]\, ["id_convert_to_bigint"\, "stage_id_convert_to_bigint"]]']
gitlab-rake db:migrate
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
14.9.5のインストール
14.9.5 のインストール
yum install -y gitlab-ce-14.9.5
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
14.10.5のインストール
14.10.5 のインストール
yum install -y gitlab-ce-14.10.5
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
15.0.5のインストール
15.0.5 のインストール
yum install -y gitlab-ce-15.0.5
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
15.4.5のインストール ※no_proxy環境変数が正しく動作しない可能性があるので、15.4.6は回避しています

※参考
https://docs.gitlab.com/ee/update/#:~:text=Due%20to%20a%20bug%20introduced%20in%20curl%20in%20GitLab%2015.4.6%2C%20the%20no_proxy%20environment%20variable%20may%20not%20work%20properly.%20Either%20downgrade%20to%20GitLab%2015.4.5%2C%20or%20upgrade%20to%20GitLab%2015.5.7%20or%20a%20later%20version.

15.4.5 のインストール
yum install -y gitlab-ce-15.4.5
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK
16.0.7のインストール ※エラー有
16.0.7 のインストール
yum install -y gitlab-ce-16.0.7
下記のエラー(PostgreSQLが低い)
gitlab preinstall: Your version of PostgreSQL is no longer supported. Please upgrade your PostgreSQL version to 13.
PostgreSQLを13にバージョンアップ
gitlab-ctl pg-upgrade -V 13
再度16.0.7 のインストール
yum install -y gitlab-ce-16.0.7
再構築
gitlab-ctl reconfigure
再起動
gitlab-ctl restart
Webでバージョン確認
OK

最後に

本当に長い戦いでした・・・。待ち時間も多いので実際1週間程度は作業をしていたかと思います。
全て先人達の知恵をお借りして解決できましたが、これからこまめにアップデートしていこう・・・。

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0