11 January 2019

Update Gitlab on CentOS

Updating CentOS and gitlab is normally as simple as:


  • yum check-update
  • yum update
The problem was that we postponed the updates too long and created a version lag for gitlab.

The installed gitlab-ce version was 10.6 and we had to update to version 11.6.3.
We got the message we had to do an intermediate update to 10.8 prior to updating to 11.6.3.


gitlab preinstall: It seems you are upgrading from 10.x version series
gitlab preinstall: to 11.x series. It is recommended to upgrade
gitlab preinstall: to the last minor version in a major version series first before
gitlab preinstall: jumping to the next major version.
gitlab preinstall: Please follow the upgrade documentation at 
https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations
gitlab preinstall: and upgrade to 10.8 first.
Failed:
  gitlab-ce.x86_64 0:10.6.2-ce.0.el7     gitlab-ce.x86_64 0:11.4.5-ce.0.el7
The following steps succesfully upgaded gitlab-ce from version 10.6.2 to 11.6.3  

  1. Determine CentOS version
    cat /etc/redhat-release
    CentOS Linux release 7.5.1804 (Core)
  2. Install all CentOS updates:
    yum check-update
    yum update
    All packages are updated automatically except gitlab, so we had to manually update gitlab
  3. Some good reads:
    1. https://docs.gitlab.com/omnibus/update/README.html
    2. https://blog.securityevaluators.com/upgrading-gitlab-ce-from-a-6-9-2-source-installation-to-10-1-0-omnibus-a-novel-cf8c4f78bf99
      I was more lucky than this guy, because we were only 1 version behind ;-)
  4. To check your gitlab installation for issues, run:
    gitlab-rake gitlab:check SANITIZE=true
  5. From version 10.0 GitLab requires the version of PostgreSQL to be 9.6 or higher, so check PostgreSQL version:
    /opt/gitlab/embedded/bin/psql --version
  6. Before updating gitlab, it is a good idea to backup it using
    gitlab-ctl start (needed in case gitlab is not already running)
    sudo gitlab-rake gitlab:backup:create   (you can add the option STRATEGY=copy)
  7. Backup configuration files
    The secrets file is essential to preserve your database encryption key.
    cd ~
    mkdir gitBackupConfig
    cd gitBackupConfig
    cp  /etc/gitlab/gitlab-secrets.json .
    cp  /etc/gitlab/gitlab.rb .
  8. Check the currently installed gitlab version:
    Login to the admin page of your gitlab server
    http://gitlab.mycompany.org/admin  (adapt the URL to your needs)
    Dashboard > Groups: 3 > Components > update asap
    Below that title you can see the current gitlab version (in my case 10.6.2)
  9. The official update instructions :
    https://about.gitlab.com/update/#centos-7
  10. Determine the version you need
    https://unixy.net/secure/knowledgebase/104/What-does-el5-el6-and-el7-mean.html
    We need el7 as we use centos release 7 (EL7 is the download for Red Hat 7.x, CentOS 7.x, and CloudLinux 7.x.)
  11. Search and  Download gitlab 10.8.0
    1. Search the correct package at
      https://packages.gitlab.com/gitlab/gitlab-ce
      I need
      https://packages.gitlab.com/app/gitlab/gitlab-ce/search?q=gitlab-ce-10.8...
      Click on the link gitlab-ce-10.8.0-ce.0.el7.x86_64.rpm and follow the instruction
    2. Download the correct version
      curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
  12. Install this version (10.8):
    sudo yum install gitlab-ce-10.8.0-ce.0.el7.x86_64
    Updated:
      gitlab-ce.x86_64 0:10.8.0-ce.0.el7
    Complete!
  13. So now we are at version 10.8 and can update to 11.6.3 the easy way:
    yum update
    Updated:
      gitlab-ce.x86_64 0:11.6.3-ce.0.el7
    Complete!
  14. Take a look at the gitlab admin page:
    http://gitlab.mycompany.org/admin
    Press F5 to refresh the webpage
    OK no updates are available and we are on GitLab 11.6.3
  15. To be sure everything works fine now :
    gitlab-ctl restart
    shutdown -Fr now
  16. And try to login again
    http://gitlab.mycompany.org
In order to prevent this update problem in the future: 

  • Do on a monthly basis:
    yum check-update
    yum update
This way gitlab and CentOS will be kept up to date