该笔记将记录:通过 Docker 镜像部署的 GitLab 服务的升级方法,以及常见问题的解决方案;
对于 Docker 部署的 GitLab 服务,仅有一个镜像,升级过程也比较简单:
根据官方文档,对于 Docker 部署,升级过程如下:
1)停止容器,并删除旧容器;
2)拉取镜像,到最新版本;
2)启动新容器,并检查 GitLab 正常运行;
但是,为了保险起见,每次我们仅升级一个次版本号。例如,我们会按照 13.6 => 13.7 => 13.8 => 13.9 的顺序依次升级;
docker-compose.yaml
version: '3' services: web: image: docker.io/gitlab/gitlab-ce:16.4.1-ce.0 restart: always hostname: 'gitlab' ports: - '8929:80' - '8930:443' # - '22:22' volumes: - ./data/etc:/etc/gitlab - ./data/log:/var/log/gitlab - ./data/var:/var/opt/gitlab - /etc/localtime:/etc/localtime
12.4.2-ce.0 to 13.6.3-ce.0
2021-01-05
我们的 GitLab 当前版本为 12.4 版本(容器部署),需要升级到 13.6 版本,以使用某些新功能;
此次升级最主要的问题:在于跨版本升级很可能会失败,这也是不经常升级的缺点;
该部分将记录:如何将 GitLab 从 12.x 升级到 13.x 版本,以及相关问题的解决方法;
第一步、备份数据
运维工作千万条,数据备份第一条。执行如下命令进行数据升级:
rsync -av /data/gitlab/ /data/gitlab.12.4.2-ce.0.backup/
第二步、服务升级
最开始,我们直接从 12.4.2-ce.0 升级到 13.6.3-ce.0 版本,果然会失败;
因此改用逐步升级的方案:12.4.2-ce.0 => 12.10.14-ce.0 => 13.0.0-ce.0 => 13.3.9-ce.0 => 13.6.3-ce.0
其中,从 12.10.14-ce.0 到 13.0.0-ce.0 是非常关键的,这两个版本的变更较大;
建议认真阅读 Upgrading GitLab | GitLab 文档,官方给出升级路径(Upgrade paths);
第三步、验证结果
1)访问我们的 GitLab 站点进行验证;
2)进行代码推送,验证服务可用;
Start with GitLab 13.6.3-ce.0
13.6.3-ce.0 to 14.0.5-ce.0
2021-07-16
第一步、数据备份:
rsync -av /data/gitlab/ /srv/backup/gitlab/
第二步,修改 docker-compose.yaml 的镜像版本,每次仅升级一个次版本号:
13.6.3-ce.0 => 13.7.9-ce.0 => 13.8.8-ce.0 => 13.9.7-ce.0 => 13.10.5-ce.0 => 13.11.7-ce.0 => 13.12.8-ce.0 => 14.0.5-ce.0
第三步、访问站点检查服务能够正常运行,然后进行代码推送测试
15.0.0-ce.0 => 15.8.0-ce.0
01/25/2023
15.0.0-ce.0 => 15.3.5-ce.0 => 15.6.6-ce.0 => 15.8.0-ce.0
第一步、数据备份
官方建议:Take a backup. As a minimum, back up the database and the GitLab secrets file.
我们进行停机,直接增量备份全部数据:
rsync -av /data/gitlab/ /srv/backup/gitlab/
第二步、更新镜像
Download the newest release and upgrade your GitLab instance:
修改 docker-compose.yaml 的镜像版本,并启动服务;
第三步、访问测试
访问站点检查服务能够正常运行,然后进行代码推送测试
15.8.0-ce.0 => 15.11.13-ce.0 => 16.0.0-ce.0 => 16.2.8-ce.0 => 16.3.5-ce.0 => 16.4.1-ce.0
# 10/14/2023 我们需要将 15.8 升级到当前最新版本(16.4);
该部分是对升级过程的总结归纳,参考 GitLab Docker images/Upgrade 文档,以获得升级的详细说明;
部署方式:Docker Image, Docker Compose, GitLab Omnibus
部署目录:/data/gitlab/
数据目录:/srv/hdd/gitlab/
注 1:升级 16.3.x 版本是必须的,否则容器会退出,并且日志提示先升级到 16.3.x 版本;
# --------------------------------------------------------- # 第一步、数据备份 # 我们进行停机,直接增量备份全部数据: cd /data/gitlab/ docker-compose down rsync -av /data/gitlab/ /srv/backup/gitlab/15.8.0-ce.0-bin/ rsync -av /srv/hdd/gitlab/ /srv/backup/gitlab/15.8.0-ce.0-data/ # --------------------------------------------------------- # 第二步、更新镜像 # Download the newest release and upgrade your GitLab instance: docker pull gitlab/gitlab-ce:15.11.13-ce.0 # 修改 docker-compose.yaml 的镜像版本,并启动服务; vim docker-compose.yaml # --------------------------------------------------------- # 第三步、访问测试 # 1 访问站点检查服务能够正常运行 # 2 然后进行代码推送测试
排障(15.11.13-ce.0 => 16.0.0-ce.0):ThreadError: can’t create Thread: Operation not permitted
Updating from 15.11 to latest docker build fails – How to Use GitLab / Upgrade – GitLab Forum
updating gitlab to the official docker build gitlab/gitlab-ce v16.0.1 fails…
gitlab-web-1 | Synchronizing cookbooks: gitlab-web-1 | gitlab-web-1 | ================================================================================ gitlab-web-1 | Error Syncing Cookbooks: gitlab-web-1 | ================================================================================ gitlab-web-1 | gitlab-web-1 | Unexpected Error: gitlab-web-1 | ----------------- gitlab-web-1 | ThreadError: can't create Thread: Operation not permitted gitlab-web-1 | gitlab-web-1 | System Info: gitlab-web-1 | ------------ gitlab-web-1 | chef_version=17.10.0 gitlab-web-1 | platform=ubuntu gitlab-web-1 | platform_version=22.04 gitlab-web-1 | ruby=ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux] gitlab-web-1 | program_name=/opt/gitlab/embedded/bin/cinc-client gitlab-web-1 | executable=/opt/gitlab/embedded/bin/cinc-client gitlab-web-1 | gitlab-web-1 | gitlab-web-1 | Running handlers: gitlab-web-1 | [2023-10-14T08:20:55+08:00] ERROR: Running exception handlers gitlab-web-1 | There was an error running gitlab-ctl reconfigure: gitlab-web-1 | gitlab-web-1 | can't create Thread: Operation not permitted gitlab-web-1 | gitlab-web-1 | [2023-10-14T08:20:55+08:00] ERROR: Report handler GitLabHandler::Exception raised #<NameError: uninitialized constant GitLabHandler::Exception::OmnibusHelper> gitlab-web-1 | [2023-10-14T08:20:55+08:00] ERROR: /opt/gitlab/embedded/cookbooks/package/libraries/handlers/gitlab.rb:30:in `report' gitlab-web-1 | [2023-10-14T08:20:55+08:00] ERROR: /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/chef-17.10.0/lib/chef/handler.rb:296:in `run_report_unsafe' gitlab-web-1 | [2023-10-14T08:20:55+08:00] ERROR: /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/chef-17.10.0/lib/chef/handler.rb:284:in `run_report_safely' gitlab-web-1 | [2023-10-14T08:20:55+08:00] ERROR: /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/chef-17.10.0/lib/chef/handler.rb:155:in `block in run_exception_handlers' gitlab-web-1 | [2023-10-14T08:20:55+08:00] ERROR: /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/chef-17.10.0/lib/chef/handler.rb:153:in `each'
原因分析
1)参考 updating gitlab to the official docker build gitlab/gitlab-ce v16.0.1 fails with errors when starting (#412886) · Issues · GitLab.org / GitLab · GitLab 页面,It appears that the new GitLab 16.0 (which updated to use ubuntu 22.04 as the base image), now requires to be run in docker 20.10.10 or newer.
解决方案
1)升级 docker 服务到 20.10.10 版本
16.4.1-ce.0 => 16.7.2-ce.0
操作时间:01/16/2024
升级文档:GitLab/Upgrade GitLab using Docker Engine
镜像地址:Image Layer Details – gitlab/gitlab-ce:16.7.2-ce.0
官方发布重大安全更新,并且我们在 GitLab 中收到更新提示,所以我们进行升级。
GitLab Critical Security Release: 16.7.2, 16.6.4, 16.5.6 | GitLab
# 03/13/2024 如果是常规升级,也需要逐步进行
It is required to upgrade to the latest 16.7.x version first before proceeding.
升级过程:(1)停止服务,(2)rsync 备份 PG 数据库,(3)然后使用新镜像启动即可。
16.7.2-ce.0 => 16.8.1-ce.0
GitLab Docker images | GitLab
GitLab Docker images | GitLab/Update GitLab using Docker Engine
操作时间:01/29/2024
更新原因:
You are currently on version 16.7.2! We strongly recommend upgrading your GitLab installation to one of the following versions immediately: 16.8.1, 16.7.4.
升级过程:(1)停止服务,(2)rsync 备份 PG 数据库,(3)然后使用新镜像启动即可。
# 03/13/2024 服务升级 16.8.1 => 16.9.2
现部署信息:GitLab v16.8.1, Docker Compose
现最新版本:gitlab/gitlab-ce:16.9.2-ce.0
现计划升级:16.8.1 => 16.9.2
升级过程:(1)停止服务,(2)rsync 备份 PG 数据库,(3)然后使用新镜像启动即可。
# 04/15/2024 服务升级 16.9.2 => 16.10.2
现部署信息:GitLab v16.9.2, Docker Compose
现最新版本:gitlab/gitlab-ce:16.10.2-ce.0
现计划升级:16.9.2 => 16.10.2
升级过程:(1)停止服务,(2)rsync 备份 PG 数据库,(3)然后使用新镜像启动即可。
# 05/16/2024 服务升级 16.10 -> 16.11.2-ce.0
现部署信息:GitLab v16.10,Docker Compose
现最新版本:gitlab/gitlab-ce:16.11.2-ce.0
现计划升级:16.10 -> 16.11.2-ce.0
升级过程:(1)停止服务,(2)rsync 备份 PG 数据库,(3)然后使用新镜像启动即可。
Start with Gitlab 16.5.0-ee.0
服务降级 | 16.5.0-ee.0 to 16.5.0-ce.0
现有版本:with Docker, GtiLab 16.5.0-ee.0
目标版本:with Docker Compose, GitLab 16.5.0-ce.0
EE to CE:https://docs.gitlab.com/ee/downgrade_ee_to_ce/
服务升级 | 16.5.0-ce.0 to 16.7.9-ce.0
现有版本:with Docker Compose, GitLab 16.5.0-ce.0
目标版本:with Docker Compose, GitLab 16.7.9-ce.0
服务升级 | 16.7.9-ce.0 to 16.11.7-ce.0
现有版本:with Docker Compose, GitLab 16.7.9-ce.0
目标版本:with Docker Compose, GitLab 16.11.7-ce.0
服务升级 | 16.7.9-ce.0 to 16.11.7-ce.0
现有版本:with Docker Compose, GitLab 16.11.7-ce.0
目标版本:with Docker Compose, GitLab 17.4.0-ce.0
镜像仓库:https://hub.docker.com/r/gitlab/gitlab-ce
16.11.7-ce.0 -> 17.3.3-ce.0 -> 17.4.0-ce.0
https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/?current=16.11.7&distro=docker&edition=ce
Start with Gitlab v16.9.2
# 03/09/2025 服务升级 16.9.2 ⇒ 17.9.1
路线:16.9.2 => 16.11.10 => 17.1.8 => 17.3.7 => 17.5.5 => 17.8.4 => 17.9.1
docker.io/gitlab/gitlab-ce:16.9.2-ce.0
docker.io/gitlab/gitlab-ce:16.11.10-ce.0
docker.io/gitlab/gitlab-ce:17.1.8-ce.0
docker.io/gitlab/gitlab-ce:17.3.7-ce.0
docker.io/gitlab/gitlab-ce:17.5.5-ce.0
docker.io/gitlab/gitlab-ce:17.8.4-ce.0
docker.io/gitlab/gitlab-ce:17.9.1-ce.0