百度360必应搜狗淘宝本站头条
当前位置:网站首页 > IT知识 > 正文

gitlab-ce 版本升级及问题处理

liuian 2025-01-16 20:09 25 浏览


背景:

当前版本10.5.6存在较多的安全隐患,且官方已经不在维护此版本。当前版本已经是16.6

升级必要性

  • 安全漏洞和数据泄露
  • 功能限制和缺失: 新版本的GitLab通常会引入新功能和增强功能;
  • 缺少错误修复和性能改进: GitLab的升级通常包含对已知错误的修复和对性能的改进;
  • 兼容性问题: 随着时间的推移,操作系统、数据库
  • 缺乏社区支持和文档更新: GitLab的社区不断发展和演变,提新的文档不适用于旧版本。

安全漏洞

存在已经披露的安全漏洞。

GitLab的代码执行漏洞(CVE-2023-2478)

受影响的版本范围是:

  • 15.4 <= GitLab CE/EE < 15.9.7
  • 15.10 <= GitLab CE/EE < 15.10.6
  • 15.11 <= GitLab CE/EE < 15.11.2

通过Nessux扫描出来的已经公开的安全漏洞

目前最新的版本16系列就是没影响的。所以,对于大多数用户,这个漏洞给出的修复,也是推荐升级GitLab版本。当前我们使用的版本为10.5.6,是5年前2018年。

升级的风险

  1. 仓库安全!
  2. 其他依赖问题

如何升级

  1. 仓库镜像备份
  2. 依据官方提供方案依次做升级

本文档的目的是验证升级的可行性,仓库为镜像备份恢复后进行操作,对原代码仓库无影响。

开始升级

官方升级文档:https://docs.gitlab.com/ee/update/index.html#upgrade-paths 
升级路径工具:https://gitlab-com.gitlab.io/support/toolbox/upgrade-path

实际使用版本是10.5.6,最新版本16.6 版本跨度大,需要逐个版本的升级,无法直接进行升级。

可以通过官方提供的升级路径工具进行确认升级的版本路径。在官方提供工具中没有实际在用的10.5.6版本,选择最接近的10.5.8,然后升级到当前最新版本16.6.0。由于中间需要升级的大版本和小版本太多,耗费时间较长,可通过分批次升级方式进行。

操作步骤

gitlab升级路径规划:

10.8.7 => 11.11.8 => 12.0.12 => 12.1.17 => 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.4.6 => 15.11.13 => 16.1.5 => 16.3.6 => 16.6.0

升级操作:

chmod 0755 /var/opt/gitlab/postgresql
systemctl restart gitlab-runsvdir  #
yum install gitlab-ce-10.8.7 -y
yum install gitlab-ce-11.11.8 -y
yum install gitlab-ce-12.0.12 -y
yum install gitlab-ce-12.1.17 -y
yum install gitlab-ce-12.10.14 -y
yum install gitlab-ce-13.0.14 -y
yum install gitlab-ce-13.1.11 -y
yum install gitlab-ce-13.8.8 -y
yum install gitlab-ce-13.12.15 -y
yum install gitlab-ce-14.0.12 -y
yum install gitlab-ce-14.3.6 -y
yum install gitlab-ce-14.9.5 -y
yum install gitlab-ce-14.10.5 -y
yum install gitlab-ce-15.0.5 -y
yum install gitlab-ce-15.4.6 -y
yum install gitlab-ce-15.11.13 -y
yum install gitlab-ce-16.1.5 -y
yum install gitlab-ce-16.3.6 -y
yum install gitlab-ce-16.6.0 -y

gitlab-ctl reconfigure
gitlab-ctl restart

PostgreSQL 升级规划

  • GitLab 版本迭代过程中,其 PostgreSQL 的要求版本也在不断更新。出于谨慎性考虑,在 GitLab 升级过程中手动升级 PostgreSQL 。

GitLab 版本

PostgreSQL 版本

12.0.12

升级至 PostgreSQL 10

12.10.14

升级至 PostgreSQL 11.7(需要手动升级)

13.8.8

升级至 PostgreSQL 12.6(自动升级)

15.4.6

升级至 PostgreSQL 13(需要手动升级)

查看命令

