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

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

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


背景:

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

相关推荐

python入门到脱坑函数—定义函数_如何定义函数python

Python函数定义:从入门到精通一、函数的基本概念函数是组织好的、可重复使用的代码块,用于执行特定任务。在Python中,函数可以提高代码的模块性和重复利用率。二、定义函数的基本语法def函数名(...

javascript函数的call、apply和bind的原理及作用详解

javascript函数的call、apply和bind本质是用来实现继承的,专业点说法就是改变函数体内部this的指向,当一个对象没有某个功能时,就可以用这3个来从有相关功能的对象里借用过来...

JS中 call()、apply()、bind() 的用法

其实是一个很简单的东西,认真看十分钟就从一脸懵B到完全理解!先看明白下面:例1obj.objAge;//17obj.myFun()//小张年龄undefined例2shows(...

Pandas每日函数学习之apply函数_apply函数python

apply函数是Pandas中的一个非常强大的工具,它允许你对DataFrame或Series中的数据应用一个函数,可以是自定义的函数,也可以是内置的函数。apply可以作用于DataF...

Win10搜索不习惯 换个设定就好了_window10搜索用不了怎么办

Windows10的搜索功能是真的方便,这点用惯了Windows10的小伙伴应该都知道,不过它有个小问题,就是Windows10虽然会自动联网搜索,但默认使用微软自家的Bing搜索引擎和Edge...

面试秘籍:call、bind、apply的区别,面试官为什么总爱问这三位?

引言你有没有发现,每次JavaScript面试,面试官总爱问你call、bind和apply的区别?好像这三个方法成了通关密码,掌握了它们,就能顺利过关。其实不难理解,面试官问这些问题,不...

记住这8招,帮你掌握“追拍“摄影技法—摄影早自习第422日

杨海英同学提问:请问叶梓老师,我练习追拍时,总也不能把运动的人物拍清晰,速度一般掌握在1/40-1/60,请问您如何把追拍拍的清晰?这跟不同的运动形式有关系吗?请您给讲讲要点,谢谢您!摄影:Damia...

[Sony] 有点残酷的测试A7RII PK FS7

都是好机!手中利器!主要是最近天天研究fs5,想知道fs5与a7rii后期匹配问题,苦等朋友的fs5月底到货,于是先拿手里现有的fs7小测一下,十九八九也能看到fs5的影子,另外也了解一下fs5k标配...

AndroidStudio_Android使用OkHttp发起Http请求

这个okHttp的使用,其实网络上有很多的案例的,但是,如果以前没用过,copy别人的直接用的话,可以发现要么导包导不进来,要么,人家给的代码也不完整,这里自己整理一下.1.引入OkHttp的jar...

ESL-通过事件控制FreeSWITCH_es事务控制

通过事件提供的最底层控制机制,允许我们有效地利用工具箱,适时选择使用其中的单个工具。FreeSWITCH是一个核心交换与混合矩阵,它周围有几十个模块提供各种功能特性。我们完全控制了所有的即时信息,这些...

【调试】perf和火焰图_perf生成火焰图

简介perf是linux上的性能分析工具,perf可以对event进行统计得到event的发生次数,或者对event进行采样,得到每次event发生时的相关数据(cpu、进程id、运行栈等),利用这些...

文本检索控件也玩安卓?dtSearch Engine发布Android测试版

dtSearchEngineforLinux(原生64-bit/32-bitC++和JavaAPIs)和dtSearchEngineforWin&.NET(原生64-bi...

网站后台莫名增加N个管理员,记一次SQL注入攻击

网站没流量,但却经常被SQL注入光顾。最近,网站真的很奇怪,网站后台不光莫名多了很多“管理员”,所有的Wordpres插件还会被自动暂停,导致一些插件支持的页面,如WooCommerce无法正常访问、...

多元回归树分析Multivariate Regression Trees,MRT

多元回归树(MultivariateRegressionTrees,MRT)是单元回归树的拓展,是一种对一系列连续型变量递归划分成多个类群的聚类方法,是在决策树(decision-trees)基础...

JMETER性能测试_JMETER性能测试指标

jmeter为性能测试提供了一下特色:jmeter可以对测试静态资源(例如js、html等)以及动态资源(例如php、jsp、ajax等等)进行性能测试jmeter可以挖掘出系统最大能处...