一、GitLab的数据从旧服务器迁移到新服务器
注释:旧服务器、新服务器GitLab版本保持一致,如果不一致得需要升级
1旧服务器上的安装版本
[root@iZbp1ac9uozodszcdkd98nZ ~]
10.0.0
2.新服务器上的安装版本
参考我之前写的文档:https://blog.csdn.net/qq_38144121/article/details/121538314?spm=1001.2014.3001.5502
3.如果新旧服务器上安装的版本不一致
例如: 旧服务器上GitLab版本10.3.3,新服务器上GitLab版本12.0.1。
GitLab不能跨版本升级,需一个一个大版本升级。例如:10.8.7是10的最后一个版本,11.11.0是11的最后一个版本,则从 10.3.3 升级到 12.0.1,需要经过 10.3.3 -> 10.8.7 -> 11.11.0 -> 12.0.1三次版本升级。
所以,要先在旧服务器上执行以下版本升级命令:
[root@old-host ~]
[root@old-host ~]
[root@old-host ~]
[root@old-host ~]
4.先在旧服务器做gitlab数据备份文件
[root@old-host ~]
[root@old-host ~]
[root@old-host backups]
[root@old-host backups]
总用量 3.4G
-rw-------. 1 git git 3.4G 3月 11 11:10 1615432132_2021_03_11_10.0.0_gitlab_backup.tar
5.上传备份文件到新服务器上
[root@iZbp1ac9uozodszcdkd98nZ ~]
6.新服务器备份文件权限修改为755,避免出现权限不够的问题
[root@iZbp13rb8m4bfaw9cek2kzZ ~]
[root@iZbp13rb8m4bfaw9cek2kzZ backups]
总用量 266676
-rwxr-xr-x 1 root root 273070080 5月 20 07:39 1653003207_2022_05_20_10.0.0_gitlab_backup.tar
[root@iZbp13rb8m4bfaw9cek2kzZ backups]
[root@iZbp13rb8m4bfaw9cek2kzZ backups]
总用量 266676
-rwxr-xr-x 1 root root 273070080 5月 20 07:39 1653003207_2022_05_20_10.0.0_gitlab_backup.tar
7.停止新服务器上gitlab数据连接服务
[root@iZbp13rb8m4bfaw9cek2kzZ backups]
[root@iZbp13rb8m4bfaw9cek2kzZ backups]
8.恢复备份文件到GitLab
gitlab-rake gitlab:backup:restore BACKUP=备份文件编号
例如:备份文件名为 1653003207_2022_05_20_10.0.0_gitlab_backup.tar,则编号为:1653003207_2022_05_20_10.0.0。 在提示中敲入“yes”继续
[root@iZbp13rb8m4bfaw9cek2kzZ backups]
9.重新启动GitLab
[root@iZbp13rb8m4bfaw9cek2kzZ backups]
最后检查新旧服务器上GitLab的内容(包括账号密码等),完全一模一样,迁移成功!
10.修改idea远程ip地址即可推送和拉取代码
二、GitLab默认仓库存储目录更换及项目迁移
背景:
GitLab默认存储目录在系统盘中,由于系统盘空间已满,把默认仓库迁移至数据盘(数据盘: /shujupan)中
如果存在磁盘未挂在情况,可参考:https://blog.csdn.net/qq_38144121/article/details/124880030?spm=1001.2014.3001.5501
1.迁移 gitlab 仓库数据
修改配置文件之前,先迁移数据
[root@iZbp13rb8m4bfaw9cek2kzZ ~]
ok: down: alertmanager: 1s, normally up
ok: down: gitaly: 0s, normally up
ok: down: gitlab-exporter: 0s, normally up
ok: down: gitlab-workhorse: 1s, normally up
ok: down: grafana: 0s, normally up
ok: down: logrotate: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: node-exporter: 1s, normally up
ok: down: postgres-exporter: 0s, normally up
ok: down: postgresql: 0s, normally up
ok: down: prometheus: 1s, normally up
ok: down: puma: 0s, normally up
ok: down: redis: 1s, normally up
ok: down: redis-exporter: 0s, normally up
ok: down: sidekiq: 1s, normally up
[root@iZbp13rb8m4bfaw9cek2kzZ shujupan]
[root@iZbp13rb8m4bfaw9cek2kzZ shujupan]
sending incremental file list
repositories/
repositories/.gitaly-metadata
repositories/+gitaly/
repositories/+gitaly/tmp/
repositories/@hashed/
...
[root@iZbp13rb8m4bfaw9cek2kzZ ~]
total 0
drwxrws---. 4 git root 57 Mar 7 19:06 repositories
2.修改配置文件
编辑 /etc/gitlab/gitlab.rb 修改git_data_dirs对应值
[root@iZbp13rb8m4bfaw9cek2kzZ shujupan] vim /etc/gitlab/gitlab.rb
git_data_dirs({
"default" => {
"path" => "/home/gitlab/git-data/"
}
})
[root@iZbp13rb8m4bfaw9cek2kzZ shujupan] gitlab-ctl reconfigure
Starting Chef Client, version 14.14.29
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
...
Running handlers:
Running handlers complete
Chef Client finished, 14/746 resources updated in 34 seconds
gitlab Reconfigured!
[root@localhost ~]
ok: run: alertmanager: (pid 126213) 1s
ok: run: gitaly: (pid 126223) 0s
ok: run: gitlab-exporter: (pid 126257) 1s
ok: run: gitlab-workhorse: (pid 126260) 0s
ok: run: grafana: (pid 126281) 0s
ok: run: logrotate: (pid 126293) 1s
ok: run: nginx: (pid 126302) 0s
ok: run: node-exporter: (pid 126308) 1s
ok: run: postgres-exporter: (pid 126314) 0s
ok: run: postgresql: (pid 125331) 172s
ok: run: prometheus: (pid 126398) 1s
ok: run: puma: (pid 126408) 0s
ok: run: redis: (pid 126414) 1s
ok: run: redis-exporter: (pid 126419) 0s
ok: run: sidekiq: (pid 126440) 0s
参考文章:https://blog.csdn.net/yuki5233/article/details/114662844
参考文章:https://blog.csdn.net/march0310/article/details/116748845
|