centos 7.2 部署并升级gitlab

事由:

    老git服务器centos 7.2上的git版本是8.13.5,先特在一台测试机centos 7.2上安装git 8.13.5 后,还原git后,在对测试服务器上git进行升级操作。

测试服务器git升级没有问题后,在对正式git进行升级。

gitlab服务器上查看各个版本的最后版本:https://packages.gitlab.com/gitlab/gitlab-ce

升级版本步骤 8.13.5-》8.17.8(8中最大的版本)-》9.5.9(9中最大的版本)-》10.8.7(10中最大版本)暂时不升级11版本。

1、测试服务器安装git

安装gitlab-ce-8.13.5-ce.0.el7.x86_64
#curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh |bash
#yum install gitlab-ce-8.13.5-ce.0.el7.x86_64

 

也可以是国内的镜像地址

[root@t101 yum.repos.d]# more gitlab_gitlab-ce.repo 
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key

  

2、备份老的git

备份数据
#/opt/gitlab/bin/gitlab-rake gitlab:backup:create
执行后在/var/opt/gitlab/backups目录创建一个名称类似为1502357536_2019_01_10__gitlab_backup.tar的压缩包
备份配置文件
#/etc/gitlab/gitlab.rb 配置文件须备份
#/var/opt/gitlab/nginx/conf nginx配置文件

3、还原git数据和配置文件

将测试服务器gitlab和nginx配置文件备份1、将备份文件权限修改为777第一步,将备份文件权限修改为777,不然可能恢复的时候会出现权限不够,不能解压的问题

chmod 777 1502357536_2017_08_10_9.4.3_gitlab_backup.tar 
2、执行命令停止相关数据连接服务
第二步,执行命令停止相关数据连接服务
# 停止相关数据连接服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
3、执行命令从备份文件中恢复Gitlab
第三步,执行命令从备份文件中恢复Gitlab
gitlab-rake gitlab:backup:restore BACKUP=备份文件编号
例如我们的备份文件的编号是1502357536_2017_08_10_9.4.3,因此执行下面的命令即可恢复gitlab
gitlab-rake gitlab:backup:restore BACKUP=1502357536_2017_08_10_9.4.3
出现交互页面,输入yes回车。
4、恢复完成后,启动gitlab
gitlab-ctl reconfigure
gitlab-ctl start

还原时报错

[root@t101 ~]# gitlab-rake gitlab:backup:restore BACKUP=1548270207
no backups found
The specified backup doesn't exist!

解决方式

先执行一下备份操作后,在执行还原

[root@t101 ~]# gitlab-rake gitlab:backup:create

在 /var/opt/gitlab/backups中生成文件,同时将copy过来的文件到该目录下。

4、 升级到gitlab-ce-8.17.8-ce.0.el7.x86_64

#curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash
#yum update gitlab-ce-8.17.8-ce.0.el7.x86_64

gitlab-ctl reconfigure  中有项目目录报错同时页面502错误,需要执行下面的chmod
chmod 2770 /home/data/git/git-data/repositories

gitlab-ctl reconfigure
gitlab-ctl pg-upgrade
gitlab-ctl start 登录页面查看版本是否正确

  

5、升级到gitlab-ce-9.5.9-ce.0.el7.x86_64  

 

#curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash
#yum update gitlab-ce-9.5.9-ce.0.el7.x86_64
#gitlab-ctl reconfiugre
#gitlab-ctl start
登录页面查看版本是否正确

6、升级到gitlab-ce-10.8.7-ce.0.el7.x86_64

#curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash
#yum update gitlab-ce-10.8.7-ce.0.el7.x86_64
#gitlab-ctl reconfiugre
#gitlab-ctl start
登录页面查看版本是否正确

  

 

原文地址:https://www.cnblogs.com/xzlive/p/10304348.html