前言:gitlab11升级到14还是有挺多需要注意的坑,也算是做一次积累吧,升级前后,gitalb的WEB界面也变化了很多,升级过程需要注意的地方我放到最后说明,挺关键的

一、首先需要下载好要升级的包,这里需要注意,gitlab的官网有说明如何升级,大概就是如下面所示,跨版本升级先要升级到版本最后一个版本才行,比如线上使用11.0.7,要升级到11.11.8才能升级到12.0.12

包下载地址
https://packages.gitlab.com/gitlab/gitlab-ce

官网建议按以下版本来升级

GitLab 8: 8.11.Z > 8.12.0 > 8.17.7
GitLab 9: 9.0.13 > 9.5.10
GitLab 10: 10.0.7 > 10.8.7
GitLab 11: 11.0.6 > 11.11.8
GitLab 12: 12.0.12 > 12.1.17 > 12.10.14
GitLab 13: 13.0.14 > 13.1.11 > 13.8.8 > 13.12.15
GitLab 14: 14.0.12 > 14.3.6 > 14.9.5 > 14.10.5
GitLab 15: 15.0.5 > 15.1.6 (for GitLab instances with multiple web nodes) > 15.4.6 > latest 15.Y.Z

官网文档链接在这里

https://docs.gitlab.com/ee/update/index.html#upgrade-paths

二、升级步骤

2.1 先把nginx停止,外部无法访问了

/usr/local/nginx/sbin/nginx -s stop

2.2 做一次备份,整个过程我只做一次备份,我也在阿里云做镜像以防万一,同时我在操作线上升级前已经反复尝试,还是有信心的

gitlab-rake gitlab:backup:create

备份敏感数据
cp  /etc/gitlab/gitlab.rb  /data/gitlab/backups
cp  /etc/gitlab/gitlab-secrets.json  /data/gitlab/backups

2.3 关闭gitlab的部分服务

13.x以前版本关闭unicorn,14.x版本就不支持unicorn,从13版本开始,我使用puma方式,停止方式gitlab-ctl stop puma

gitlab-ctl stop unicorn

gitlab-ctl stop sidekiq

2.4 升级新版本

rpm -Uvh 要升级版本.rpm

这里要升级到11.11.8版本为例子

rpm -Uvh gitlab-ce-11.11.8-ce.0.el7.x86_64.rpm

2.5升级完成后,没有报错情况下,需要重新运行配置,否则启动会失败  

gitlab-ctl reconfigure

2.6 启动

gitlab-ctl restart

2.7 查看gitlab版本信息  

第一种
gitlab-rake gitlab:env:info

第二种
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION 

2.8 检查服务

gitlab-rake gitlab:check SANITIZE=true

systemctl status gitlab-runsvdir.service

2.9 启动nginx  

/usr/local/nginx/sbin/nginx

三、检查测试git提交是否正常

我这里会修改代码,然后提交是否正常,如果没有问题就当升级成功了

 

 

 

 

四、需要注意的问题,我都说明下

4.1 gitlab13.x版本要安装并且开启Puma,因为14版本就不支持unicorn

4.2 升级13版本前一个版本需要升级postgresql,就是升级到了12.10.14版本,再执行更新postgresql

更新
gitlab-ctl pg-upgrade 

需要重新运行配置,否则启动会失败
gitlab-ctl reconfigure

启动
gitlab-ctl restart

4.3 在gitlab13.x的最后一个版本 将传统存储转换为哈希存储,也就是13.12.15版本,文档说明

https://docs.gitlab.com/ee/administration/raketasks/storage.html#migrate-to-hashed-storage%20for%20details

步骤如下

gitlab-rake gitlab:storage:migrate_to_hashed
 
# 执行成功后,再次执行,会提示如下内容:
#There are no projects requiring storage migration. Nothing to do!

# 全部迁移成功,以下命令查看所列出的项目总数与页面的理应一致
gitlab-rake gitlab:storage:hashed_projects
 
# 查看,全部迁移成功以下两条命令应该为 0 
gitlab-rake gitlab:storage:legacy_projects
gitlab-rake gitlab:storage:legacy_attachments
 
# 列出传统存储的项目以及附件
gitlab-rake gitlab:storage:list_legacy_projects
gitlab-rake gitlab:storage:list_legacy_attachments

4.5 升级14.x版本前一个版本升级postgresql,也就是13.12.15版本

更新
gitlab-ctl pg-upgrade 

需要重新运行配置,否则启动会失败
gitlab-ctl reconfigure

启动
gitlab-ctl restart

  

最后没问题了,正常使用~

  

作者:|lucky_tomato|,原文链接: https://www.cnblogs.com/lucktomato/p/17209110.html

文章推荐

【Lua】VSCode 搭建 Lua 开发环境

基于Canal实现MySQL 8.0 数据库数据同步

安装Zookeeper和Kafka集群

nginx各种代理配置

Windows 系统下怎么获取 UDP 本机地址

Net DB Web多级缓存的实现

Linux xargs命令介绍

Next.js 实践:从 SSR 到 CSR 的优雅降级

Spring MVC的请求处理逻辑

Linux的文件权限管理

关于this指向的一些梳理

SpringBoot+Mybatis-Plus整合Sharding-JDBC5.1.1实现单库分...