温馨提示×

Debian升级GitLab怎么操作

小樊
43
2026-07-18 13:23:51
栏目: 智能运维

Debian 上升级 GitLab(通常指 GitLab CE / EE Omnibus 包)是比较成熟的流程,下面按推荐顺序给你一份安全、可回滚的操作步骤。


一、升级前必做(非常重要)

1️⃣ 查看当前版本

gitlab-rake gitlab:env:info

dpkg -l | grep gitlab

2️⃣ 备份 GitLab(强烈建议)

gitlab-backup create

默认备份路径:

/var/opt/gitlab/backups

如需备份配置:

tar czf /root/gitlab-config-$(date +%F).tar.gz \
  /etc/gitlab /var/opt/gitlab

3️⃣ 确认 Debian 版本

lsb_release -a

GitLab 对 Debian 版本有要求,例如:

  • GitLab 16.x → Debian 11 / 12
  • GitLab 17.x → Debian 12

二、升级方式(推荐:Omnibus 包)

✅ 方式一:使用官方仓库升级(推荐)

1️⃣ 更新 APT 索引

apt update

2️⃣ 升级 GitLab

apt upgrade gitlab-ee

或(CE 版本)

apt upgrade gitlab-ce

如果提示依赖问题,可先:

apt --fix-broken install

✅ 方式二:指定版本升级(跨大版本必看)

⚠️ GitLab 不支持跨多个大版本直接升级

例如:

14.x → 15.x → 16.x → 17.x

查看可用版本

apt-cache policy gitlab-ce

安装指定版本

apt install gitlab-ce=16.11.5-ce.0

三、每次升级后必须执行

gitlab-ctl reconfigure
gitlab-ctl restart

检查状态:

gitlab-ctl status

四、升级后检查

gitlab-rake gitlab:check
gitlab-rake gitlab:env:info

五、常见问题

❌ 1. 升级后 502 / 500

gitlab-ctl restart
gitlab-ctl tail

❌ 2. PostgreSQL 升级失败

gitlab-ctl pg-upgrade

❌ 3. 磁盘空间不足

df -h
du -sh /var/opt/gitlab

六、回滚方案(紧急)

如果升级失败:

apt install gitlab-ce=<旧版本号>
gitlab-ctl reconfigure

七、升级建议总结

最小停机升级流程

  1. 备份
  2. 小版本升级
  3. 逐步跨大版本
  4. 每次升级后 reconfigure

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

  • GitLab 当前版本
  • Debian 版本
  • 是 CE 还是 EE

我可以给你精确到版本的升级路线

0