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
-
從
9.0.0
->9.5.10
,使用docker
安裝,導入備份,完成。 -
修改
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