gitlab遷移方案
需求
- gitlab-hz.rubikstack.com 倉庫是容器形式,不穩定,期望改成在物理機上面直接部署gitlab應用
- 目前存在多個gitlab倉庫,需要合並成一個
- gitlab版本升級到最新
方案一:
- 手動刪除gitlab.cjy.com、gitlab-hz.cjy.com中不存在項目的群組、用戶(已過濾一遍)
- gitlab-hz.cjy.com整體遷移到新的物理機環境上
(通過命令遷移,gitlab版本目前為9.4.1,需升級到 13.10.2)
步驟:
版本升級需經歷版本
9.4.1-->9.5.9-->10.8.7-->11.0.1-->11.11.8-->12.0.1-->12.10.14-->13.0.1-->13.0.14-->13.10.2
- 在新物理機中搭建版本為9.4.1的gitlab
#設置鏡像倉庫
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
#安裝9.4.1版本
yum install gitlab-ce-9.4.1-ce.0.el7.x86_64 -y
#查看安裝版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
#給gitlab服務綁定域名
vim /etc/gitlab/gitlab.rb
#填寫你指定的綁定域名和端口,默認是80端口
external_url 'http://gitlab.ciika.com'
#更新配置
gitlab-ctl reconfigure
#重啟
gitlab-ctl restart
#訪問地址
http://gitlab.ciika.com
- 在gitlab-hz.cjy.com對應的物理機中備份數據,並且拷貝到新的物理機中
#備份數據
gitlab-rake gitlab:backup:create
#拷貝數據
SCP DC_Group.tar.gz 10.110.18.93:/var/opt/gitlab/git-data/
- 在新的物理機上恢復數據
#恢復數據
gitlab-rake gitlab:backup:restore BACKUP=1617862575_2021_04_08_9.4.1
#更新配置
gitlab-ctl reconfigure
#重啟
gitlab-ctl restart
#訪問gitlab地址
每次升級版本之后,都需要驗證一下,地址是否能夠訪問
- 按照版本列表,循環執行下面操作
#更新版本號,X.X.X為版本號
yum install gitlab-ce-X.X.X-ce.0.el7.x86_64 -y
#更新配置
gitlab-ctl reconfigure
#重啟
gitlab-ctl restart
- gitlab.cjy.com倉庫遷移,需寫代碼配合
參考鏈接:http://www.uml.org.cn/pzgl/201901223.asp
遇到的問題:
- 安裝12.10.14之后出現 deploy in process
解決方式:
gitlab-ctl deploy-page status
gitlab-ctl deploy-page down
2.安裝13.0.1和13.0.14出現502
解決方式:
編輯/etc/gitlab/gitlab.rb
puma['enabled'] = true
# this can be any port so long as it matches gitlab_workhorse['auth_backend']
puma['port'] = 8098
unicorn['enabled'] = false
gitlab_workhorse['auth_backend'] = "http://localhost:8098"