Gitlab迁移(亲测)
1. 概述
当前gitlab部署在k8s内,根据基础设施设计此处不合理,需将gitlab迁移至主机部署的gitlab
当前位置:k8s 集群
迁移后位置:云主机部署gitlab
2. Gitlab从Kubernetes迁移到Host
Gitlab Kubernetes: GitLab-CE 14.2.3
Gitlab Host : GitLab-CE 14.2.3
2.1 备份恢复过程
旧服务备份数据
备份命令:
gitlab-rake gitlab:backup:create
生成备份文件/opt/gitlab/backups/1547087542_2022_09_02_13.12.15_gitlab_backup.tar
新服务器准备工作
1. 安装gitlab-ce(保证两个服务器的gitlab版本一致)
2. 修改配置文件
```
vim /etc/gitlab/gitlab.rb
external_url 'https://gitlab.xxx.work'
##配置https
nginx['enable'] = true
nginx['redirect_http_to_https'] = true #http重定向到https
nginx['ssl_certificate'] = "/opt/gitlab/ssl/zzz.zzz.crt" #ssl证书路径
nginx['ssl_certificate_key'] = "/opt/gitlab/ssl/zzz.zzz.key" #ssl秘钥路径
##配置LDAP
gitlab_rails['ldap_enabled'] = true
gitlab_rails['prevent_ldap_sign_in'] = false
gitlab_rails['ldap_servers'] = {
'main' => {
'label' => 'LDAP',
'host' => 'xxx.xxx.xxx.xxx',
'port' => 389,
'uid' => 'sAMAccountName',
'bind_dn' => 'CN=gitlab,CN=Users,DC=xxx,DC=com',
'password' => 'xxxx',
'active_directory' => true,
'allow_username_or_email_login' => true,
'block_auto_created_users' => false,
'base' => 'DC=xxx,DC=com',
'user_filter' => ''
}
}
##配置好以上信息后执行重置命令并重启
gitlab-ctl reconfigure
gitlab-ctl restart
3. 将备份文件放到本地
/opt/gitlab/backups/
4. 修改备份文件权限
chmod 777 /opt/gitlab/backups/1547087542_2022_09_02_13.12.15_gitlab_backup.tar
5. 停止unicorn和sidekiq服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
6. 恢复备份数据
gitlab-rake gitlab:backup:restore BACKUP=1547087542_2022_09_02_13.12.15
7. 重启gitlab服务
gitlab-ctl start
2.2恢复过程中遇到错误解决
错误 一:监听问题
Restoring PostgreSQL database gitlabhq_production ... ERROR: must be owner of extension pg_trgm
ERROR: must be owner of extension btree_gist
ERROR: must be owner of extension btree_gist
ERROR: must be owner of extension pg_trgm
解决:
vim /var/opt/gitlab/postgresql/data/postgresql.conf
listen_addresses = '*'
# 最下面新增两行
$ vim /var/opt/gitlab/postgresql/data/pg_hba.conf
local all all trust
host all all 127.0.0.1/32 trust
错误 二:用户问题
psql not ‘postgres’ superuser
解决: $ su - gitlab-psql
$ /opt/gitlab/embedded/bin/psql -h 127.0.0.1 gitlabhq_production
psql (9.2.8)
Type "help" for help. gitlabhq_production=# ALTER USER gitlab WITH SUPERUSER;
ALTER ROLE
gitlabhq_production=# CREATE USER postgres SUPERUSER;
gitlabhq_production=# \q
错误三:恢复后遇到500问题
问题描述:直接将备份恢复后,在页面上随便都会报500错误,日志提示'Object Storage is not enabled',需要按下文开启lfs功能再恢复数据

# Job Artifacts
gitlab_rails['artifacts_enabled'] = true
gitlab_rails['artifacts_path'] = "/var/opt/gitlab/gitlab-rails/shared/artifacts"
####! Job artifacts Object Store
####! Docs: https://docs.gitlab.com/ee/administration/job_artifacts.html#using-object-storage
gitlab_rails['artifacts_object_store_enabled'] = true
gitlab_rails['artifacts_object_store_direct_upload'] = true
gitlab_rails['artifacts_object_store_background_upload'] = true
gitlab_rails['artifacts_object_store_proxy_download'] = true
gitlab_rails['artifacts_object_store_remote_directory'] = "artifacts"
gitlab_rails['artifacts_object_store_connection'] = {
'provider' => 'AWS',
'region' => 'eu-west-1',
'aws_access_key_id' => 'Z1Xh28dpKo0Oc9Xjjq35n0lCceGYxHmGwpibz2WQ9acLtiUTBHftVTKxcLiISSld',
'aws_secret_access_key' => 'ebRmMNRHh9R9ve869SkspkC3xMOyPBmo0FGhud4JqBZu7zjuiMCu36xn7aEVNEeT',
# # The below options configure an S3 compatible host instead of AWS
'aws_signature_version' => 4, # For creation of signed URLs. Set to 2 if provider does not support v4.
'endpoint' => 'http://minio地址:9000', # default: nil - Useful for S3 compliant services such as DigitalOcean Spaces
'host' => 'localhost',
'path_style' => true # Use 'host/bucket_name/object' instead of 'bucket_name.host/object'
} ### Git LFS
gitlab_rails['lfs_enabled'] = true
gitlab_rails['lfs_storage_path'] = "/var/opt/gitlab/gitlab-rails/shared/lfs-objects"
gitlab_rails['lfs_object_store_enabled'] = true
gitlab_rails['lfs_object_store_direct_upload'] = true
gitlab_rails['lfs_object_store_background_upload'] = true
gitlab_rails['lfs_object_store_proxy_download'] = true
gitlab_rails['lfs_object_store_remote_directory'] = "lfs-objects"
gitlab_rails['lfs_object_store_connection'] = {
'provider' => 'AWS',
'region' => 'eu-west-1',
'aws_access_key_id' => 'Z1Xh28dpKo0Oc9Xjjq35n0lCceGYxHmGwpibz2WQ9acLtiUTBHftVTKxcLiISSld',
'aws_secret_access_key' => 'ebRmMNRHh9R9ve869SkspkC3xMOyPBmo0FGhud4JqBZu7zjuiMCu36xn7aEVNEeT#',
# # The below options configure an S3 compatible host instead of AWS
'aws_signature_version' => 4, # For creation of signed URLs. Set to 2 if provider does not support v4.
# 'endpoint' => 'https://s3.amazonaws.com', # default: nil - Useful for S3 compliant services such as DigitalOcean Spaces
'host' => 'localhost',
'endpoint' => 'http://minio地址:9000',
'path_style' => true
# # 'path_style' => false # Use 'host/bucket_name/object' instead of 'bucket_name.host/object'
} ### GitLab uploads
###! Docs: https://docs.gitlab.com/ee/administration/uploads.html
gitlab_rails['uploads_storage_path'] = "/var/opt/gitlab/gitlab-rails/public"
gitlab_rails['uploads_base_dir'] = "uploads/-/system"
gitlab_rails['uploads_object_store_enabled'] = true
gitlab_rails['uploads_object_store_direct_upload'] = true
gitlab_rails['uploads_object_store_background_upload'] = true
gitlab_rails['uploads_object_store_proxy_download'] = true
gitlab_rails['uploads_object_store_remote_directory'] = "uploads"
gitlab_rails['uploads_object_store_connection'] = {
'provider' => 'AWS',
'region' => 'eu-west-1',
'aws_access_key_id' => 'Z1Xh28dpKo0Oc9Xjjq35n0lCceGYxHmGwpibz2WQ9acLtiUTBHftVTKxcLiISSld',
'aws_secret_access_key' => 'ebRmMNRHh9R9ve869SkspkC3xMOyPBmo0FGhud4JqBZu7zjuiMCu36xn7aEVNEeT',
# # # The below options configure an S3 compatible host instead of AWS
'host' => 'localhost',
'aws_signature_version' => 4, # For creation of signed URLs. Set to 2 if provider does not support v4.
'endpoint' => 'http://minio地址:9000', # default: nil - Useful for S3 compliant services such as DigitalOcean Spaces
'path_style' => true # Use 'host/bucket_name/object' instead of 'bucket_name.host/object'
}
错误四:其他密钥问题
问题描述
gitlab代码仓库迁移数据后,在测试的时候发现有的功能按键点击出现500的错误,经过查资料解决了问题。现在把解决步骤整理一下
1.覆盖原来的gitlab的db_key_base到新的gitlab,db_key_base的位置在/etc/gitlab/gitlab-secrets.json
2.不同版本执行命令不同
CE版本执行
sudo gitlab-rails runner "Project.where.not(import_url: nil).each { |p| p.import_data.destroy if p.import_data }"
EE版本执行
sudo gitlab-rails runner "Project.where(mirror: false).where.not(import_url: nil).each { |p| p.import_data.destroy if p.import_data }"
执行完重启gitlab:gitlab-ctl restart
3.如果执行第二步没有生效,可以尝试如下操作
覆盖老的gitlab的secrets.yaml文件到新gitlab仓库的secrets.yaml 文件,文件的位置在:
/opt/gitlab/embedded/service/gitlab-rails/config/secrets.yaml
重启gitlab后发现之前500的页面可以正常访问了
Gitlab迁移(亲测)的更多相关文章
- 本地ES集群数据通过_reindex方式迁移到腾讯云服务器(亲测有效)
本地ES集群数据通过_reindex方式迁移到腾讯云服务器(亲测有效) 随着业务量的增加,本地的ES集群服务器性能和磁盘空间有点不够使用,项目组考虑使用腾讯云服务器,以下是我测试的使用_reindex ...
- Kubernetes_手把手打镜像并运行到k8s容器上(亲测可用)
一.前言 本文使用两个机器 192.168.100.150 是master节点,192.168.100.151 是node1 节点,如下: 演示三个示例,第一个示例wordpress博客系统是指将别人 ...
- nginx代理https站点(亲测)
nginx代理https站点(亲测) 首先,我相信大家已经搞定了nginx正常代理http站点的方法,下面重点介绍代理https站点的配置方法,以及注意事项,因为目前大部分站点有转换https的需要所 ...
- C#读取Excel设置(亲测可用)
OpenFileDialog openFD = new OpenFileDialog(); openFD.FileName = ""; openFD.Filter = " ...
- ASP.NET中的文件操作(文件信息,新建,移动,复制,重命名,上传,遍历)(亲测详细)
做了几天的文件操作,现在来总结一下,错误之处,还望指点!以文件为例,如果对文件夹操作,基本上将File换为Directory即可(例:FileInfo file = new FileInfo(Path ...
- 推荐几个最好用的CRM软件,本人亲测
CRM是英文Customer Relationship Management 的简写,一般译作“客户关系管理”.CRM最早产生于美国,由Gartner Group 首先提出的CRM这个概念的.20世纪 ...
- linux 系统下开机自动启动oracle 监听和实例 (亲测有效)
[oracle@oracle11g ~]$ dbstartORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listene ...
- IntelliJ13+tomcat+jrebel实现热部署(亲测可用)
网上有很多介绍intellij idea整合jrebel插件实现热部署的文章,但是有的比较复杂,有的不能成功,最后经过各种尝试,实现了整合,亲测可用!步骤说明如下: 一.先下载jrebel安 ...
- Linux下通过crontab及expect实现自动化处理 --亲测可用
#!/usr/bin/expect -fspawn /home/scripts/bckup.shexpect "Enter password: " send "WWQQ ...
- 获取UIColor中的RGB值(本人亲测多个获取RGB值的方法,这个最有效)
在自己研发的项目个人项目中,碰到一个从颜色中获取RGB值的需求. 在网上找了许久,也有一些方法可以获取RGB值,但不能获取黑白以及灰色的值(他们是非RGB颜色空间,不清楚什么意思,反正亲测确实获取不了 ...
随机推荐
- 第一个C程序
写C代码 创建工作区 创建工程 创建文件(.c源文件..h头文件) main函数是程序执行的入口,有且只有一个 函数printf(print function打印函数)[库函数-C语言本身提供给我们使 ...
- drf-day7——认证组件、权限组件、频率组件、过滤排序、分页
目录 一.认证组件 1.1 登录接口 1.2 认证组件使用步骤 1.3 整体代码 1.4认证时cookie的获取方式 二.权限组件 2.1需求分析: 2.2 权限的使用 2.3代码 三.频率组件 3. ...
- CSP-J2022游寄
本人资料 地区:河北-衡水 洛谷账号:xinao2186182144 洛谷ID:747196 前言 这次比赛本来是信心满满,认为自己这半年来的努力与付出都不会付诸东流(还想表个白?算是吧).到了考场的 ...
- Vue前后端交互、生命周期、组件化开发
目录 Vue前后端交互.生命周期.组件化开发 一.Vue用axios与后端交互 二.Vue的生命周期 三.组件化开发 Vue前后端交互.生命周期.组件化开发 一.Vue用axios与后端交互 如果 ...
- python3使用requests模块发https请求,提示caused by ssl error, can't connect to https url because the ssl module is not available
Q: python3使用requests模块发https请求,提示caused by ssl error, can't connect to https url because the ssl mod ...
- Can not use keyword ‘await’ outside an async function
- 三天吃透Java并发八股文!
本文已经收录到Github仓库,该仓库包含计算机基础.Java基础.多线程.JVM.数据库.Redis.Spring.Mybatis.SpringMVC.SpringBoot.分布式.微服务.设计模式 ...
- GPS地图生成02之经典算法体验
经典的利用轨迹生成地图的算法与数据集可寻找于:Mapconstruction by pfoser Mapconstruction by pfoser数据集中,雅典数据集投影坐标系为(UTM, GGRS ...
- Vue学习笔记之Vue基础语法
1. 概述 Vue.js 使用了基于 HTML 的模板语法,允许开发者声明式地将 DOM 绑定至底层 Vue 实例的数据.所有 Vue.js 的模板都是合法的 HTML,所以能被遵循规范的浏览器和 H ...
- js提交数据
一.from表单提交 <form action="" method="post" enctype="multipart/form-data&qu ...