gitlab升级

查看当前版本

sh 复制代码
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION

12.9.3-ee

备份数据

sh 复制代码
gitlab-rake gitlab:backup:create

备份默认位置在 /var/opt/gitlab/backups/

备份配置数据(git配置目录)

sh 复制代码
tar -zcvf gitlab12.9.3-ee.tar.gz /etc/gitlab

备份数据文件(git数据目录)

sh 复制代码
tar -zcvf git-data12.9.3-ee.tar.gz /var/opt/gitlab/git-data

将以上三个文件下载或备份到其它服务器

配置yum源

sh 复制代码
cd /etc/yum.repos.d/
vi gitlab-ee.repo
sh 复制代码
[gitlab-ee]
name=gitlab-ee
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/
Repo_gpgcheck=0
Enabled=1
Gpgkey=https://packages.gitlab.com/gpg.key

重建yum缓存

sh 复制代码
yum makecache

确定升级路径

参考

https://docs.gitlab.com/ee/update/?tab=Self-compiled+(source)#version-specific-upgrading-instructions

https://archives.docs.gitlab.com/15.11/ee/update/#upgrade-paths

由此可以确定,我们的升级路径应该是

12.9.3-ee > 12.10.14 >13.0.14 > 13.1.11 > 13.8.8 > 13.12.15 > 14.0.12 > 14.3.6 > 14.9.5 > 14.10.5 >15.0.5 > 15.1.6 (for GitLab instances with multiple web nodes) > 15.4.6 > 15.11.13 > 16.0.8 (only instances with lots of users or large pipeline variables history) > 16.1.6 (instances with NPM packages in their package registry) > 16.2.9 (only instances with large pipeline variables history) > 16.3.7 > 16.7.6 > latest 16.9.1

这里的16.7.6和16.9.1是根据仓库(https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/)中的最新小版本确定的

升级至12.10.14

升级到12.10.14 不必全部停止(升级中可能会用到其它服务)

停止gitlab相关服务

sh 复制代码
gitlab-ctl stop nginx
gitlab-ctl stop sidekiq
gitlab-ctl stop unicorn

安装12.10.9版本

sh 复制代码
yum --showduplicates list gitlab-ee   # 查看yum可用安装包

yum -y install gitlab-ee-12.10.14-ee.0.el7  --nogpgcheck

升级完成后,重新加载配置文件并重启

sh 复制代码
gitlab-ctl reconfigure
gitlab-ctl restart

验证

打开git网址或通过gitlab-ctl tail gitlab-rails查看日志

如果上面的升级没有问题,接下来重复上述步骤按照升级路径依次升级

13.12.15版本升级14.0.12版本需要先执行以下操作

14版本更新后将unicorn替换为puma

sh 复制代码
vim /etc/gitlab/gitlab.rb 
:%s/unicorn/puma/g

重新加载配置文件

sh 复制代码
gitlab-ctl reconfigure

配置完成后可以看到如下提示

这里要根据提示重启postgresql

sh 复制代码
gitlab-ctl restart postgresql

这里还需要注意14版本建议的redis版本为6.x,如果redis版本较低,在这里也要升级redis。

centos可以参考centos使用yum安装redis最新版CentOS 7安装redis6.2.6。如果有重要数据记得备份

如果在执行gitlab-ctl reconfigure时遇到错误,按照错误提示处理即可,我这里有遇到

sh 复制代码
sudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,ci_job_artifacts,id,'[["id"\, "job_id"]\, ["id_convert_to_bigint"\, "job_id_convert_to_bigint"]]']

sudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,ci_builds_metadata,id,'[["id"]\, ["id_convert_to_bigint"]]']

sudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,taggings,id,'[["id"\, "taggable_id"]\, ["id_convert_to_bigint"\, "taggable_id_convert_to_bigint"]]']

按照提示执行即可

检查是否有执行中的迁移

sudo gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining'

如果结果显示为0,则可以继续升级

参考文章
gitlab-ce 大版本升级方式 | 13.xx.xx升级到14.xx.xx注意事项
gitlab 14.4.2升级至15.11.2报错修复
gitlab升级12.2.8版本至14.9.2版本
gitlab 日志查看
关闭gitlab中的prometheus

相关推荐
明月心9521 天前
git remote add 用法
gitlab
only_Klein2 天前
jenkins流水线报错:Connection reset by peer
ci/cd·kubernetes·gitlab·jenkins·ssl
梁萌2 天前
docker部署gitlab和gitlab runner
docker·eureka·gitlab
johnnyAndCode3 天前
Idea 设置GitLab时使用账密,而不是token的配置方法
gitlab·idea
天外飞雨3 天前
Gitlab使用
gitlab
BUTCHER53 天前
GitLab SSH 密钥配置
运维·ssh·gitlab
明月心9523 天前
GitLab使用
gitlab
明月心9524 天前
gitlab pull requets
gitlab
BUTCHER54 天前
GitLab基本设置
gitlab
张小凡vip5 天前
Kubernetes---gitlab的ci/cd发布基于k8s的项目示例参考
ci/cd·kubernetes·gitlab