前提
だいぶ古い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のインストール ※エラー有
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):
chown -R git:git /opt/gitlab/embedded/service/gitlab-rails/tmp/cache/assets/sprockets/v3.0/
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
問題なし
9.5.10のインストール
yum install -y gitlab-ce-9.5.10
gitlab-ctl reconfigure
gitlab-ctl restart
OK
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
yum install -y gitlab-ce-10.8.7
gitlab-ctl reconfigure
gitlab-ctl restart
OK
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
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
OK
12.0.12のインストール
yum install -y gitlab-ce-12.0.12
gitlab-ctl reconfigure
gitlab-ctl restart
OK
12.1.17のインストール
yum install -y gitlab-ce-12.1.17
gitlab-ctl reconfigure
gitlab-ctl restart
OK
12.10.14のインストール
yum install -y gitlab-ce-12.10.14
gitlab-ctl reconfigure
gitlab-ctl restart
OK
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.
gitlab-ctl pg-upgrade -V 11
yum install -y gitlab-ce-13.0.14
gitlab-ctl reconfigure
gitlab-ctl restart
OK
13.1.11のインストール
yum install -y gitlab-ce-13.1.11
gitlab-ctl reconfigure
gitlab-ctl restart
OK
13.8.8のインストール
yum install -y gitlab-ce-13.8.8
gitlab-ctl reconfigure
gitlab-ctl restart
OK
13.12.15のインストール
yum install -y gitlab-ce-13.12.15
gitlab-ctl reconfigure
gitlab-ctl restart
OK
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.
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
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.
gitlab-ctl pg-upgrade -V 12
gitlab-ctl reconfigure
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
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.
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
yum install -y gitlab-ce-14.0.12
gitlab-ctl reconfigure
gitlab-ctl restart
OK
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
OK
14.9.5のインストール
yum install -y gitlab-ce-14.9.5
gitlab-ctl reconfigure
gitlab-ctl restart
OK
14.10.5のインストール
yum install -y gitlab-ce-14.10.5
gitlab-ctl reconfigure
gitlab-ctl restart
OK
15.0.5のインストール
yum install -y gitlab-ce-15.0.5
gitlab-ctl reconfigure
gitlab-ctl restart
OK
15.4.5のインストール
※no_proxy環境変数が正しく動作しない可能性があるので、15.4.6は回避していますyum install -y gitlab-ce-15.4.5
gitlab-ctl reconfigure
gitlab-ctl restart
OK
16.0.7のインストール ※エラー有
yum install -y gitlab-ce-16.0.7
gitlab preinstall: Your version of PostgreSQL is no longer supported. Please upgrade your PostgreSQL version to 13.
gitlab-ctl pg-upgrade -V 13
yum install -y gitlab-ce-16.0.7
gitlab-ctl reconfigure
gitlab-ctl restart
OK
最後に
本当に長い戦いでした・・・。待ち時間も多いので実際1週間程度は作業をしていたかと思います。
全て先人達の知恵をお借りして解決できましたが、これからこまめにアップデートしていこう・・・。