gitlab版本升级

历览千载书,时时见遗烈。这篇文章主要讲述gitlab版本升级相关的知识,希望能为你提供帮助。
官方文档
??版本升级路线和依赖关系??
??gitlab12 changes log??


操作步骤1. 备份机器
在阿里云后台,对机器创建镜像。

根据阿里云的文档,需要先注释掉 /etc/fstab 里面的数据盘的挂载,然后再做镜像。 注意做完镜像后,再把 /etc/fstab 里注释去掉。

耗时统计: 3T的数据盘打image耗时不到60分钟。



稳妥起见,我们这里升级分为2天去推进,留出一天观察时间来。
day1,从12.9.2升级到12.10.6 【操作前备份一次】
day2,从12.10.6升级到12.10.14,然后从12.10.14升级到13.0.14【操作前备份一次】


2. 从12.9.2升级到12.10.6
我这边生产gitlab版本是12.9.2 ,先升级到 12.10.6 ,再升级到 12.10.14 ,然后再升级到 13.0.14
【gitlab版本升级】

12.10大的改动是: 升级了pg的版本到pg11。




# 停止当前gitlab的运行(这步可省略,不停gitlab也可以的,当然如果条件允许,建议还是停下)
# gitlab-ctl stop


# 拉取最新仓库信息
# apt update


# 列出我们要安装的版本
apt-cache madison gitlab-ce | grep \'12.10.6\'
结果:
gitlab-ce | 12.10.6-ce.0 | https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu xenial/main amd64 Packages


# 安装12.10.6的gitlab-ce
apt-get install gitlab-ce=12.10.6-ce.0

