gitlab runner 500錯誤

解決辦法1

gitlab-rails console
Ci::Runner.all.update_all(token_encrypted: nil)

並重啟gitlab

解決辦法2

gitlab-rails dbconsole
gitlabhq_production=> UPDATE projects SET runners_token = null, runners_token_encrypted = null;
gitlabhq_production=> UPDATE namespaces SET runners_token = null, runners_token_encrypted = null;
gitlabhq_production=> UPDATE application_settings SET runners_registration_token_encrypted = null;

並重啟gitlab

reference

https://blog.csdn.net/qq_15904277/article/details/90751271

遷移gitlab

我自建的gitlab是跑在synology上,不過因為效能太差了
因此決定將gitlab移植到vm上.

之前測試了讓vm掛載synology網芳的gitlab data的資料夾,
但是都會發生權限的問題.

因此目前打算讓gitlab data的資料夾也放在vm的本機端.
再透過定期備份的方式,來保全資料.
以下是我移機的紀錄

備份
[code lang=”bash”]docker exec -it gitlab gitlab-rake gitlab:backup:create[/code]

還原-前置工作
建立資料夾
[code lang=”bash”]mkdir -p $PWD/files/data/backups
mkdir -p $PWD/files/conf
mkdir -p $PWD/files/log/[/code]

複製備份資料
[code lang=”bash”]cp $OLD_GITLAB_PATH/backups/1510018625_2017_11_07_10.1.0_gitlab_backup.tar $PWD/files/data/backups[/code]

執行新的gitlab
[code lang=”bash”]docker run -d \
–name=gitlab \
–publish 443:443 \
–publish 80:80 \
–restart always \
-v $PWD/files/conf:/etc/gitlab \
-v $PWD/files/log:/var/log/gitlab \
-v $PWD/files/data:/var/opt/gitlab \
gitlab/gitlab-ce:10.1.0-ce.0[/code]

等待兩三分鐘後,確定可以進入gitlab web ui介面後
開始進入還原工作

還原
進入container
[code lang=”bash”]docker exec -it gitlab bash[/code]

停止服務
[code lang=”bash”]gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq[/code]

設定權限
[code lang=”bash”]chmod 777 /var/opt/gitlab/backups/1510018625_2017_11_07_10.1.0_gitlab_backup.tar[/code]

還原
[code lang=”bash”]gitlab-rake gitlab:backup:restore BACKUP=1510018625_2017_11_07_10.1.0[/code]

重啟服務
[code lang=”bash”]gitlab-ctl restart[/code]

check
[code lang=”bash”]gitlab-rake gitlab:check SANITIZE=true[/code]

用docker架設gitlab server

首先需準備好ssl憑證,這部分可參考Let’s Encrypt
建立conf,data,log,ssl等資料夾於$PWD/files之下.

mkdir -p $PWD/files/conf
mkdir -p $PWD/files/log
mkdir -p $PWD/files/data
mkdir -p $PWD/files/ssl

並把fullchain.pem以及private.pem放在$PWD/files/ssl資料夾下,
接著用下列語法,就可以用docker架設gitlab server了

docker run -d \
  --name=gitlab \
  --hostname git.slanla.com \
  --env GITLAB_OMNIBUS_CONFIG="external_url 'https://git.slanla.com' ; nginx['redirect_http_to_https'] = true" ; gitlab_rails['backup_keep_time'] = 604800 ; \
  --publish 443:443 \
  --publish 80:80 \
  --restart always \
  -v $PWD/files/ssl/fullchain.pem:/etc/gitlab/ssl/git.slanla.com.crt \
  -v $PWD/files/ssl/privkey.pem:/etc/gitlab/ssl/git.slanla.com.key \
  -v $PWD/files/conf:/etc/gitlab \
  -v $PWD/files/log:/var/log/gitlab \
  -v $PWD/files//data:/var/opt/gitlab \
  gitlab/gitlab-ce:10.1.0-ce.0

其中

--hostname git.slanla.com \
--env GITLAB_OMNIBUS_CONFIG="external_url 'https://git.slanla.com';nginx['redirect_http_to_https'] = true" \
--publish 443:443 \
-v $PWD/files/ssl/fullchain.pem:/etc/gitlab/ssl/git.slanla.com.crt \
-v $PWD/files/ssl/privkey.pem:/etc/gitlab/ssl/git.slanla.com.key \

是與https相關,若不需要則可移除.