温馨提示×

centos gitlab怎样升级

小樊
46
2026-10-17 12:35:39
栏目: 智能运维

在 CentOS 上升级 GitLab(通常指 Omnibus 安装的 GitLab)一般按下面步骤来。请先确认你是 Omnibus 安装(最常见),而不是源码或 Docker 安装。


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

1. 查看当前版本

cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
# 或
gitlab-rake gitlab:env:info

2. 备份 GitLab

gitlab-rake gitlab:backup:create

备份文件默认在:

/var/opt/gitlab/backups/

同时也建议备份配置文件:

cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bak
cp -r /etc/gitlab/ssl /etc/gitlab/ssl.bak   # 如有

3. 查看官方升级路径(关键)

⚠️ GitLab 不能跨大版本直接升 例如:

  • 13.0 → 13.12 → 14.0 → 14.9 → 15.0 → 15.x
  • 不能直接 13.x → 15.x

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


二、CentOS 上升级 GitLab(Omnibus)

1. 更新 yum 源(如未改过)

vim /etc/yum.repos.d/gitlab_gitlab-ee.repo
# 或 gitlab-ce.repo

常见内容(示例):

[gitlab-ce]
name=GitLab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
gpgcheck=0
enabled=1

CentOS 7 用 el7,CentOS 8 用 el8

2. 清理并刷新缓存

yum clean all
yum makecache

3. 升级到指定版本(推荐)

例如升级到 15.11.0:

yum install gitlab-ce-15.11.0-ce.0.el7

或升级到最新:

yum update gitlab-ce

4. 重新配置并重启

gitlab-ctl reconfigure
gitlab-ctl restart

5. 检查状态

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

三、跨大版本升级示例(标准做法)

例如当前是 13.12.0:

yum install gitlab-ce-13.12.15-ce.0.el7
gitlab-ctl reconfigure

yum install gitlab-ce-14.0.12-ce.0.el7
gitlab-ctl reconfigure

yum install gitlab-ce-14.10.5-ce.0.el7
gitlab-ctl reconfigure

yum install gitlab-ce-15.0.5-ce.0.el7
gitlab-ctl reconfigure

yum install gitlab-ce-15.11.0-ce.0.el7
gitlab-ctl reconfigure

四、常见问题

1. 升级后 502

  • 等待几分钟
  • 查看日志:
gitlab-ctl tail

2. 数据库迁移失败

gitlab-rake db:migrate

3. 升级前磁盘不足

至少预留 GitLab 数据大小 × 2 的空间


五、Docker 安装(如你是)

docker pull gitlab/gitlab-ce:15.11.0-ce.0
docker stop gitlab
docker rm gitlab
# 用相同 volumes 启动

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

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

我可以给你 精确到版本的升级命令。

0 踩