温馨提示×

centos gitlab如何升级

小樊
55
2026-09-02 20:16:17
栏目: 智能运维

CentOS 上升级 GitLab(通常指 Omnibus 安装方式)一般步骤如下。请先确认你是 GitLab CE 还是 GitLab EE,以及安装方式(Omnibus / Docker / 源码)。下面以最常见的 Omnibus + CentOS 7/8 为例。


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

1. 备份 GitLab

sudo gitlab-rake gitlab:backup:create

备份文件默认在:

/var/opt/gitlab/backups/

2. 查看当前版本

cat /opt/gitlab/version-manifest.txt | head -n 1

sudo gitlab-rake gitlab:env:info

3. 确认升级路径(⚠关键)

GitLab 不能跨大版本直接升级,例如:

8.x → 9.x → 10.x → 11.x → 12.x → 13.x → 14.x → 15.x → 16.x

官方升级路径工具: https://docs.gitlab.com/ee/update/index.html#upgrade-paths


二、CentOS 上升级 GitLab(Omnibus)

方式一:使用 yum 升级(推荐)

1. 更新 yum 缓存

sudo yum clean all
sudo yum makecache

2. 升级 GitLab

sudo yum update gitlab-ce

或 EE:

sudo yum update gitlab-ee

如果 yum 中没有新版本,可能需要修改 repo: /etc/yum.repos.d/gitlab_gitlab-ce.repo


方式二:手动指定版本升级(跨版本常用)

例如升级到 15.11.13:

sudo yum install gitlab-ce-15.11.13-ce.0.el7.x86_64

升级完成后执行:

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

三、大版本升级示例(逐步)

假设当前是 13.12.15

# 升到 14.0
yum install gitlab-ce-14.0.12
gitlab-ctl reconfigure

# 升到 14.10
yum install gitlab-ce-14.10.5
gitlab-ctl reconfigure

# 升到 15.0
yum install gitlab-ce-15.0.5
gitlab-ctl reconfigure

# 最后升到 16.x

四、升级后检查

sudo gitlab-ctl status
sudo gitlab-rake gitlab:check SANITIZE=true

访问 Web 页面确认正常。


五、Docker 方式(如适用)

docker pull gitlab/gitlab-ce:16.5.0-ce.0
docker stop gitlab
docker rm gitlab
docker run ...(同原启动参数)

六、常见问题

1. 升级卡在 migrate

sudo gitlab-rake db:migrate

2. 磁盘空间不足

确保 /var/opt/gitlab 至少有 2–5GB 空闲

3. CentOS 8 已 EOL

建议使用:

  • AlmaLinux
  • Rocky Linux
  • Ubuntu

如果你能提供:

  • 当前 GitLab 版本
  • CentOS 版本
  • 安装方式(Omnibus / Docker)

我可以给你精确的升级命令

0