公司有臺Gitlab
服務器使用的是9.0.0
版本,現要將其遷移到新的服務器,爲了使用最新的功能,要將其升級。html
爲了便於維護,咱們使用docker
安裝,使用docker
安裝gitlab
很是容易,官網上只要一行命令.nginx
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
的方式安裝,文件以下git
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
從老的服務器上備份,拷貝到新的機器上恢復數據docker
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
安裝,導入備份,完成。shell
修改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
bash
sudo docker-compose exec gitlab gitlab-rake gitlab:backup:create
按此流程下來,能夠一路刷到最新版。服務器
接下來還有域名和端口的問題,由於咱們是內網環境,服務器沒有獨立的外網IP,須要使用網關作HTTP代理,如何解決將在後面再講。ssh
後面再講如何使用gitlab
完成CI/CD
gitlab
從12
升級到13
版本的時候要先升級到 13.0.x
版本,那就再加一個版本吧。ui
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