日志如下:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
geoip-database-extra libjs-openlayers libwireshark8 libwiretap6 libwscodecs1 libwsutil7 linux-headers-4.4.0-93 linux-headers-4.4.0-93-generic
linux-image-4.4.0-93-generic linux-image-extra-4.4.0-93-generic
Use \'apt autoremove\' to remove them.
The following packages will be upgraded:
gitlab-ce
1 upgraded, 0 newly installed, 0 to remove and 93 not upgraded.
Need to get 799 MB of archives.
After this operation, 84.2 MB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
gitlab-ce
Install these packages without verification? [y/N] y
Get:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu xenial/main amd64 gitlab-ce amd64 12.10.6-ce.0 [799 MB]
Fetched 799 MB in 1min 12s (11.1 MB/s)
(Reading database ... 243001 files and directories currently installed.)
Preparing to unpack .../gitlab-ce_12.10.6-ce.0_amd64.deb ...
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:
Unpacking gitlab-ce (12.10.6-ce.0) over (12.9.2-ce.0) ...
Setting up gitlab-ce (12.10.6-ce.0) ...
Checking PostgreSQL executables:Starting Chef Client, version 14.14.29
resolving cookbooks for run list: ["gitlab::config", "postgresql::bin"]
Synchronizing Cookbooks:
- gitlab (0.0.1)
- postgresql (0.1.0)
- redis (0.1.0)
- package (0.1.0)
- monitoring (0.1.0)
- registry (0.1.0)
- mattermost (0.1.0)
- gitaly (0.1.0)
- consul (0.1.0)
- praefect (0.1.0)
- letsencrypt (0.1.0)
- nginx (0.1.0)
- runit (4.3.0)
- acme (4.1.1)
- crond (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 3 resources
Recipe: postgresql::bin
* ruby_block[check_postgresql_version] action run (skipped due to not_if)
* ruby_block[check_postgresql_version_is_deprecated] action run (skipped due to not_if)
* ruby_block[Link postgresql bin files to the correct version] action run
- execute the ruby block Link postgresql bin files to the correct version


Running handlers:
Running handlers complete
Chef Client finished, 1/3 resources updated in 04 seconds
Checking PostgreSQL executables: OK
Checking if Grafana needs to be reset:
Status file found. Grafana is not vulnerable. Skipping reset.
Checking if Grafana needs to be reset: OK
Found /etc/gitlab/skip-auto-reconfigure, exiting...


_______ ______
/ ____(_) /_/ /____ _/ /_
/ / __/ / __/ // __ `/ __ \\
/ /_/ / / /_/ /___/ /_/ / /_/ /
\\____/_/\\__/_____/\\__,_/_.___/



Upgrade complete! If your GitLab server is misbehaving try running
sudo gitlab-ctl restart
before anything else.
If you need to roll back to the previous version you can use the database
backup made during the upgrade (scroll up for the filename).


=== WARNING ===
Note that PostgreSQL 11 will become the minimum required PostgreSQL version in GitLab 13.0 (May 2020).
PostgreSQL 9.6 and PostgreSQL 10 will be removed in GitLab 13.0.
To upgrade, please see: https://docs.gitlab.com/omnibus/settings/database.html#upgrade-packaged-postgresql-server
=== WARNING ===



# 重启gitlab
gitlab-ctl restart

ok: run: alertmanager: (pid 15738) 0s
ok: run: gitaly: (pid 15749) 0s
ok: run: gitlab-exporter: (pid 15768) 1s
ok: run: gitlab-pages: (pid 15770) 0s
ok: run: gitlab-workhorse: (pid 15800) 1s
ok: run: grafana: (pid 15809) 0s
ok: run: logrotate: (pid 15818) 1s
ok: run: nginx: (pid 15824) 0s
ok: run: node-exporter: (pid 15830) 0s
ok: run: postgres-exporter: (pid 15912) 1s
ok: run: postgresql: (pid 15918) 0s
ok: run: prometheus: (pid 15926) 1s
ok: run: redis: (pid 15937) 0s
ok: run: redis-exporter: (pid 15942) 1s
ok: run: registry: (pid 15948) 0s
ok: run: sidekiq: (pid 15957) 0s
ok: run: unicorn: (pid 15963) 1s


# 查看状态
gitlab-ctl status

run: alertmanager: (pid 15738) 14s; run: log: (pid 1815) 2647s
run: gitaly: (pid 15749) 14s; run: log: (pid 1839) 2647s
run: gitlab-exporter: (pid 15768) 14s; run: log: (pid 1809) 2647s
run: gitlab-pages: (pid 15770) 13s; run: log: (pid 1808) 2647s
run: gitlab-workhorse: (pid 15800) 13s; run: log: (pid 1820) 2647s
run: grafana: (pid 15809) 12s; run: log: (pid 1810) 2647s
run: logrotate: (pid 15818) 12s; run: log: (pid 1816) 2647s
run: nginx: (pid 15824) 11s; run: log: (pid 1812) 2647s
run: node-exporter: (pid 15830) 11s; run: log: (pid 1833) 2647s
run: postgres-exporter: (pid 15912) 11s; run: log: (pid 1835) 2647s
run: postgresql: (pid 15918) 10s; run: log: (pid 1804) 2647s
run: prometheus: (pid 15926) 10s; run: log: (pid 1805) 2647s
run: redis: (pid 15937) 9s; run: log: (pid 1821) 2647s
run: redis-exporter: (pid 15942) 9s; run: log: (pid 1806) 2647s
run: registry: (pid 15948) 8s; run: log: (pid 1803) 2647s
run: sidekiq: (pid 15957) 8s; run: log: (pid 1807) 2647s
run: unicorn: (pid 15963) 8s; run: log: (pid 1802) 2647s


# 开始升级pg的版本
gitlab-ctl pg-upgrade

结果如下:
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.

这里日志比较多,大部分的内容省略掉。。。。


Running handlers:
Running handlers complete
Chef Client finished, 30/812 resources updated in 47 seconds
Running reconfigure: OK--- 这里有自动做reconfigure
Waiting for Database to be running.
Database upgrade is complete, running analyze_new_cluster.sh
Toggling deploy page:rm -f /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling services:ok: run: alertmanager: (pid 17631) 0s
ok: run: gitaly: (pid 17643) 1s
ok: run: gitlab-exporter: (pid 17654) 0s
ok: run: gitlab-pages: (pid 17667) 1s
ok: run: grafana: (pid 17686) 0s
ok: run: logrotate: (pid 17705) 1s
ok: run: node-exporter: (pid 17719) 0s
ok: run: postgres-exporter: (pid 17728) 0s
ok: run: prometheus: (pid 17741) 1s
ok: run: redis-exporter: (pid 17753) 0s
ok: run: registry: (pid 17601) 5s
ok: run: sidekiq: (pid 17766) 1s
Toggling services: OK
==== Upgrade has completed ====
Please verify everything is working and run the following if so
sudo rm -rf /var/opt/gitlab/postgresql/data.9.6
sudo rm -f /var/opt/gitlab/postgresql-version.old


# 查看下PG当前版本
cd /opt/gitlab/embedded/bin
./psql --version
psql (PostgreSQL) 11.7





gitlab版本升级

文章图片
gitlab版本升级

文章图片





3. 从12.10.6升级到12.10.14
这里小版本升级,没有啥大的改动。pg的版本升级我们在上面已做完了。
升级步骤:
?
# 停止当前gitlab的运行
gitlab-ctl stop


# 拉取最新仓库信息
# apt update


# 列出我们要安装的版本
apt-cache madison gitlab-ce | grep \'12.10.13\'

apt-get install gitlab-ce=12.10.14-ce.0


# 再次启动gitlab
gitlab-ctl start

gitlab-ctl status



4. 从12.10.14升级到13.0.14
13开始改动比较多,具体??changes log??


13.0的改动;
1、puma替代unicorn成为默认的web server
2、pg11成标配,并移除了对pg9和10的支持
3、alertmanager的配置ns移动到monitoring下


# 停止当前gitlab的运行
gitlab-ctl stop


# 拉取最新仓库信息
# apt update


# 列出我们要安装的版本
apt-cache madison gitlab-ce | grep \'13.0.14\'


apt-get install gitlab-ce=13.0.14-ce.0


# 再次启动gitlab
gitlab-ctl start

gitlab-ctl status





回滚步骤如果发现无法段时间解决的问题,可以考虑通过之前创建的机器镜像来启动一台新的gitlab实例。
1、从image启动一个备份的gitlab-new ecs实例,挂载磁盘,执行gitlab-ctl restart启动进程
2、将gitlab机器的SLB的后端节点改为gitlab-new
3、内部测试下CI/CD流程,没问题后就可以对外提供服务

    推荐阅读