gitlab升级

1.升级路线

gitlab升级不能一步到位,要一个个版本渐进式升级,根据官方文档选择自己的升级路线。
官方文档:https://docs.gitlab.com/ee/update/index.html#upgrade-paths
根据文档,升级路线为:11.4.3 -> 11.11.8 -> 12.0.12 -> 12.1.17 -> 12.10.14 -> 13.0.14 -> 13.1.11 -> 13.8.8 -> 13.12.15 -> 14.0.12 -> 14.3.6 -> 14.6.2 -> 14.9.5 -> 14.10.5

2.准备

升级路线上所有安装包,容器部署的下载官方镜像文件gitlab/gitlab-ce:[version]-ce.0
https://packages.gitlab.com/gitlab/gitlab-ce

升级前务必执行备份操作

1
2
3
4
GitLab 12.2以后:
gitlab-backup create
GitLab 12.1及以前:
gitlab-rake gitlab:backup:create

如果升级过程中出现问题,退回初始版本,执行恢复操作:

1
2
关闭数据库连接服务
gitlab-ctl stop unicorn && gitlab-ctl stop sidekiq

⚠️恢复操作会清空当前gitlab数据

1
2
cd /opt/gitlab_backup
gitlab-rake gitlab:backup:restore BACKUP=1553965778_2019_03_31_10.7.3 ---#文件名会自动补全-(注意)

3.升级

11.4.3 -> 11.11.8

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq

根据:https://docs.gitlab.com/omnibus/update/gitlab_11_changes.html

11.11.8大版本需要修改 gitlab.rb的2个地方:
1、增加 nginx[‘ssl_protocols’] = “TLSv1.2”
2、旧格式去掉 git_data_dir “/data/git-data” 增加新格式 git_data_dirs({ “default” => { “path” => “/data/git-data” } })
然后执行:
gitlab-ctl reconfigure
开始升级:
rpm -Uvh gitlab-ce-11.11.8-ce.0.el7.x86_64.rpm

按提示执行:gitlab-ctl restart postgresql

gitlab-ctl restart
gitlab-ctl status 查看应该正常了。

查看版本号:

1
2
3
4
[root@gitlab soft]# rpm -qa|grep gitlab
gitlab-ce-11.11.8-ce.0.el7.x86_64
[root@gitlab soft]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
11.11.8

11.11.8 -> 12.0.12

记录一下PostgreSQL的版本为9.6:

1
2
/opt/gitlab/embedded/bin/psql --version
psql (PostgreSQL) 9.6.11

停止数据连接服务:
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq

这个版本需要升级prometheus,大概15分钟

1
2
3
4
[root@gitlab ~]# gitlab-ctl prometheus-upgrade
Converting existing data to new format is a time consuming process and can take hours.
If you prefer not to migrate existing data, press Ctrl-C now and re-run the command with --skip-data-migration flag.
Waiting for 30 seconds for input.

开始升级

1
2
3
4
5
6
[root@gitlab soft]# rpm -Uvh gitlab-ce-12.0.12-ce.0.el7.x86_64.rpm
#查看版本号
[root@gitlab soft]# rpm -qa|grep gitlab
gitlab-ce-12.0.12-ce.0.el7.x86_64
[root@gitlab soft]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
12.0.12

12.0.12 -> 12.1.17

查看PostgreSQL的版本:

1
2
[root@gitlab soft]# /opt/gitlab/embedded/bin/psql --version
psql (PostgreSQL) 10.7

停止数据连接服务:
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl stop nginx
开始升级:
rpm -Uvh gitlab-ce-12.1.17-ce.0.el7.x86_64.rpm

查看版本:

1
2
3
4
[root@gitlab soft]# rpm -qa|grep gitlab
gitlab-ce-12.1.17-ce.0.el7.x86_64
[root@gitlab soft]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
12.1.17

12.1.17 -> 12.10.14

查看当前PostgreSQL的版本:

1
2
[root@gitlab soft]# /opt/gitlab/embedded/bin/psql --version
psql (PostgreSQL) 10.7

停止数据库连接服务:
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl stop nginx
这个版本的PostgreSQL会自动升级到11.x
开始升级:
rpm -Uvh gitlab-ce-12.10.14-ce.0.el7.x86_64.rpm
gitlab-ctl restart
升级后的PostgreSQL 的版本:

1
2
[root@gitlab soft]# /opt/gitlab/embedded/bin/psql --version
psql (PostgreSQL) 11.7

12.10.14 -> 13.0.14

此版本变动如下:
1、Puma代替unicorn作为默认web server
2、PostgreSQL最低版本提升到11。

停止数据连接服务:
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl stop nginx
开始升级:
rpm -Uvh gitlab-ce-13.0.14-ce.0.el7.x86_64.rpm
gitlab-ctl restart

查看版本:

1
2
3
4
[root@gitlab soft]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
13.0.14
[root@gitlab ~]# rpm -qa|grep gitlab
gitlab-ce-13.0.14-ce.0.el7.x86_64

运行检查脚本:
gitlab-rake gitlab:check SANITIZE=true

一切正常,Git version显示为2.26.2

13.0.14 -> 13.1.11

关闭数据库连接服务:
gitlab-ctl stop unicorn
gitlab-ctl stop puma
gitlab-ctl stop sidekiq

开始升级:
rpm -Uvh gitlab-ce-13.1.11-ce.0.el7.x86_64.rpm

执行检查脚本:
gitlab-rake gitlab:check SANITIZE=true

13.1.11 -> 13.8.8

gitlab-ctl stop puma
gitlab-ctl stop sidekiq
rpm -Uvh gitlab-ce-13.8.8-ce.0.el7.x86_64.rpm
安装完成后
gitlab-rake gitlab:check SANITIZE=true

13.8.8 -> 13.12.15

gitlab-ctl stop puma
gitlab-ctl stop sidekiq

rpm -Uvh gitlab-ce-13.12.15-ce.0.el7.x86_64.rpm

[root@gitlab soft]# /opt/gitlab/embedded/bin/psql –version
psql (PostgreSQL) 12.6
[root@gitlab soft]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
13.12.15

13.12.15 -> 14.0.12

gitlab-ctl stop puma
gitlab-ctl stop sidekiq

rpm -Uvh gitlab-ce-14.0.12-ce.0.el7.x86_64.rpm

[root@gitlab soft]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
14.0.12

14.0.12 -> 14.3.6

gitlab-ctl stop puma
gitlab-ctl stop sidekiq

rpm -Uvh gitlab-ce-14.3.6-ce.0.el7.x86_64.rpm

[root@gitlab soft]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
14.3.6

14.3.6 -> 14.6.2

gitlab-ctl stop puma
gitlab-ctl stop sidekiq

rpm -Uvh gitlab-ce-14.6.2-ce.0.el7.x86_64.rpm

[root@gitlab soft]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
14.6.2

14.6.2 -> 14.9.5

gitlab-ctl stop puma
gitlab-ctl stop sidekiq

rpm -Uvh gitlab-ce-14.9.5-ce.0.el7.x86_64.rpm

[root@gitlab soft]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
14.9.5

14.9.5 -> 14.10.5

gitlab-ctl stop puma
gitlab-ctl stop sidekiq

rpm -Uvh gitlab-ce-14.10.5-ce.0.el7.x86_64.rpm

[root@gitlab soft]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
14.10.5