自编译安装的补丁版本通用更新指南
选择要安装的版本
确保你查看的是要安装的极狐 GitLab 版本的此更新指南。在大多数情况下,这应该是最高编号的生产标签(不包含 rc
)。你可以在极狐 GitLab 左上角的版本下拉列表中选择标签。
0. 备份
以防万一,先备份。根据安装方法,备份命令会有所不同。请参阅备份和恢复极狐GitLab文档。
1. 停止服务器
# 对于运行 systemd 的系统
sudo systemctl stop gitlab.target
# 对于运行 SysV init 的系统
sudo service gitlab stop
2. 获取稳定分支的最新代码
在下面的命令中,用最新的极狐GitLab 标签替换 LATEST_TAG
,例如 v8.0.3
。使用 git tag -l 'v*.[0-9]' --sort='v:refname'
查看所有标签列表。确保只更新补丁版本(使用 cat VERSION
检查你的当前版本)。
cd /home/git/gitlab
sudo -u git -H git fetch --all
sudo -u git -H git checkout -- Gemfile.lock db/structure.sql locale
sudo -u git -H git checkout LATEST_TAG -b LATEST_TAG
3. 安装库、迁移等
cd /home/git/gitlab
# 如果你在安装或之前的升级过程中还没有这样做
sudo -u git -H bundle config set --local deployment 'true'
sudo -u git -H bundle config set --local without 'development test kerberos'
# 更新 gems
sudo -u git -H bundle install
# 可选:清理旧的 gems
sudo -u git -H bundle clean
# 运行数据库迁移
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
# 清理资产和缓存
sudo -u git -H bundle exec rake yarn:install gitlab:assets:clean gitlab:assets:compile cache:clear RAILS_ENV=production NODE_ENV=production NODE_OPTIONS="--max_old_space_size=4096"
4. 更新极狐GitLab Workhorse 到相应版本
cd /home/git/gitlab
sudo -u git -H bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workhorse]" RAILS_ENV=production
5. 更新 Gitaly 到相应版本
cd /home/git/gitlab
sudo -u git -H bundle exec rake "gitlab:gitaly:install[/home/git/gitaly,/home/git/repositories]" RAILS_ENV=production
6. 更新极狐GitLab Shell 到相应版本
cd /home/git/gitlab-shell
sudo -u git -H git fetch --all --tags
sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_SHELL_VERSION) -b v$(</home/git/gitlab/GITLAB_SHELL_VERSION)
sudo -u git -H make build
7. 更新极狐GitLab Pages 到相应版本(如果不使用 pages 则跳过)
cd /home/git/gitlab-pages
sudo -u git -H git fetch --all --tags
sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_PAGES_VERSION)
sudo -u git -H make
8. 安装/更新 gitlab-elasticsearch-indexer
按照安装说明进行操作。
9. 启动应用程序
# 对于运行 systemd 的系统
sudo systemctl start gitlab.target
sudo systemctl restart nginx.service
# 对于运行 SysV init 的系统
sudo service gitlab start
sudo service nginx restart
10. 检查应用程序状态
检查极狐 GitLab 及其环境是否配置正确:
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
为了确保没有遗漏任何内容,进行更彻底的检查:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
如果所有项目都是绿色的,那么恭喜,升级完成!
11. 确保后台迁移已完成
检查后台迁移的状态,确保它们已完成。