#查看所有日志
gitlab-ctl tail  
查看当前版本:
rpm -qa gitlab-ce
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
cat /var/opt/gitlab/postgresql/data/PG_VERSION
/opt/gitlab/embedded/bin/pg_ctl --version
/opt/gitlab/embedded/bin/psql --version

FAQ

1.备份目录的权限问题

[root@bogon ~]# yum install gitlab-ce-10.8.7

gitlab preinstall: 
gitlab preinstall: This node does not appear to be running a database
gitlab preinstall: Skipping version check, if you think this is an error exit now
gitlab preinstall: 
gitlab preinstall: Automatically backing up only the GitLab SQL database (excluding everything else!)
Dumping database ... 
Dumping PostgreSQL database gitlabhq_production ... pg_dump: [archiver (db)] connection to database "gitlabhq_production" failed: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
Backup failed

解决方法:

先执行
chmod 0755 /var/opt/gitlab/postgresql
systemctl restart gitlab-runsvdir
然后在进行升级

2.登录Deploy in progress 错误

升级到gitlab-ce-12.1.17版本后登录提示 Deploy in progress

Deploy in progress 
Please try again in a few minutes.

解决方案:gitlab-ctl deploy-page down

[root@bogon ~]# gitlab-ctl deploy-page down
rm -f /opt/gitlab/embedded/service/gitlab-rails/public/index.html

3.PostgreSQL 版本低错误

gitlab-ce-12.10.1更新到gitlab-c-13.0.14 版本时候失败,错误信息如下

gitlab preinstall: Your version of PostgreSQL is no longer supported. Please upgrade your PostgreSQL version to 11.
gitlab preinstall: Check https://docs.gitlab.com/omnibus/settings/database.html#upgrade-packaged-postgresql-server for details.
gitlab preinstall:
gitlab preinstall: Upgrade failed. Retry the upgrade after upgrading your PostgreSQL version.
error: %pre(gitlab-ce-13.0.14-ce.0.el7.x86_64) scriptlet failed, exit status 1
Error in PREIN scriptlet in rpm package gitlab-ce-13.0.14-ce.0.el7.x86_64
Verifying  : gitlab-ce-13.0.14-ce.0.el7.x86_64                                                                                                                                                                                    1/2
gitlab-ce-12.10.14-ce.0.el7.x86_64 was supposed to be removed but is not!

错误原因:要求PostgreSQL版本进行升级,

PostgreSQL升级操作

PostgreSQL升级命令:  gitlab-ctl pg-upgrade -V 11
生成数据库统计信息:
sudo gitlab-psql -c "SELECT relname, last_analyze, last_autoanalyze FROM pg_stat_user_tables WHERE last_analyze IS NULL AND last_autoanalyze IS NULL;"
执行以上sql,如果有任何输出,则手动运行:
sudo gitlab-psql -c 'SET statement_timeout = 0; ANALYZE VERBOSE;'

查看版本命令:/opt/gitlab/embedded/bin/postgres --version

参考官方文档:
https://docs.gitlab.com/omnibus/settings/database.html#
upgrade-packaged-postgresql-server

解决方案

[root@bogon postgresql]# cd  /var/opt/gitlab/postgresql/
[root@bogon postgresql]# mv data.11/ data.11-bak

[root@bogon postgresql]# gitlab-ctl pg-upgrade -V 11
Checking for an omnibus managed postgresql: OK
Checking if postgresql['version'] is set: OK
Checking if we already upgraded: NOT OK
Checking for a newer version of PostgreSQL to install
Upgrading PostgreSQL to 11.7
Checking if PostgreSQL bin files are symlinked to the expected location: OK
Waiting 30 seconds to ensure tasks complete before PostgreSQL upgrade.
See https://docs.gitlab.com/omnibus/settings/database.html#upgrade-packaged-postgresql-server for details
If you do not want to upgrade the PostgreSQL server at this time, enter Ctrl-C and see the documentation for details

