gitlab仓库迁移方案

gitlab迁移方案

需求

  1. gitlab-hz.rubikstack.com 仓库是容器形式,不稳定,期望改成在物理机上面直接部署gitlab应用
  2. 目前存在多个gitlab仓库,需要合并成一个
  3. gitlab版本升级到最新

方案一:

  1. 手动删除gitlab.cjy.com、gitlab-hz.cjy.com中不存在项目的群组、用户(已过滤一遍
  2. 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

  1. 在新物理机中搭建版本为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

  1. 在gitlab-hz.cjy.com对应的物理机中备份数据,并且拷贝到新的物理机中
#备份数据
gitlab-rake gitlab:backup:create

#拷贝数据
SCP DC_Group.tar.gz 10.110.18.93:/var/opt/gitlab/git-data/


  1. 在新的物理机上恢复数据
#恢复数据
gitlab-rake gitlab:backup:restore BACKUP=1617862575_2021_04_08_9.4.1

#更新配置
gitlab-ctl reconfigure

#重启
gitlab-ctl restart

#访问gitlab地址
每次升级版本之后,都需要验证一下,地址是否能够访问

  1. 按照版本列表,循环执行下面操作
#更新版本号,X.X.X为版本号
yum install gitlab-ce-X.X.X-ce.0.el7.x86_64 -y

#更新配置
gitlab-ctl reconfigure

#重启
gitlab-ctl restart

  1. gitlab.cjy.com仓库迁移,需写代码配合
    参考链接:http://www.uml.org.cn/pzgl/201901223.asp

遇到的问题:

  1. 安装12.10.14之后出现 deploy in process

解决方式:

gitlab-ctl deploy-page status

gitlab-ctl deploy-page down

2.安装13.0.1和13.0.14出现502

解决方式:

参考地址:https://forum.gitlab.com/t/502-whoops-gitlab-is-taking-too-much-time-to-respond-after-13-x-update/39109/8

编辑/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"

方案二:

手动删除gitlab.cjy.com、gitlab-hz.cjy.com中不存在项目的群组

通过代码将仓库合并到同一个(相关过滤逻辑等)

原文地址:https://www.cnblogs.com/cjyboy/p/14658270.html