备份当前的Gitlab
gitlab-rake gitlab:backup:create 注:升级的时候也会自动备份
gitlab的升级不能跨越大版本号,因此只能升级到当前大版本号到最高版本,方可升级到下一个大版本号。
由于我现在的版本号是9.2.2,我要升级到现在最新版本的11.10.4,需要做的升级步骤如下:
9.2.2—>9.5.9—>10.8.x—>11.11.x -> 12.0.x -> 12.10.x -> 13.0.x
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.5.9-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.10.4-ce.0.el7.x86_64.rpm
.....
停止 GitLab 的 Web 服务
gitlab-ctl stop unicorn
Sidekiq 是 GitLab 用于处理后台任务的组件,包括邮件发送、CI/CD 构建、系统通知等任务
gitlab-ctl stop sidekiq
nginx 这是如果是迁出来就不用停了
gitlab-ctl stop nginx
依次执行下面指令逐步升级,在每一步安装成功后如果发现界面500,这是因为redis等程序还没完全启动,等一会儿访问就ok了。(一定保证数据可以正常访问方可执行下一步升级指令) 关闭gitlab最好
yum localinstall -y gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm
yum localinstall -y gitlab-ce-10.8.7-ce.0.el7.x86_64.rpm
yum localinstall -y gitlab-ce-11.10.4-ce.0.el7.x86_64.rpm
......
完成之后再查看下当前的版本:
[root@gitlab ~]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
升级过程中只要按照升级对应的版本即可,一般不会出现错误
gitlab-ctl reconfigure
gitlab-ctl restart postgresql
gitlab-ctl reconfigure 是一个 GitLab 的命令,用于重新配置 GitLab 的各个组件和服务,包括 Nginx、PostgreSQL、Redis、GitLab Shell 等。该命令会根据 /etc/gitlab/gitlab.rb 文件中的配置重新生成 GitLab 配置文件,并自动加载/etc/gitlab/gitlab-secrets.json 文件中的敏感数据。如果你对 GitLab 的配置文件进行了修改,或者添加了新的组件或服务,需要运行 gitlab-ctl reconfigure 命令来应用这些修改。