描述:由于项目需要把gitlab升级到最新版本
目前版本:8.16.5
目标版本:12.7.5
升级路径
GitLab不支持直接跨版本升级,需按照官方指南一步步向上升级
这样我们的升级路径就是:8.16.5->8.17.7->9.5.10->10.8.7->11.3.4->11.11.8->12.0.9->12.7.5
备份数据
gitlab-rake gitlab:backup:create
备份后会在/var/opt/gitlab/backups下会生成一个备份文件如:1582049386_2020_02_19_gitlab_backup.tar
准备工作
根据官方文档自行选择:https://about.gitlab.com/install/#centos-6
sudo yum install -y curl policycoreutils-python openssh-server cronie
sudo lokkit -s http -s ssh
sudo yum install postfix
sudo service postfix start
sudo chkconfig postfix on
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
升级
#先安装原来版本以恢复数据
yum install -y gitlab-ce-8.16.5
gitlab-ctl reconfigure
#复制灰度数据包到 /var/opt/gitlab/backups
mv /root/1582049386_2020_02_19_gitlab_backup.tar /var/opt/gitlab/backups
chmod +r /var/opt/gitlab/backups/*
gitlab-rake gitlab:backup:restore BACKUP=1582049386_2020_02_19
#后面一直按yes....
#升级后查看状态
gitlab-ctl status
#状态ok继续升级
yum update -y gitlab-ce-8.17.7
yum update -y gitlab-ce-9.5.10
yum update -y gitlab-ce-10.8.7
yum update -y gitlab-ce-11.3.4
yum update -y gitlab-ce-11.11.8
yum update -y gitlab-ce-12.0.9
yum update -y gitlab-ce-12.7.5
#顺利的话,大体流程如此。后面会补充一个错误处理过程
错误处理
错误1:版本8.16.5恢复过程中出现 NoMethodError: private method `puts’ called for nil:NilClass
解决办法: 编辑vim /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake文件注析方法上下两行的puts
错误2:版本 9.5.10->10.8.7启动失败页面500错误
解决方法: gitlab-ctl reconfigure
错误3:版本 9.5.10->10.8.7时有两个模块无法启动日志报错
解决方法:
vim /opt/gitlab/sv/postgres-exporter/run # 把后面参数改成如下图的双横线
vim /opt/gitlab/sv/node-exporter/run # 把后面参数改成如下图的双横线
上述是本人遇到的问题,其他人可能不一样。需要自行百度和google