Please hit Ctrl-C now if you want to cancel the operation.
Toggling deploy page:cp /opt/gitlab/embedded/service/gitlab-rails/public/deploy.html /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling services:ok: down: alertmanager: 0s, normally up
ok: down: gitaly: 1s, normally up
ok: down: gitlab-exporter: 0s, normally up
ok: down: grafana: 1s, normally up
ok: down: logrotate: 0s, normally up
ok: down: node-exporter: 1s, normally up
ok: down: postgres-exporter: 0s, normally up
ok: down: prometheus: 0s, normally up
ok: down: redis-exporter: 1s, normally up
ok: down: sidekiq: 1s, normally up
Toggling services: OK
Running stop on postgresql:ok: down: postgresql: 0s, normally up
Running stop on postgresql: OK
Symlink correct version of binaries: OK
Creating temporary data directory: OK
Initializing the new database: OK
……
==== Upgrade has completed ====
Please verify everything is working and run the following if so
sudo rm -rf /var/opt/gitlab/postgresql/data.10
sudo rm -f /var/opt/gitlab/postgresql-version.old      
[root@bogon postgresql]# /opt/gitlab/embedded/bin/psql --version
psql (PostgreSQL) 11.7

4.gitlab 14 版本起,全面启用哈希存储,不在支持传统存储

升级gitlab-ce-13.8.8版本后 gitlab-ctl reconfigure 报错误

Running handlers:
There was an error running gitlab-ctl reconfigure:

sidekiq_service[sidekiq] (gitlab::sidekiq-cluster line 20) had an error: Mixlib::ShellOut::ShellCommandFailed: runit_service[sidekiq] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/sidekiq_service.rb line 50) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/sidekiq ----
STDOUT: timeout: run: /opt/gitlab/service/sidekiq: (pid 11365) 117s, got TERM
STDERR: 
---- End output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/sidekiq ----
Ran /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/sidekiq returned 1

Running handlers complete
Chef Infra Client failed. 4 resources updated in 01 minutes 26 seconds

解决方案:gitlab-ctl restart

5、存储库中有传统存储

13.12.15 升级14.0.12 报如下错误 原因是gitlab 14 版本起,全面启用哈希存储,不在支持传统存储

gitlab preinstall: Checking for unmigrated data on legacy storage
gitlab preinstall: 
gitlab preinstall: Legacy storage is no longer supported. Please migrate your data to hashed storage.
gitlab preinstall: Check https://docs.gitlab.com/ee/administration/raketasks/storage.html#migrate-to-hashed-storage for details.
gitlab preinstall: 
gitlab preinstall: If you want to skip this check, run the following command and try again:
gitlab preinstall: 
gitlab preinstall:  sudo touch /etc/gitlab/skip-unmigrated-data-check
gitlab preinstall: 
error: %pre(gitlab-ce-14.0.12-ce.0.el7.x86_64) scriptlet failed, exit status 1
Error in PREIN scriptlet in rpm package gitlab-ce-14.0.12-ce.0.el7.x86_64
gitlab-ce-13.12.15-ce.0.el7.x86_64 was supposed to be removed but is not!
  Verifying  : gitlab-ce-13.12.15-ce.0.el7.x86_64                                                                                                                                                                      1/2 
  Verifying  : gitlab-ce-14.0.12-ce.0.el7.x86_64                                                                                                                                                                       2/2 

Failed:
  gitlab-ce.x86_64 0:13.12.15-ce.0.el7                                                                         gitlab-ce.x86_64 0:14.0.12-ce.0.el7                                                                        

Complete!

解决方案

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

gitlab-rake
gitlab:storage:migrate_to_hashed 执行后每次迁移时都提示成功,多次执行都返回如下内容:

Enqueuing migration of 309 projects in batches of 200.. Done!

原因:项目read-only 为true需要将所有项目批量修改为false

解决方案:

[root@bogon tmp]# gitlab-rails console
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
 GitLab:       13.12.15 (6614e1562c6) FOSS
 GitLab Shell: 13.18.1
 PostgreSQL:   12.6
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.3.7)
irb(main):001:0> 

irb(main):001:0> Project.all.find_each { |project| project.update!(repository_read_only: false) }
irb(main):001:0> Project.all.find_each { |project| project.update!(repository_read_only: true) }

执行迁移命令

gitlab-rake gitlab:storage:hashed_projects

相关推荐

GANs为何引爆机器学习?这篇基于TensorFlow的实例教程为你解惑!

「机器人圈导览」:生成对抗网络无疑是机器学习领域近三年来最火爆的研究领域,相关论文层出不求,各种领域的应用层出不穷。那么,GAN到底如何实践?本文编译自Medium,该文作者以一朵玫瑰花为例,详细阐...

