温馨提示×

GitLab在CentOS如何升级

小樊
37
2026-08-29 20:01:45
栏目: 智能运维

CentOS 上升级 GitLab(以 Omnibus GitLab 为例,最常见)通常分为 同大版本升级跨大版本升级 两种情况。下面给你一套安全、通用的升级流程


一、升级前准备(非常重要)

1️⃣ 查看当前 GitLab 版本

gitlab-rake gitlab:env:info
# 或
cat /opt/gitlab/version-manifest.txt

2️⃣ 备份 GitLab(必须)

gitlab-backup create

备份文件默认在:

/var/opt/gitlab/backups/

⚠️ 如果是生产环境,建议整台服务器或 /var/opt/gitlab 做快照

3️⃣ 确认 CentOS 版本

cat /etc/centos-release

GitLab 16+ 已不再支持 CentOS 7(官方建议迁移到 Rocky / Alma)


二、升级方式选择

✅ 推荐方式:RPM 包升级(Omnibus)


三、同大版本升级(如 16.5 → 16.10)

1️⃣ 更新 yum 源

yum clean all
yum makecache

2️⃣ 升级 GitLab

yum update gitlab-ee
# 或 gitlab-ce
yum update gitlab-ce

3️⃣ 重新配置并重启

gitlab-ctl reconfigure
gitlab-ctl restart

四、跨大版本升级(官方要求)

⚠️ GitLab 不支持跳过主版本升级

正确升级路径示例

14.x → 15.0 → 15.11 → 16.0 → 16.x

1️⃣ 升级到当前大版本最新补丁

yum install gitlab-ce-15.11.13

2️⃣ 再升级到下一个大版本

yum install gitlab-ce-16.0.0

3️⃣ 每次升级后执行

gitlab-ctl reconfigure
gitlab-ctl restart

五、指定版本升级(避免错误)

查看可用版本

yum --showduplicates list gitlab-ce

安装指定版本

yum install gitlab-ce-16.8.0

六、升级后检查

1️⃣ 查看版本

gitlab-rake gitlab:env:info

2️⃣ 检查状态

gitlab-ctl status

3️⃣ 检查完整性

gitlab-rake gitlab:check

七、常见问题

❌ CentOS 7 升级失败

原因:GitLab 16+ 已停止支持
✅ 解决方案:

  • 迁移到 Rocky Linux 8/9
  • 或停留在 GitLab 15.x

❌ 升级后 502 / 500

gitlab-ctl restart
gitlab-rake db:migrate

八、Docker 部署方式(补充)

如果你是用 Docker:

docker pull gitlab/gitlab-ce:latest
docker stop gitlab
docker rm gitlab
# 重新运行新版容器(挂载相同数据目录)

九、总结(推荐流程)

备份 → 查版本 → 按主版本逐级升级 → reconfigure → 检查


如果你愿意,可以告诉我:

  • ✅ GitLab 当前版本
  • ✅ GitLab CE / EE
  • ✅ CentOS 7 还是 8
  • ✅ 是否生产环境

我可以给你 一步不多、一步不少的升级命令方案

0