Gitlab 升級方案


Gitlab 升級方案

公司有台Gitlab服務器使用的是9.0.0版本,現要將其遷移到新的服務器,為了使用最新的功能,要將其升級。

為了便於維護,我們使用docker安裝,使用docker安裝gitlab非常容易,官網上只要一行命令.

sudo docker run --detach \
  --hostname gitlab.example.com \
  --publish 443:443 --publish 80:80 --publish 22:22 \
  --name gitlab \
  --restart always \
  --volume $GITLAB_HOME/config:/etc/gitlab \
  --volume $GITLAB_HOME/logs:/var/log/gitlab \
  --volume $GITLAB_HOME/data:/var/opt/gitlab \
  gitlab/gitlab-ee:latest

我們使用docker-compose的方式安裝,文件如下

version: "3"

services:
  gitlab:
    image: gitlab/gitlab-ce:9.0.0-ce.0
    # image: gitlab/gitlab-ce:9.5.10-ce.0
    # image: gitlab/gitlab-ce:10.8.7-ce.0
    # image: gitlab/gitlab-ce:11.11.8-ce.0
    # image: gitlab/gitlab-ce:12.10.14-ce.0
    # image: gitlab/gitlab-ce:13.0.0-ce.0
    # image: gitlab/gitlab-ce:13.3.5-ce.0
    restart: always
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        nginx['listen_port'] = '80'
        nginx['listen_https'] = false
        registry_nginx['listen_port'] = '80'
        registry_nginx['listen_https'] = false
        gitlab_rails['lfs_enabled'] = true
        gitlab_rails['registry_enabled'] = true
        gitlab_rails['gitlab_shell_ssh_port'] = 2222
    ports:
      - 80:80
      - 2222:2222
    volumes:
      - /opt/gitlab/config:/etc/gitlab
      - /opt/gitlab/logs:/var/log/gitlab
      - /opt/gitlab/data:/var/opt/gitlab
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro

從老的服務器上備份,拷貝到新的機器上恢復數據

sudo cp ~/backups/1596417964_2020_08_03_gitlab_backup.tar /opt/gitlab/data/backups/
sudo docker-compose exec gitlab gitlab-rake gitlab:backup:restore
  1. 9.0.0 -> 9.5.10,使用docker安裝,導入備份,完成。

  2. 修改docker-compose.yml中的gitlab image版本,docker-compose up -d啟動,每升級一個版本號做一次備份,升級路線9.0.0-ce.0->9.5.10-ce.0->10.8.7-ce.0->11.11.8-ce.0->12.10.14-ce.0->13.3.5-ce.0

sudo docker-compose exec gitlab gitlab-rake gitlab:backup:create

按此流程下來,可以一路刷到最新版。

域名,端口的問題

接下來還有域名和端口的問題,因為我們是內網環境,服務器沒有獨立的外網IP,需要使用網關做HTTP代理,如何解決將在后面再講。

CI/CD

后面再講如何使用gitlab完成CI/CD


翻車了!!!!

12升級到13版本的時候要先升級到 13.0.x版本,那就再加一個版本吧。

It seems you are upgrading from major version 12 to major version 13.
It is required to upgrade to the latest 13.0.x version first before proceeding.
Please follow the upgrade documentation at https://docs.gitlab.com/ee/policy/maintenance.html#upgrading-major-versions


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM