勤学如春起之苗,不见其增,日有所长。辍学如磨刀之石,不见其损,日有所亏
文章目录
环境概述
"目前生产环境gitlab是12.10.4 X86版本,因华为云ARM架构下没有此版本对应的rpm包和docker镜像,所以只能选择更高级的版本,此处选择13.10.4版本的arch包"
1) 阿里云生产Gitlab环境[x86] 版本:12.10.14
2) 阿里云克隆机Gitlab部署[x86] 版本:12.10.14
3) 阿里云克隆机Gitlab数据恢复 版本:12.10.14
4) 阿里云克隆机Gitlab版本升级 版本:13.10.4
5) 阿里云克隆机Gitlab数据备份 版本:13.10.4
6) 华为云迁移后gitlab环境[Arm] 版本:13.10.4
1、阿里云生产Gitlab环境配置
一)阿里云生产环境gitlab
服务器: 阿里云ECS---X86机器
git版本: GitLab Community Edition 12.10.14
### 备份:
[root@gitlab ~]# gitlab-rake gitlab:backup:create
### 将备份文件拷贝到克隆机器
[root@gitlab ~]# cd /var/opt/gitlab/backups/ "备份文件默认存储路径"
[root@gitlab ~]# scp -r 1641214318_2022_01_03_12.10.14_gitlab_backup.tar root@克隆机:/var/opt/gitlab/backups/
2、阿里云克隆机Gitlab环境
二)阿里云克隆机器环境
服务器: 阿里云ECS---X86机器
git版本: GitLab Community Edition 12.10.14
"为避免直接基于目前生产环境gitlab做更新迁移从而出现问题,所以再次找一台阿里云服务器做gitlab克隆机,安装和生产环境相同版本git,做迁移和更新"
2.1) 配置yum源
[root@test-git]# cat /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=gitlab-ce
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/
repo_gpgcheck=0
gpgcheck=0
enable=1
gpgkey=https://packages.gitlab.com/gpg.key
[root@test-git]# yum clean all
[root@test-git]# yum makecache
[root@test-git]# yum list --showduplicates gitlab-ce
Last metadata expiration check: 1:34:31 ago on Tue 04 Jan 2022 03:40:50 PM CST.
Installed Packages
gitlab-ce.x86_64 13.10.4-ce.0.el8 @gitlab-ce
Available Packages
gitlab-ce.x86_64 12.8.1-ce.0.el8 gitlab-ce
gitlab-ce.x86_64 12.8.2-ce.0.el8 gitlab-ce
gitlab-ce.x86_64 12.8.5-ce.0.el8 gitlab-ce
gitlab-ce.x86_64 12.8.6-ce.0.el8
......
2.2) 安装gitlab-12.10.14版
[root@test-git]# yum -y install gitlab-ce-12.10.14-ce.0.el8
2.3) 安装完之后查看当前版本
[root@test-git]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
2.4) 修改配置文件,配置当前gitlab
[root@test-git]# cat gitlab.rb |grep -v "^#"|grep -v '^$'
external_url 'http://IP:9999'
gitlab_rails['gravatar_plain_url'] = 'http://gravatar.duoshuo.com/avatar/%{hash}?s=%{size}&d=identicon'
gitlab_rails['gitlab_shell_ssh_port'] = 9999
unicorn['worker_processes'] = 3
nginx['enable'] = true
nginx['listen_port'] = 9999
2.5) 重新配置gitlab并启动
[root@test-git]# gitlab-ctl reconfigure
2.6) 重启所有gitlab组件
sudo gitlab-ctl restart
3、阿里云克隆机Gitlab数据恢复
注意:
新服务器上的Gitlab的版本必须与创建备份时的Gitlab版本号相同.
比如新服务器安装的是较新版本的Gitlab, 那么迁移之前, 最好将老服务器的Gitlab 升级和新服务一致的版本再进行备份
3.1) 停止gitlab服务
[root@test-git]# gitlab-ctl stop unicorn
[root@test-git]# gitlab-ctl stop sidekiq
[root@test-git]# gitlab-ctl status
3.2) 恢复数据
[root@test-git]# cd /var/opt/gitlab/backups
[root@test-git]# chomd 777 1641214318_2022_01_03_12.10.14_gitlab_backup.tar
[root@test-git]# gitlab-rake gitlab:backup:restore BACKUP=1641214318_2022_01_03_12.10.14
3.3) 再次启动gitlab
数据恢复完成之后,再次启动gitlab
[root@test-git]# gitlab-ctl start
[root@test-git]# gitlab-ctl status
3.4) 恢复命令完成后,check检查一下恢复情况
[root@test-git]# gitlab-rake gitlab:check SANITIZE=true
"注意:如果启动GitLab后,访问出现500,这是因为程序还没完全启动,需要等一会儿访问"
3.5) 登录gitlab地址进行验证,所有的数据都做了恢复
3.6) GitLab迁移的具体过程
1585185505_2020_03_26_12.7.0_gitlab_backup.tar
[ro