高丽大学等机构联合发布StarGAN:可自定义表情和面部特征

原文来源:arXiv、GitHub作者:YunjeyChoi、MinjeChoi、MunyoungKim、Jung-WooHa、SungKim、JaegulChoo「雷克世界」编译:嗯~...

TensorFlow和PyTorch相继发布最新版,有何变化

原文来源:GitHub「机器人圈」编译:嗯~阿童木呀、多啦A亮Tensorflow主要特征和改进在Tensorflow库中添加封装评估量。所添加的评估量列表如下:1.深度神经网络分类器(DNNCl...

「2022 年」崔庆才 Python3 爬虫教程 - 深度学习识别滑动验证码缺口

上一节我们使用OpenCV识别了图形验证码躯壳欧。这时候就有朋友可能会说了,现在深度学习不是对图像识别很准吗?那深度学习可以用在识别滑动验证码缺口位置吗?当然也是可以的,本节我们就来了解下使用深度...

20K star!搞定 LLM 微调的开源利器

LLM(大语言模型)微调一直都是老大难问题,不仅因为微调需要大量的计算资源,而且微调的方法也很多,要去尝试每种方法的效果,需要安装大量的第三方库和依赖,甚至要接入一些框架,可能在还没开始微调就已经因为...

大模型DeepSeek本地部署后如何进行自定义调整?

1.理解模型架构a)查看深度求索官方文档或提供的源代码文件,了解模型的结构、输入输出格式以及支持的功能。模型是否为预训练权重?如果是,可以在预训练的基础上进行微调(Fine-tuning)。是否需要...

因配置不当,约5000个AI模型与数据集在公网暴露

除了可访问机器学习模型外,暴露的数据还可能包括训练数据集、超参数,甚至是用于构建模型的原始数据。前情回顾·人工智能安全动态向ChatGPT植入恶意“长期记忆”,持续窃取用户输入数据多模态大语言模型的致...

基于pytorch的深度学习人员重识别

基于pytorch的深度学习人员重识别Torchreid是一个库。基于pytorch的深度学习人员重识别。特点:支持多GPU训练支持图像的人员重识别与视频的人员重识别端到端的训练与评估简单的re...

DeepSeek本地部署:轻松训练你的AI模型

引言:为什么选择本地部署?在AI技术飞速发展的今天,越来越多的企业和个人希望将AI技术应用于实际场景中。然而,对于一些对数据隐私和计算资源有特殊需求的用户来说,云端部署可能并不是最佳选择。此时,本地部...

谷歌今天又开源了,这次是Sketch-RNN

前不久,谷歌公布了一项最新技术,可以教机器画画。今天,谷歌开源了代码。在我们研究其代码之前,首先先按要求设置Magenta环境。(https://github.com/tensorflow/magen...

Tensorflow 使用预训练模型训练的完整流程

前面已经介绍了深度学习框架Tensorflow的图像的标注和训练数据的准备工作,本文介绍一下使用预训练模型完成训练并导出训练的模型。1.选择预训练模型1.1下载预训练模型首先需要在Tensorf...

30天大模型调优学习计划(30分钟训练大模型)

30天大模型调优学习计划,结合Unsloth和Lora进行大模型微调,掌握大模型基础知识和调优方法,熟练应用。第1周:基础入门目标:了解大模型基础并熟悉Unsloth等工具的基本使用。Day1:大模...

python爬取喜马拉雅音频,json参数解析

一.抓包分析json,获取加密方式1.抓包获取音频界面f12打开抓包工具,播放一个(非vip)视频,点击“媒体”单击打开可以复制URL,发现就是我们要的音频。复制“CKwRIJEEXn-cABa0Tg...

五、JSONPath使用(Python)(json数据python)

1.安装方法pipinstalljsonpath2.jsonpath与Xpath下面表格是jsonpath语法与Xpath的完整概述和比较。Xpathjsonpath概述/$根节点.@当前节点...

Python网络爬虫的时候json=就是让你少写个json.dumps()

大家好,我是皮皮。一、前言前几天在Python白银交流群【空翼】问了一个Python网络爬虫的问题,提问截图如下:登录请求地址是这个:二、实现过程这里【甯同学】给了一个提示,如下所示:估计很多小伙伴和...