“ 生命中,再无聊的时光,也都是限量版的。”
最近老版本Gitlab支持不起需求,干脆跨三大版本升级到最新,心惊胆战,最后还是自己抗住所有的压力。
01
—
准备工作
提前模拟好一模一样的环境,最终还是没逃过零风险,但能把风险和时间降到最低。
#查看当前版本
>cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
10.0.3
#查看系统、内核
>cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
>uname -a
Linux 192-168-20-1 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
复制
注意:“/”目录是要比当前使用率大一倍(如已使用50G,“/”最少要100G),备份以及安装rpm会占用空间
#下载好rpm包(因为不能跨大版本升级,只能升级到当前小版本到最大才能升级到大版本)
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-10.8.4-ce.0.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-11.11.4-ce.0.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-12.0.9-ce.0.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-12.10.11-ce.0.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-13.0.6-ce.0.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-13.7.3-ce.0.el7.x86_64.rpm/download.rpm
#备份、备份、备份(数据大备份比较久,耐心等待)
gitlab-rake gitlab:backup:create
#关闭部分gitlab服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl stop nginx
#升级
rpm -Uvh gitlab-ce-10.8.4-ce.0.el7.x86_64.rpm
#重新配置gitlab
gitlab-ctl reconfigure
#重启gitlab
gitlab-ctl restart
#浏览器访问gitlab是否正常
复制
注意:重复关闭部分gitlab服务、升级、重新配置gitlab、浏览器访问
02
—
升级遇到的问题
1.执行gitlab-ctl reconfigure报
STDERR: libsemanage.semanage_pipe_data: Child process /usr/libexec/selinux/hll/pp failed with code: 255. (No such file or directory).
解决方法:
yum install libsemanage-devel
复制
2.升级完,刚开始访问页面404然后执行重新初始化访问502(最主要是nginx配置问题,重新初始化gitlab太多次,最终是以下方法解决)
#查看日志
gitlab-ctl tail
复制
官网:
Note that on a single-core server it may take up to a minute to restart Unicorn and Sidekiq. Your GitLab instance will give a 502 error until Unicorn is up again.
It is also possible to start, stop or restart individual components.
sudo gitlab-ctl restart sidekiq
Unicorn supports zero-downtime reloads. These can be triggered as follows:
sudo gitlab-ctl hup unicorn
Note that you cannot use a Unicorn reload to update the Ruby runtime.
解决方法:
gitlab-ctl restart sidekiq
gitlab-ctl hup unicorn
复制