gitlab 跨版本升级至docker

2019-05-10  本文已影响0人  于殿国
Policewomen_ZH-CN9260416327_1920x1080.jpg
背景:由于公司原有gitlab为gitlab-ce-8.13.0-ce.0的版本,因为版本比较老,无法部署ci/cd持续化集成。所以打算把公司的gilab升级一下。由于公司的服务器系统也比较老了是centos6的版本打算同时把系统升级为centos7
说明:有问题大家可以加微信(yudianguo)或者发邮箱(yu_dianguo@163.com)共同交流
过程:
1、备份原有gitlab数据
# 备份数据
gitlab-rake gitlab:backup:create
# 由于升级系统,下载数据到本地(如果下载速度比较慢建议上传到阿里云图床)
scp root@<您的ip>:/var/opt/gitlab/backups/1555903057_gitlab_backup.tar ./

2、 更换镜像源(如果系统没有更新镜像源)

3、安装一个和线上同版本的gitlab

# 下载安装包
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.13.0-ce.0.el7.x86_64.rpm
# 配置gitlab并启动
sudo gitlab-ctl reconfigure
# 重新启动
sudo gitlab-ctl restart

4、恢复备份文件

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
# 复制备份文件到  /var/opt/gitlab/backups
mv 1555554634_gitlab_backup.tar /var/opt/gitlab/backups
# 更改所属文件  git:git
chown git:git 1555926452_2019_04_22_11.3.4_gitlab_backup.tar 
gitlab-rake gitlab:backup:restore BACKUP="1555926452_2019_04_22_11.3.4"

5、由于gitlab不支持直接升级到最高版本,要逐步升级

# 官方规定升级路线([https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations](https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations))

6、逐步升级

# 下载对应升级路径的镜像(由于升级过程中按照官方路径提示版本不一致,下面是我调整后的)
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.13.5-ce.0.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.17.7-ce.0.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.5.10-ce.0.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.8.7-ce.0.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.3.4-ce.0.el7.x86_64.rpm

# 以下部分循环执行 一步步升级
### 开始 ###
rpm -Uvh gitlab-ce-8.13.5-ce.0.el7.x86_64.rpm (对应版本)
gitlab-ctl reconfigure
gitlab-ctl restart
### 结束 ### 

# 安装包 这个执行 有一个版本需要安装该扩展
yum install -y curl policycoreutils-python openssh-server openssh-clients

7、执行到最后一步后备份阿里云

8、docker-composer 配置 这个是配置的nginx转发,由于gitlab使用ssh端口,所以把服务器登录的端口可以改掉,注意下恢复版本到docker的时候 一开始要把image的版本 和你备份的版本号一致恢复。恢复完成后在该你的版本。

    gitlab:
      image: 'gitlab/gitlab-ce:latest'
      container_name: gitlab
      restart: always
      hostname: 'gitlab.xxx.com'
      environment:
        GITLAB_OMNIBUS_CONFIG: |
          external_url 'http://gitlab.xxx.com'
      ports:
        - '83:80'
        - '444:443'
        - '22:22'
      volumes:
        - /etc/localtime:/etc/localtime
        - './gitlab/config:/etc/gitlab'
        - './gitlab/logs:/var/log/gitlab'
        - './gitlab/data:/var/opt/gitlab'
      extra_hosts:
         - "gitlab.xxx.com:127.0.0.1"
      networks:
          - backend
上一篇 下一篇

猜你喜欢

热点阅读