前言:gitlab11升级到14还是有挺多需要注意的坑,也算是做一次积累吧,升级前后,gitalb的WEB界面也变化了很多,升级过程需要注意的地方我放到最后说明,挺关键的
一、首先需要下载好要升级的包,这里需要注意,gitlab的官网有说明如何升级,大概就是如下面所示,跨版本升级先要升级到版本最后一个版本才行,比如线上使用11.0.7,要升级到11.11.8才能升级到12.0.12
1 2 | 包下载地址https://packages.gitlab.com/gitlab/gitlab-ce |
官网建议按以下版本来升级

1 2 3 4 5 6 7 8 | GitLab 8: 8.11.Z > 8.12.0 > 8.17.7GitLab 9: 9.0.13 > 9.5.10GitLab 10: 10.0.7 > 10.8.7GitLab 11: 11.0.6 > 11.11.8GitLab 12: 12.0.12 > 12.1.17 > 12.10.14GitLab 13: 13.0.14 > 13.1.11 > 13.8.8 > 13.12.15GitLab 14: 14.0.12 > 14.3.6 > 14.9.5 > 14.10.5GitLab 15: 15.0.5 > 15.1.6 (for GitLab instances with multiple web nodes) > 15.4.6 > latest 15.Y.Z |
官网文档链接在这里
1 | https://docs.gitlab.com/ee/update/index.html#upgrade-paths |
二、升级步骤
2.1 先把nginx停止,外部无法访问了
1 | /usr/local/nginx/sbin/nginx -s stop |
2.2 做一次备份,整个过程我只做一次备份,我也在阿里云做镜像以防万一,同时我在操作线上升级前已经反复尝试,还是有信心的
1 2 3 4 5 | gitlab-rake gitlab:backup:create备份敏感数据cp /etc/gitlab/gitlab.rb /data/gitlab/backupscp /etc/gitlab/gitlab-secrets.json /data/gitlab/backups |
2.3 关闭gitlab的部分服务
13.x以前版本关闭unicorn,14.x版本就不支持unicorn,从13版本开始,我使用puma方式,停止方式gitlab-ctl stop puma
官网对照

链接地址
1 | https://docs.gitlab.com/ee/administration/operations/puma.html#converting-unicorn-settings-to-puma |
13.x以前版本关闭unicorn,操作命令停止下面服务
1 2 3 | gitlab-ctl stop unicorngitlab-ctl stop sidekiq |
2.4 升级新版本
1 | rpm -Uvh 要升级版本.rpm |
这里要升级到11.11.8版本为例子
1 | rpm -Uvh gitlab-ce-11.11.8-ce.0.el7.x86_64.rpm |
2.5升级完成后,没有报错情况下,需要重新运行配置,否则启动会失败
1 | gitlab-ctl reconfigure |
2.6 启动
1 | gitlab-ctl restart |
2.7 查看gitlab版本信息
1 2 3 4 5 | 第一种gitlab-rake gitlab:env:info第二种cat /opt/gitlab/embedded/service/gitlab-rails/VERSION |
2.8 检查服务
1 2 3 | gitlab-rake gitlab:check SANITIZE=truesystemctl status gitlab-runsvdir.service |
2.9 启动nginx
1 | /usr/local/nginx/sbin/nginx |
三、检查测试git提交是否正常
我这里会修改代码,然后提交是否正常,如果没有问题就当升级成功了

四、需要注意的问题,我都说明下
4.1 gitlab13.x版本要安装并且开启Puma,因为14版本就不支持unicorn
4.2 升级13版本前一个版本需要升级postgresql,就是升级到了12.10.14版本,再执行更新postgresql
1 2 3 4 5 6 7 8 | 更新gitlab-ctl pg-upgrade 需要重新运行配置,否则启动会失败gitlab-ctl reconfigure启动gitlab-ctl restart |
4.3 在gitlab13.x的最后一个版本 将传统存储转换为哈希存储,也就是13.12.15版本,文档说明
1 | https://docs.gitlab.com/ee/administration/raketasks/storage.html#migrate-to-hashed-storage%20for%20details |
步骤如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | gitlab-rake gitlab:storage:migrate_to_hashed # 执行成功后,再次执行,会提示如下内容:#There are no projects requiring storage migration. Nothing to do!# 全部迁移成功,以下命令查看所列出的项目总数与页面的理应一致gitlab-rake gitlab:storage:hashed_projects # 查看,全部迁移成功以下两条命令应该为 0 gitlab-rake gitlab:storage:legacy_projectsgitlab-rake gitlab:storage:legacy_attachments # 列出传统存储的项目以及附件gitlab-rake gitlab:storage:list_legacy_projectsgitlab-rake gitlab:storage:list_legacy_attachments |
4.5 升级14.x版本前一个版本升级postgresql,也就是13.12.15版本
1 2 3 4 5 6 7 8 | 更新gitlab-ctl pg-upgrade 需要重新运行配置,否则启动会失败gitlab-ctl reconfigure启动gitlab-ctl restart |
最后没问题了,正常使用~