Method of GitLab upgrade across major versions under CentOS7
- 2021-06-28 14:47:43
- OfStack
backups
&
upgrade
Be sure to make a backup before upgrading and record your current version number of gitlab-ca.
View the current gitlab version number
[root@localhost ~]# yum list | grep gitlab-ce
gitlab-ce.x86_64 9.3.6-ce.0.el7 installed
Backup Files
[root@localhost ~]# gitlab-rake gitlab:backup:create
Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
done
Dumping repositories ...
* dev/dubbo ... [DONE]
* dev/dubbo.wiki ... [SKIPPED]
* dev/dubbox-master ... [DONE]
* dev/dubbox-master.wiki ... [SKIPPED]
* MobileTerminal/MobileDoc ... [SKIPPED]
* MobileTerminal/MobileDoc.wiki ... [SKIPPED]
* TrakCare/Doc ... [SKIPPED]
* TrakCare/Doc.wiki ... [SKIPPED]
* PerationMaintenance/PMDoc ... [DONE]
* PerationMaintenance/PMDoc.wiki ... [DONE]
* doc/his ... [DONE]
* doc/his.wiki ... [SKIPPED]
* PerationMaintenance/image ... [SKIPPED]
* PerationMaintenance/image.wiki ... [SKIPPED]
done
Dumping uploads ...
done
Dumping builds ...
done
Dumping artifacts ...
done
Dumping pages ...
done
Dumping lfs objects ...
done
Dumping container registry images ...
[DISABLED]
Creating backup archive: 1552552057_2019_03_14_9.3.6_gitlab_backup.tar ... done
Uploading backup archive to remote storage ... skipped
Deleting tmp directories ... done
done
done
done
done
done
done
done
Deleting old backups ... skipping
A backup file is generated under directory/var/opt/gitlab/backups/e.g. 1552552057_gitlab_backup.tar, of which 1552552057 is the version number for this backup.
Restore Backup (Failed)
gitlab-rake gitlab:backup:restore BACKUP= Backup version number
Configure gitlab-yum source
[root@localhost ~]# cat << EOF > /etc/yum.repos.d/gitlab-ce.repo
> [gitlab-ce]
> name=gitlab-ce
> baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
> repo_gpgcheck=0
> gpgcheck=0
> enable=1
> gpgkey=https://packages.gitlab.com/gpg.key
> EOF
yum install Installation
[root@localhost ~]# yum install gitlab-ce-9.5.9
Plugins loaded: fastestmirror, langpacks
gitlab-ce | 2.9 kB 00:00:00
gitlab-ce/primary_db | 2.7 MB 00:00:01
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving dependencies
--> Checking transactions
---> software package gitlab-ce.x86_64.0.9.3.6-ce.0.el7 Will be upgrade
---> software package gitlab-ce.x86_64.0.9.5.9-ce.0.el7 Will be To update
--> Resolve Dependency Complete
Dependency Resolution
===============================================================================================================================================================================================================================================================
Package Framework Edition source Size
===============================================================================================================================================================================================================================================================
Updating :
gitlab-ce x86_64 9.5.9-ce.0.el7 gitlab-ce 381 M
Transaction Summary
===============================================================================================================================================================================================================================================================
upgrade 1 software package
Total downloads: 381 M
Is this ok [y/d/N]: Y
Downloading packages:
No Presto metadata available for gitlab-ce
gitlab-ce-9.5.9-ce.0.el7.x86_6 FAILED 18% [==================- ] 659 B/s | 70 MB 137:35:05 ETA
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm: [Errno 12] Timeout on https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying another mirror.
gitlab-ce-9.5.9-ce.0.el7.x86_6 FAILED 21% [====================== ] 646 B/s | 83 MB 134:19:56 ETA
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm: [Errno 12] Timeout on https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying another mirror.
gitlab-ce-9.5.9-ce.0.el7.x86_6 FAILED 81% [===================================================================================- ] 411 B/s | 311 MB 50:00:08 ETA
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm: [Errno 12] Timeout on https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying another mirror.
gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm | 381 MB 00:01:52
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
gitlab preinstall: Automatically backing up only the GitLab SQL database (excluding everything else!)
Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
done
Dumping repositories ...
[SKIPPED]
Dumping uploads ...
[SKIPPED]
Dumping builds ...
[SKIPPED]
Dumping artifacts ...
[SKIPPED]
Dumping pages ...
[SKIPPED]
Dumping lfs objects ...
[SKIPPED]
Dumping container registry images ...
[DISABLED]
Creating backup archive: 1552553362_2019_03_14_9.3.6_gitlab_backup.tar ... done
Uploading backup archive to remote storage ... skipped
Deleting tmp directories ... done
done
Deleting old backups ... skipping
Updating : gitlab-ce-9.5.9-ce.0.el7.x86_64 [############################################################################################################################ ] 1/2 Updating : gitlab-ce-9.5.9-ce.0.el7.x86_64 [############################################################################################################################## Updating : gitlab-ce-9.5.9-ce.0.el7.x86_64 1/2
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
gitlab: Thank you for installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:
sudo gitlab-ctl reconfigure
gitlab: GitLab should be reachable at http://192.168.x.x:8090/gitlab
gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
gitlab: And running reconfigure again.
gitlab:
gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
gitlab:
Clear : gitlab-ce-9.3.6-ce.0.el7.x86_64 2/2
Checking PostgreSQL executables: OK
Shutting down all GitLab services except those needed for migrations
ok: down: gitaly: 1s, normally up
ok: down: gitlab-monitor: 0s, normally up
ok: down: gitlab-workhorse: 1s, normally up
ok: down: logrotate: 0s, normally up
ok: down: nginx: 1s, normally up
ok: down: node-exporter: 0s, normally up
ok: down: postgres-exporter: 0s, normally up
ok: down: postgresql: 0s, normally up
ok: down: prometheus: 0s, normally up
ok: down: redis: 1s, normally up
ok: down: redis-exporter: 0s, normally up
ok: down: sidekiq: 0s, normally up
ok: down: unicorn: 0s, normally up
ok: run: postgresql: (pid 3362) 1s
ok: run: redis: (pid 3370) 0s
run: postgresql: (pid 3362) 1s; run: log: (pid 866) 3488369s
run: redis: (pid 3370) 0s; run: log: (pid 897) 3488369s
Reconfiguring GitLab to apply migrations
* Moving existing certificates found in /opt/gitlab/embedded/ssl/certs
* Symlinking existing certificates found in /etc/gitlab/trusted-certs
gitlab Reconfigured!
Checking for an omnibus managed postgresql: OK
Checking if we already upgraded: OK
The latest version 9.6.3 is already running, nothing to do
Ensuring PostgreSQL is updated: OK
Restarting previously running GitLab services
ok: run: gitaly: (pid 4046) 2s
ok: run: gitlab-monitor: (pid 4086) 1s
ok: run: gitlab-workhorse: (pid 4068) 2s
ok: run: logrotate: (pid 4120) 1s
ok: run: nginx: (pid 4126) 0s
ok: run: node-exporter: (pid 4177) 0s
ok: run: postgres-exporter: (pid 4184) 1s
ok: run: postgresql: (pid 3362) 72s
ok: run: prometheus: (pid 4094) 3s
ok: run: redis: (pid 3370) 71s
ok: run: redis-exporter: (pid 4194) 0s
ok: run: sidekiq: (pid 4203) 1s
ok: run: unicorn: (pid 4216) 0s
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).
In Verification : gitlab-ce-9.5.9-ce.0.el7.x86_64 1/2
In Verification : gitlab-ce-9.3.6-ce.0.el7.x86_64 2/2
Update complete :
gitlab-ce.x86_64 0:9.5.9-ce.0.el7
Complete!
Upgrade Gitlab (Note: Since upgrades cannot span large version numbers, they can only be upgraded to the current large version number to the maximum version before being upgraded to the next large version number)
[root@localhost ~]# cd /var/opt/gitlab/backups/
[root@localhost backups]# ll
Total dosage 6532
-rw-------. 1 git git 6625280 3 month 14 16:27 1552552057_2019_03_14_9.3.6_gitlab_backup.tar
-rw-------. 1 git git 61440 3 month 14 16:49 1552553362_2019_03_14_9.3.6_gitlab_backup.tar
16:27 Generated tar The package was generated by me executing the backup command manually
16:49 Generated tar Package is yum Update version automatic backup
Follow the instructions below to upgrade step by step. After each successful installation, if the interface 500 is found to be inaccessible, then execute the gitlab-ctl reconfigure instructions to refresh the configuration file. (1 Make sure the data is accessible properly before you can execute the next step of the upgrade instructions)
yum install gitlab-ce-8.17.8-ce.0.el7
yum install gitlab-ce-9.5.9-ce.0.el7
yum install gitlab-ce-10.0.0-ce.0.el7
yum install gitlab-ce-10.8.0-ce.0.el7
yum install gitlab-ce-11.3.0-ce.0.el7
View the current version number
[root@localhost backups]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
9.5.9
FAQ
[ERROR] OpenSSL::Cipher::CipherError (bad decrypt):
gitlab-rails runner "Project.where.not(import_url: nil).each { |p| p.import_data.destroy if p.import_data }"
[ERROR] Error executing action `run` on resource 'ruby_block[directory resource: /var/opt/gitlab/git-data/repositories]'
chmod -R 2770 /var/opt/gitlab/git-data