确定升级路径:
从 10.8.5 升级到 14.1.3 路径:
10.8.5 → 10.8.7 → 11.11.8 → 12.0.3 → 12.1.6 → 12.10.14 → 13.0.14 → 13.1.11 → 13.9.2 → 13.12.9 → 14.0.7 → 14.1.3
# 确定目前版本,规划版本过渡路径。
rpm -q gitlab-ce
# 关闭服务:
gitlab-ctl stop unicorn ( 13 版本以前的操作 )
gitlab-ctl stop puma ( 13 版本后操作 )
gitlab-ctl stop sidekiq
gitlab-ctl stop nginx
# 配置yum源:
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
## 这里的 yum 源是 el7 的,如果机器装的是 el6 需要将 /etc/yum.repos.d/gitlab_gitlab-ce.repo 中 7 改为 6.( :%s/7/6/g )
# 升级到9.5.4:
yum install gitlab-ce-9.5.4-ce.0.el6.x86_64
## 升级指定版本,可以根据官方安装过渡路径,修改相应版本号,即可。(官方版本过渡路径:https://docs.gitlab.com/ee/update/)
# 重启gitlab:
gitlab-ctl restart
#重载配置文件:
gitlab-ctl reconfigure
12 版变动官方文档https://docs.gitlab.com/omnibus/update/gitlab_12_changes.html
13 版变动官方文档:https://docs.gitlab.com/omnibus/update/gitlab_13_changes.html
官方转换存储类型参考文档:https://docs.gitlab.com/ee/administration/raketasks/storage.html#migrate-to-hashed-storage
切换到 puma 官方参考文档:https://docs.gitlab.com/ee/administration/operations/puma.html#configure-puma
14 版变动官方文档:https://docs.gitlab.com/omnibus/update/gitlab_14_changes.html
存储库迁移第一种官方论坛解决方案网址:https://gitlab.com/-/snippets/2039252
存储库迁移第二种官方论坛解决方法网址:https://gitlab.com/gitlab-org/gitlab/-/issues/289816
* git_data_dir has been deprecated since 8.10 and removed in 11.0. Use git_data_dirs instead. Deprecations found. Please correct them and try again.
原因:升级到10.8.7时,新版的gitlab配置文件中指定的git_data_dir写法有变更。
需要将文件中的 git_data_dirs "/data/gitlab/git-data" 改为:
git_data_dirs({
"default" => {
"path" => "/data/gitlab/git-data"
}
})
保存后重载配置文件
gitlab-ctl reconfigure
继续升级
'rack_attack_protected_paths'
。gitlab_rails['rack_attack_protected_paths'] = ['/unsubscribes/',]
,重新安装就可以正常进行。12.10.14 → 13.0.14,升级后,如果 web 访问出现 500 错误时,可能是 unicorn 占用端口,puma 无法启动。
- 首先注意,12 版的 unicorn 组件被 13 版的 puma 取代。
- netstat -anltp | grep 8080
查看 8080 端口目前哪个组件再用。
- 如果是 unicorn ,ps -aux | grep unicorn
获取 pid 后,将其 kill 掉。
- gitlab-ctl restart puma
,重启组件后,查看 8080 是否为 puma 在用,是的话,此问题解决。
13 版本 unicorn 被puma 取代,14 版本将删除 unicorn 组件,所以13 版本 /etc/gitlab/gitlab.rb
配置文件中的,有关遗留 unicorn 配置需修改为 puma 的配置。如果未修改做,13 升级 14 的话,可能出现报错如下:
* unicorn['worker_timeout'] has been deprecated since 13.10 and was removed in 14.0. Starting with GitLab 14.0, Unicorn is no longer supported and users must switch to Puma, following https://docs.gitlab.com/ee/administration/operations/puma.html.
* unicorn['worker_processes'] has been deprecated since 13.10 and was removed in 14.0. Starting with GitLab 14.0, Unicorn is no longer supported and users must switch to Puma, following https://docs.gitlab.com/ee/administration/operations/puma.html.
Deprecations found. Please correct them and try again.
error: %pre(gitlab-ce-14.0.7-ce.0.el7.x86_64) scriptlet failed, exit status 1
Error in PREIN scriptlet in rpm package gitlab-ce-14.0.7-ce.0.el7.x86_64
Verifying : gitlab-ce-14.0.7-ce.0.el7.x86_64 1/2
gitlab-ce-13.12.9-ce.0.el7.x86_64 was supposed to be removed but is not!
Verifying : gitlab-ce-13.12.9-ce.0.el7.x86_64
## 基于以上问题的解决方法(修改 `etc/gitlab/gitlab.rb `配置文件中的,有关遗留 unicorn 配置需修改为 puma 的配置。)
# 修改配置文件
vim /etc/gitlab/gitlab.rb
修改 unicorn 配置为 puma 配置
# unicorn['worker_timeout'] = 60
# unicorn['worker_processes'] = 3
puma['worker_timeout'] = 60
puma['worker_processes'] = 3
# 重启 ,重新配置
13 版 默认启用了 hash 存储,软件内部会自动做数据迁移,从传统存储转至 hash 存储,迁移进度查看在 web 页面,” 设置 → 监控 → 后台任务 ",查看。
14 版将不对旧存储提供支持,所以升级 14 版本前,请先做数据迁移。
第一种处理方式:
# 编写执行文件
vim /tmp/fix-legacy-hashed-storage-migration.rb
# Find all projects that GitLab thinks is in legacy storage
Project.without_storage_feature(:repository).find_each(batch_size: 10) do |p|
# Generate the hashed path
hash_path = Storage::Hashed.new(p).disk_path
storage = Gitlab.config.repositories.storages[p.repository.shard]
# Enable access
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
# Put a wildcard on the end so we find .git, .wiki.git and .design.git
full_hashed_path = File.expand_path(File.join(storage.legacy_disk_path, hash_path + '*'))
# If any repos already exist in hashed storage, complete the migration
if(!Dir.glob(full_hashed_path).empty?)
puts "Fixing ID:#{p.id} #{p.full_name} - #{full_hashed_path}"
# Set the repo to read only if it isn't already
if(!p.repository_read_only)
p.set_repository_read_only!
end
# Copy over git files from legacy path to hashed path
if(!Dir.glob(File.expand_path(File.join(storage.legacy_disk_path, p.disk_path + '.git'))).empty?)
system("cp -rf #{File.expand_path(File.join(storage.legacy_disk_path, p.disk_path + '.git', '*'))} #{File.expand_path(File.join(storage.legacy_disk_path, hash_path + '.git'))}")
end
p.storage_version = ::Project::HASHED_STORAGE_FEATURES[:repository]
p.reload_repository!
p.write_repository_config
p.track_project_repository
p.repository_read_only = false
p.save!(validate: false)
end
end
end
# 执行
gitlab-rails runner /tmp/fix-legacy-hashed-storage-migration.rb
# 手动数据迁移
gitlab-rake gitlab:storage:migrate_to_hashed
# 查看,全部迁移成功以下两条命令应该为 0
gitlab-rake gitlab:storage:legacy_projects
gitlab-rake gitlab:storage:legacy_attachments
# 全部迁移成功,以下两条命令应该没有输出
gitlab-rake gitlab:storage:list_legacy_projects
gitlab-rake gitlab:storage:list_legacy_attachments
第二种处理方式:
# 进入 Rails 控制台
gitlab-rails console
# 查询 项目 read-only 打开的
projects = Project.where(repository_read_only: true)
# 关闭 项目的 read-only
projects.each do |p|
p.update!(repository_read_only:nil)
end
# 存储库迁移
gitlab-rake gitlab:storage:migrate_to_hashed
# 全部迁移成功,以下命令查看所列出的项目总数与页面的理应一致
gitlab-rake gitlab:storage:hashed_projects
# 查看,全部迁移成功以下两条命令应该为 0
gitlab-rake gitlab:storage:legacy_projects
gitlab-rake gitlab:storage:legacy_attachments
# 全部迁移成功,以下两条命令应该没有输出
gitlab-rake gitlab:storage:list_legacy_projects
gitlab-rake gitlab:storage:list_legacy_attachments
# 报错:
Running transaction
gitlab preinstall: Checking for unmigrated data on legacy storage
gitlab preinstall:
gitlab preinstall: Legacy storage is no longer supported. Please migrate your data to hashed storage.
gitlab preinstall: Check https://docs.gitlab.com/ee/administration/raketasks/storage.html#migrate-to-hashed-storage for details.
gitlab preinstall:
gitlab preinstall: If you want to skip this check, run the following command and try again:
gitlab preinstall:
gitlab preinstall: sudo touch /etc/gitlab/skip-unmigrated-data-check
gitlab preinstall:
error: %pre(gitlab-ce-14.0.7-ce.0.el7.x86_64) scriptlet failed, exit status 1
Error in PREIN scriptlet in rpm package gitlab-ce-14.0.7-ce.0.el7.x86_64
Verifying : gitlab-ce-14.0.7-ce.0.el7.x86_64 1/2
gitlab-ce-13.12.9-ce.0.el7.x86_64 was supposed to be removed but is not!
Verifying : gitlab-ce-13.12.9-ce.0.el7.x86_64
##基于上面出现问题解决方法:
# 查看使用传统存储的项目
gitlab-rake gitlab:storage:list_legacy_projects
gitlab-rake gitlab:storage:list_legacy_attachments
# 进行数据迁移
sudo gitlab-rake gitlab:storage:migrate_to_hashed
# 确保存储库都迁移到 hash 再升级。
# 重启,重配。