GitLab導入でつまずいたところ

概要

GitLabは容易にインストール出来ますが、ちょっとした手順の間違い等で色々トラブルに巻き込まれました。
備忘録として、その内容を記録しておきます。

OSはAlmaLinux(8.6)でこちらの記事ではすんなりインストール出来たみたいな感じですが、実は色々ありました。

EXTERNAL_URLを指定せずにインストールする

これは仮想環境にて試した結果で、インストール時にEXTERNAL_URLを指定せずにインストールした場合のトラブルと、その対処です。

トラブル内容

リポジトリ登録後に、

dnf install -y gitlab-ce

これは、一部サイトの手順に書いてあるやり方(情報が古い?)でインストール後に設定ファイルである、
"/etc/gitlab/gitlab.rb"
の内容を変更するというものです。
仮想環境にて行ってみました。

EXTERNAL_URL指定無しの場合、"/etc/gitlab/gitlab.rb"の冒頭はデフォルトURLが入った状態でした。

## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
##!
##! Note: During installation/upgrades, the value of the environment variable
##! EXTERNAL_URL will be used to populate/replace this value.
##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'https://gitlab.example.com'

仮想環境はテスト用のため、IPアドレスにてアクセスするために、次の2種類に変更してみました。

## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
##!
##! Note: During installation/upgrades, the value of the environment variable
##! EXTERNAL_URL will be used to populate/replace this value.
##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'http://192.168.***.***'    # サーバーのIPアドレス
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
##!
##! Note: During installation/upgrades, the value of the environment variable
##! EXTERNAL_URL will be used to populate/replace this value.
##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'http://localhost'

変更後はコマンドで設定内容を反映します。

gitlab-ctl reconfigure

少し時間がかかりますが、これでアクセスを試みましたがダメでした。

対処法

対処法は、GitLabを一度アンインストールしてから、再度EXTERNAL_URLを付与して再インストールしました。

まずはアンインストールから。

#サービスの停止
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop nginx
#アンインストール
sudo dnf remove gitlab-ce

次に再インストールします。

sudo EXTERNAL_URL="https://192.168.***.***" dnf install -y gitlab-ce

これで、無事にアクセス出来るようになりました。

サービスがfailで停止する

本番サーバーでの設定の際に、EXTERNAL_URLをhttpsでインストールしてしまいました。

無事、インストール成功したものの、https設定をしていないためアクセスの際に警告が出ました。
そこで一旦アンインストールしてから再インストールすると、インストールが成功したにもかかわらず、アクセス出来ないというトラブルになりました。

とりあえずGitLabの状態を確認してみる。

sudo gitlab-ctl status

出力結果

fail: alertmanager: runsv not running
fail: gitaly: runsv not running
fail: gitlab-exporter: runsv not running
fail: gitlab-workhorse: runsv not running
fail: grafana: runsv not running
fail: logrotate: runsv not running
fail: nginx: runsv not running
fail: node-exporter: runsv not running
fail: postgres-exporter: runsv not running
fail: postgresql: runsv not running
fail: prometheus: runsv not running
fail: puma: runsv not running
fail: redis: runsv not running
fail: redis-exporter: runsv not running
fail: sidekiq: runsv not running

???GitLabのサービスの状態一覧が出てくるのですが、全てfailとなっていました。restartしても同じ。

そこで、設定ファイルを再構成してみます。

sudo gitlab-ctl reconfigure

30分くらいは経ちましたが再構築が終わらない。ネットで症状を検索すると、色々情報が出てきます。どうやら良く知られた不具合の様。(日本語の情報ならこちら、大本の情報はこちらのようです。)

情報どおりのコマンドを実行してみます。

sudo /opt/gitlab/embedded/bin/runsvdir-start &

こちらもなにやら"Fail..."が出てそこから進まないが"Enter"を押してみるとコマンド待ち状態に戻りました。

再度、設定ファイルの再構築をしてみる。

sudo gitlab-ctl reconfigure

おぉ、通った。ブラウザでもログインページが出てきました。何やらよく分からないですが解決しました(笑)

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

one + fourteen =