gitlab升级(11->17)
环境:
Os:Centos 7
当前版本:11.11.8
升级版本:17.8.5
1.查看升级路径
https://gitlab-com.gitlab.io/support/toolbox/upgrade-path


2.备份当前的gitlab
gitlab-rake gitlab:backup:create
可以看到备份目录生成了备份文件
[root@host135 soft]# ls -al /var/opt/gitlab/backups
total 104
drwx------ 2 git root 61 Mar 21 14:42 .
drwxr-xr-x 20 root root 4096 Mar 21 13:51 ..
-rw------- 1 git git 102400 Mar 21 14:42 1742539333_2025_03_21_11.11.8_gitlab_backup.tar
备份配置文件
cp /etc/gitlab/gitlab.rb /etc/gitlab/bak20250321_gitlab.rb
cp /etc/gitlab/gitlab-secrets.json /etc/gitlab/bak20250321_gitlab-secrets.json
3.获取新版本的rpm安装包(好像不能使用rpm方式安装)
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.0.12-ce.0.el7.x86_64.rpm
只能使用yum安装不能下载rpm包后使用rpm -ivh命令安装,会包如下的错误:
from package gitlab-ce-11.11.8-ce.0.el7.x86_64
file /opt/gitlab/version-manifest.txt from install of gitlab-ce-12.0.12-ce.0.el7.x86_64 conflicts with file from package gitlab-ce-11.11.8-ce.0.el7.x86_64
4.只停掉如下2个服务
gitlab-ctl stop unicorn ##web服务
gitlab-ctl stop sidekiq ##队列任务
5.yum安装
使用下面的yum
vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
官网的yum很慢
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh|bash
yum install gitlab-ce-16.3.9
No package gitlab-ce-16.3.9 available. ##升级到该版本的时候需要使用官网的yum,下载速度比较慢
[root@host135 yum.repos.d]# yum install gitlab-ce-12.0.12
成功后会出现如下的输出
==== Upgrade has completed ====
Please verify everything is working and run the following if so
rm -rf /var/opt/gitlab/postgresql/data.9.6
Ensuring PostgreSQL is updated: OK
Restarting previously running GitLab services
ok: run: alertmanager: (pid 21725) 4s
ok: run: gitaly: (pid 21727) 4s
ok: run: gitlab-monitor: (pid 21756) 3s
ok: run: gitlab-workhorse: (pid 20235) 86s
ok: run: logrotate: (pid 21787) 2s
ok: run: nginx: (pid 21837) 1s
ok: run: node-exporter: (pid 21793) 3s
ok: run: postgres-exporter: (pid 21800) 2s
ok: run: postgresql: (pid 21245) 22s
ok: run: prometheus: (pid 21807) 2s
ok: run: redis: (pid 32267) 2420s
ok: run: redis-exporter: (pid 21819) 2s
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Upgrade complete! If your GitLab server is misbehaving try running
sudo gitlab-ctl restart
before anything else.
If you need to roll back to the previous version you can use the database
backup made during the upgrade (scroll up for the filename).
Verifying : gitlab-ce-12.0.12-ce.0.el7.x86_64 1/2
Verifying : gitlab-ce-11.11.8-ce.0.el7.x86_64 2/2
Updated:
gitlab-ce.x86_64 0:12.0.12-ce.0.el7
Complete!
执行这个语句会对整个gitlab进行了备份
[root@host135 backups]# pwd
/var/opt/gitlab/backups
[root@host135 backups]# ls -al
total 196
drwx------ 2 git root 116 Mar 21 16:23 .
drwxr-xr-x 20 root root 4096 Mar 21 13:51 ..
-rw------- 1 git git 102400 Mar 21 14:42 1742539333_2025_03_21_11.11.8_gitlab_backup.tar
-rw------- 1 git git 92160 Mar 21 16:23 1742545398_2025_03_21_11.11.8_gitlab_backup.tar
6.启动(不需要)
gitlab-ctl reconfigure
gitlab-ctl restart
执行了上面的yum,会自动启动所有的组件
[root@host135 yum.repos.d]# gitlab-ctl status
run: alertmanager: (pid 21725) 24s; run: log: (pid 31214) 9663s
run: gitaly: (pid 21727) 24s; run: log: (pid 19373) 251s
run: gitlab-monitor: (pid 21756) 23s; run: log: (pid 30981) 9681s
run: gitlab-workhorse: (pid 20235) 106s; run: log: (pid 19893) 165s
run: grafana: (pid 21764) 23s; run: log: (pid 20117) 127s
run: logrotate: (pid 21787) 22s; run: log: (pid 30743) 9693s
run: nginx: (pid 21837) 20s; run: log: (pid 30699) 9697s
run: node-exporter: (pid 21793) 22s; run: log: (pid 30824) 9686s
run: postgres-exporter: (pid 21800) 21s; run: log: (pid 31287) 9656s
run: postgresql: (pid 21245) 41s; run: log: (pid 29374) 9823s
run: prometheus: (pid 21807) 21s; run: log: (pid 31096) 9669s
run: redis: (pid 32267) 2439s; run: log: (pid 28969) 9846s
run: redis-exporter: (pid 21819) 21s; run: log: (pid 31024) 9674s
run: sidekiq: (pid 21826) 20s; run: log: (pid 19890) 166s
down: unicorn: 2289s, normally up; run: log: (pid 30418) 9716s
7.查看升级情况
[root@host135 yum.repos.d]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
12.0.12
8.登录web界面检查是否有问题
http://192.168.1.135:8888
好像要等很久,重启后就可以了
gitlab-ctl restart
9.重复上面的步骤继续升级
yum install gitlab-ce-12.1.17
yum install gitlab-ce-12.10.14
yum install gitlab-ce-13.0.14
yum install gitlab-ce-13.1.11
yum install gitlab-ce-13.8.8
yum install gitlab-ce-13.12.15
yum install gitlab-ce-14.0.12
yum install gitlab-ce-14.3.6
yum install gitlab-ce-14.9.5
yum install gitlab-ce-14.10.5
出现如下警告
Warnings:
LD_LIBRARY_PATH was found in the env variables, this may cause issues with linking against the included libraries.
解决办法:
将/etc/profile 或是/root/.bash_profile定义的LD_LIBRARY_PATH变量去掉
yum install gitlab-ce-15.0.5
yum install gitlab-ce-15.4.6
yum install gitlab-ce-15.11.13
yum install gitlab-ce-16.3.9
yum install gitlab-ce-16.7.10
yum install gitlab-ce-16.11.10
yum install gitlab-ce-17.1.8
yum install gitlab-ce-17.3.7
yum install gitlab-ce-17.5.5
yum install gitlab-ce-17.8.5
浙公网安备 33010602011771号