GitLab Community Edition 14.3.3を最新バージョンへアップデート
目次
概要
Raspberry Pi 4 Model B 8GBへインストール済みのGitLab Community Edition 14.3.3を 2021/12/2時点で最新バージョンの14.5.1へアップデートします。 公式ドキュメントに沿ったやり方(と言っても一般的なパッケージ更新手順と同じですが)で実施します。 アップデートは単にソフトウェアを最新化するだけではなく、アップデートの過程で データベースのバックアップ、リストアなども自動で行ってくれますので、 アップデートコマンドだけ実行すれば新バージョンに合わせてデータの移行も完了します。 今回は同じメジャーバージョン14の範囲でのアップデートでしたが、アップデートのログを見ていると 異なるバージョンでもデータの移行は問題なくできそうに見えました(想像)。
構成
サーバ構成
OS
AlmaLinux release 8.4 (Electric Cheetah) aarch64
インストール済み主要パッケージ
- gitlab-ce-14.5.1-ce.0.el8.aarch64.rpm
- postfix-3.5.8-1.el8.aarch64.rpm
手順
GitLabのアップデート
インストール済みパッケージのバージョン確認
アップデート前に現在のGitLabのバージョンを確認します。 以下の例では14.3.3のバージョンとなっています。
# rpm -qa | grep gitlab-ce gitlab-ce-14.3.3-ce.0.el8.aarch64
YUMリポジトリの登録(未実施の場合のみ)
GitLabのアップデートは公式のYUMリポジトリから最新バージョンのパッケージをダウンロードしてインストールします。 もしYUMリポジトリを登録していない、もしくは削除してしまっている場合は登録する必要があります。 GitLabのYUMリポジトリを登録するためのシェルスクリプトが公開されているので、curlコマンドでダウンロードして実行します。
# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 6928 100 6928 0 0 16301 0 --:--:-- --:--:-- --:--:-- 16301 Detected operating system as almalinux/8. Checking for curl... Detected curl... Downloading repository file: https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.repo?os=almalinux&dist=8&source=script done. Installing yum-utils... gitlab_gitlab-ce-source 461 B/s | 862 B 00:01 Package yum-utils-4.0.21-3.el8.noarch is already installed. Dependencies resolved. Nothing to do. Complete! Generating yum cache for gitlab_gitlab-ce... Generating yum cache for gitlab_gitlab-ce-source... The repository is setup! You can now install packages.
GitLabのアップデート
GitLabを公式のYUMリポジトリからdnf(yum)コマンドでインストールしている場合は、 アップデート方法もdnf(yum)コマンドを実行するだけです。 dnf(yum)でアップデートすると、単にパッケージを最新化するだけでなく、 GitLabの停止や起動、DBに登録されているプロジェクト情報などのバックアップやリストアなども自動でやってくれます。 なのでアップデートコマンドを実行するだけでデータはそのまま使える形で維持されます。 今回はあくまでアップデートなのですが、公式ドキュメントではdnf(yum)のコマンドが update ではなく install と書かれていたので、 そのとおり実行しましたが特に問題ありませんでした。
# dnf -y install gitlab-ce
Last metadata expiration check: 0:00:23 ago on Thu 02 Dec 2021 06:39:18 AM JST.
Package gitlab-ce-14.3.3-ce.0.el8.aarch64 is already installed.
Dependencies resolved.
========================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================
Upgrading:
gitlab-ce aarch64 14.5.1-ce.0.el8 gitlab_gitlab-ce 908 M
Transaction Summary
========================================================================================================================
Upgrade 1 Package
Total download size: 908 M
Downloading Packages:
gitlab-ce-14.5.1-ce.0.el8.aarch64.rpm 11 MB/s | 908 MB 01:24
------------------------------------------------------------------------------------------------------------------------
Total 11 MB/s | 908 MB 01:25
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: gitlab-ce-14.5.1-ce.0.el8.aarch64 1/2
gitlab preinstall: Checking for unmigrated data on legacy storage
gitlab preinstall: Automatically backing up only the GitLab SQL database (excluding everything else!)
2021-12-02 06:45:28 +0900 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2021-12-02 06:45:49 +0900 -- done
2021-12-02 06:45:49 +0900 -- Dumping repositories ...
2021-12-02 06:45:49 +0900 -- [SKIPPED]
2021-12-02 06:45:49 +0900 -- Dumping uploads ...
2021-12-02 06:45:49 +0900 -- [SKIPPED]
2021-12-02 06:45:49 +0900 -- Dumping builds ...
2021-12-02 06:45:49 +0900 -- [SKIPPED]
2021-12-02 06:45:49 +0900 -- Dumping artifacts ...
2021-12-02 06:45:49 +0900 -- [SKIPPED]
2021-12-02 06:45:49 +0900 -- Dumping pages ...
2021-12-02 06:45:49 +0900 -- [SKIPPED]
2021-12-02 06:45:49 +0900 -- Dumping lfs objects ...
2021-12-02 06:45:49 +0900 -- [SKIPPED]
2021-12-02 06:45:49 +0900 -- Dumping container registry images ...
2021-12-02 06:45:49 +0900 -- [DISABLED]
Creating backup archive: 1638395149_2021_12_02_14.3.3_gitlab_backup.tar ... done
Uploading backup archive to remote storage ... skipped
Deleting tmp directories ... done
done
Deleting old backups ... skipping
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data
and are not included in this backup. You will need these files to restore a backup.
Please back them up manually.
Backup task is done.
gitlab preinstall: Automatically backing up /etc/gitlab
Could not find '/etc/gitlab/config_backup' directory. Creating.
Running configuration backup
Creating configuration backup archive: gitlab_config_1638395158_2021_12_02.tar
/etc/gitlab/
/etc/gitlab/gitlab.rb.bk20211017
/etc/gitlab/gitlab-secrets.json
/etc/gitlab/initial_root_password
/etc/gitlab/trusted-certs/
/etc/gitlab/gitlab.rb.bk20211017a
/etc/gitlab/gitlab.rb
Configuration backup archive complete: /etc/gitlab/config_backup/gitlab_config_1638395158_2021_12_02.tar
Keeping all older configuration backups
Upgrading : gitlab-ce-14.5.1-ce.0.el8.aarch64 1/2
Running scriptlet: gitlab-ce-14.5.1-ce.0.el8.aarch64 1/2
Cleanup : gitlab-ce-14.3.3-ce.0.el8.aarch64 2/2
Running scriptlet: gitlab-ce-14.3.3-ce.0.el8.aarch64 2/2
Running scriptlet: gitlab-ce-14.5.1-ce.0.el8.aarch64 2/2
Checking PostgreSQL executables:Starting Chef Infra Client, version 15.17.4
resolving cookbooks for run list: ["gitlab::config", "postgresql::bin"]
Synchronizing Cookbooks:
- postgresql (0.1.0)
- gitlab (0.0.1)
- logrotate (0.1.0)
- package (0.1.0)
- redis (0.1.0)
- registry (0.1.0)
- monitoring (0.1.0)
- mattermost (0.1.0)
- gitaly (0.1.0)
- consul (0.1.0)
- letsencrypt (0.1.0)
- nginx (0.1.0)
- praefect (0.1.0)
- gitlab-pages (0.1.0)
- runit (5.1.3)
- crond (0.1.0)
- gitlab-kas (0.1.0)
- acme (4.1.3)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 4 resources
Recipe: postgresql::bin
* ruby_block[check_postgresql_version] action run (skipped due to not_if)
* ruby_block[check_postgresql_version_is_deprecated] action run (skipped due to not_if)
* ruby_block[Link postgresql bin files to the correct version] action run (skipped due to only_if)
* template[/opt/gitlab/etc/gitlab-psql-rc] action create (up to date)
Running handlers:
Running handlers complete
Chef Infra Client finished, 0/4 resources updated in 23 seconds
Checking PostgreSQL executables: OK
Checking for an omnibus managed postgresql: OKlable and attempting automatic upgrade to it:
Checking if postgresql['version'] is set: OK
Checking if we already upgraded: OK
The latest version 12.7 is already running, nothing to do
Checking if a newer PostgreSQL version is available and attempting automatic upgrade to it: OK
Shutting down all GitLab services except those needed for migrations
ok: down: alertmanager: 0s, normally up
ok: down: gitlab-exporter: 0s, normally up
ok: down: gitlab-workhorse: 0s, normally up
ok: down: grafana: 1s, normally up
ok: down: logrotate: 0s, normally up
ok: down: nginx: 0s, normally up
ok: down: node-exporter: 0s, normally up
ok: down: postgres-exporter: 1s, normally up
timeout: run: prometheus: (pid 187087) 34s, want down, got TERM
ok: down: puma: 0s, normally up
ok: down: redis-exporter: 1s, normally up
ok: down: sidekiq: 1s, normally up
Ensuring the required services are running
ok: run: postgresql: (pid 1219) 107805s
ok: run: redis: (pid 1222) 107805s
ok: run: gitaly: (pid 1220) 107805s
run: postgresql: (pid 1219) 107805s; run: log: (pid 1218) 107805s
run: redis: (pid 1222) 107805s; run: log: (pid 1221) 107805s
run: gitaly: (pid 1220) 107805s; run: log: (pid 1210) 107805s
Ensuring Prometheus is updated:Already running Prometheus version 2.
Ensuring Prometheus is updated: OK
Reconfigure GitLab to apply migrations
Starting Chef Infra Client, version 15.17.4
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
- gitlab (0.0.1)
- package (0.1.0)
- logrotate (0.1.0)
- postgresql (0.1.0)
- registry (0.1.0)
- mattermost (0.1.0)
- monitoring (0.1.0)
- gitaly (0.1.0)
- redis (0.1.0)
- gitlab-pages (0.1.0)
- gitlab-kas (0.1.0)
- nginx (0.1.0)
- letsencrypt (0.1.0)
- consul (0.1.0)
- runit (5.1.3)
- praefect (0.1.0)
- crond (0.1.0)
- acme (4.1.3)
Installing Cookbook Gems:
Compiling Cookbooks...
( ========== 中略 ========== )
Notes:
Found old initial root password file at /etc/gitlab/initial_root_password and deleted it.
gitlab Reconfigured!
Restarting previously running GitLab services
ok: run: alertmanager: (pid 187713) 0s
ok: run: gitaly: (pid 1220) 108084s
ok: run: gitlab-exporter: (pid 187716) 1s
ok: run: gitlab-workhorse: (pid 187691) 2s
ok: run: grafana: (pid 187723) 0s
ok: run: logrotate: (pid 187727) 1s
ok: run: nginx: (pid 187733) 0s
ok: run: node-exporter: (pid 187736) 1s
ok: run: postgres-exporter: (pid 187705) 4s
ok: run: postgresql: (pid 1219) 108087s
ok: run: prometheus: (pid 187744) 0s
ok: run: puma: (pid 187749) 0s
ok: run: redis: (pid 1222) 108087s
ok: run: redis-exporter: (pid 187757) 0s
ok: run: sidekiq: (pid 187761) 0s
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Upgrade complete! If your GitLab server is misbehaving try running
sudo gitlab-ctl restart
before anything else.
If you need to roll back to the previous version you can use the database
backup made during the upgrade (scroll up for the filename).
Running scriptlet: gitlab-ce-14.3.3-ce.0.el8.aarch64 2/2
Verifying : gitlab-ce-14.5.1-ce.0.el8.aarch64 1/2
Verifying : gitlab-ce-14.3.3-ce.0.el8.aarch64 2/2
Upgraded:
gitlab-ce-14.5.1-ce.0.el8.aarch64
Complete!
アップデート後のバージョン確認
アップデート後にパッケージのバージョンが14.3.3から14.5.1に上がっていることを確認します。
# rpm -qa | grep gitlab-ce gitlab-ce-14.5.1-ce.0.el8.aarch64
アップデート後のGitLabのステータス確認
アップデート後に念の為GitLabの構成機能がすべて起動していることを確認します。
# gitlab-ctl status run: alertmanager: (pid 187713) 358s; run: log: (pid 1245) 108442s run: gitaly: (pid 187800) 333s; run: log: (pid 1210) 108442s run: gitlab-exporter: (pid 187716) 358s; run: log: (pid 1232) 108442s run: gitlab-workhorse: (pid 187691) 359s; run: log: (pid 1230) 108442s run: grafana: (pid 187723) 357s; run: log: (pid 1248) 108442s run: logrotate: (pid 187727) 357s; run: log: (pid 1217) 108442s run: nginx: (pid 187733) 356s; run: log: (pid 1237) 108442s run: node-exporter: (pid 187736) 356s; run: log: (pid 1231) 108442s run: postgres-exporter: (pid 187705) 359s; run: log: (pid 1243) 108442s run: postgresql: (pid 1219) 108442s; run: log: (pid 1218) 108442s run: prometheus: (pid 188192) 41s; run: log: (pid 1240) 108442s run: puma: (pid 187749) 355s; run: log: (pid 1212) 108442s run: redis: (pid 1222) 108442s; run: log: (pid 1221) 108442s run: redis-exporter: (pid 187757) 354s; run: log: (pid 1247) 108442s run: sidekiq: (pid 187761) 354s; run: log: (pid 1235) 108442s