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

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

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


背景:

当前版本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

相关推荐

2023年最新微信小程序抓包教程(微信小程序 抓包)

声明:本公众号大部分文章来自作者日常学习笔记,部分文章经作者授权及其他公众号白名单转载。未经授权严禁转载。如需转载,请联系开百。请不要利用文章中的相关技术从事非法测试。由此产生的任何不良后果与文...

测试人员必看的软件测试面试文档(软件测试面试怎么说)

前言又到了毕业季,我们将会迎来许多需要面试的小伙伴,在这里呢笔者给从事软件测试的小伙伴准备了一份顶级的面试文档。1、什么是bug?bug由哪些字段(要素)组成?1)将在电脑系统或程序中,隐藏着的...

复活,视频号一键下载,有手就会,长期更新(2023-12-21)

视频号下载的话题,也算是流量密码了。但也是比较麻烦的问题,频频失效不说,使用方法也难以入手。今天,奶酪就来讲讲视频号下载的新方案,更关键的是,它们有手就会有用,最后一个方法万能。实测2023-12-...

新款HTTP代理抓包工具Proxyman(界面美观、功能强大)

不论是普通的前后端开发人员,还是做爬虫、逆向的爬虫工程师和安全逆向工程,必不可少会使用的一种工具就是HTTP抓包工具。说到抓包工具,脱口而出的肯定是浏览器F12开发者调试界面、Charles(青花瓷)...

使用Charles工具对手机进行HTTPS抓包

本次用到的工具:Charles、雷电模拟器。比较常用的抓包工具有fiddler和Charles,今天讲Charles如何对手机端的HTTS包进行抓包。fiddler抓包工具不做讲解,网上有很多fidd...

苹果手机下载 TikTok 旧版本安装包教程

目前苹果手机能在国内免拔卡使用的TikTok版本只有21.1.0版本,而AppStore是高于21.1.0版本,本次教程就是解决如何下载TikTok旧版本安装包。前期准备准备美区...

【0基础学爬虫】爬虫基础之抓包工具的使用

大数据时代,各行各业对数据采集的需求日益增多,网络爬虫的运用也更为广泛,越来越多的人开始学习网络爬虫这项技术,K哥爬虫此前已经推出不少爬虫进阶、逆向相关文章,为实现从易到难全方位覆盖,特设【0基础学爬...

防止应用调试分析IP被扫描加固实战教程

防止应用调试分析IP被扫描加固实战教程一、概述在当今数字化时代,应用程序的安全性已成为开发者关注的焦点。特别是在应用调试过程中,保护应用的网络安全显得尤为重要。为了防止应用调试过程中IP被扫描和潜在的...

一文了解 Telerik Test Studio 测试神器

1.简介TelerikTestStudio(以下称TestStudio)是一个易于使用的自动化测试工具,可用于Web、WPF应用的界面功能测试,也可以用于API测试,以及负载和性能测试。Te...

HLS实战之Wireshark抓包分析(wireshark抓包总结)

0.引言Wireshark(前称Ethereal)是一个网络封包分析软件。网络封包分析软件的功能是撷取网络封包,并尽可能显示出最为详细的网络封包资料。Wireshark使用WinPCAP作为接口,直接...

信息安全之HTTPS协议详解(加密方式、证书原理、中间人攻击 )

HTTPS协议详解(加密方式、证书原理、中间人攻击)HTTPS协议的加密方式有哪些?HTTPS证书的原理是什么?如何防止中间人攻击?一:HTTPS基本介绍:1.HTTPS是什么:HTTPS也是一个...

Fiddler 怎么抓取手机APP:抖音、小程序、小红书数据接口

使用Fiddler抓取移动应用程序(APP)的数据接口需要进行以下步骤:首先,确保手机与计算机连接在同一网络下。在计算机上安装Fiddler工具,并打开它。将手机的代理设置为Fiddler代理。具体方...

python爬虫教程:教你通过 Fiddler 进行手机抓包

今天要说说怎么在我们的手机抓包有时候我们想对请求的数据或者响应的数据进行篡改怎么做呢?我们经常在用的手机手机里面的数据怎么对它抓包呢?那么...接下来就是学习python的正确姿势我们要用到一款强...

Fiddler入门教程全家桶,建议收藏

学习Fiddler工具之前,我们先了解一下Fiddler工具的特点,Fiddler能做什么?如何使用Fidder捕获数据包、修改请求、模拟客户端向服务端发送请求、实施越权的安全性测试等相关知识。本章节...

fiddler如何抓取https请求实现手机抓包(100%成功解决)

一、HTTP协议和HTTPS协议。(1)HTTPS协议=HTTP协议+SSL协议,默认端口:443(2)HTTP协议(HyperTextTransferProtocol):超文本传输协议。默认...