2018-07-09--記錄一次gitlab遷移事件及遇到的問題


一、事情起因

    因機房服務器即將到期,需要將即將到期的服務器遷移至雲上,遷移之前沒有查看老環境的Gitlab是什么版本,直接裝的Gitlab社區版,做數據導入時提示版本錯誤:

[root@vpn-server-001 devops]# gitlab-rake gitlab:backup:restore RAILS_ENV=production BACKUP=1531072861
Unpacking backup ... done
GitLab version mismatch:
  Your current GitLab version (11.0.2) differs from the GitLab version in the backup!
  Please switch to the following version and try again:
  version: 8.9.5


Hint: git checkout v8.9.5 

    此時去查看老環境的gitlab版本:

[root@git-server yum.repos.d]# gitlab-rake gitlab:env:info

System information
System:		
Current User:	git
Using RVM:	no
Ruby Version:	2.1.8p440
Gem Version:	2.5.1
Bundler Version:1.10.6
Rake Version:	10.5.0
Sidekiq Version:4.1.2

GitLab information
Version:	8.9.5                  #發現是8.9.5的
Revision:	f6ab19d
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	postgresql
URL:		http://gitlab.zlkjbj.cn
HTTP Clone URL:	http://gitlab.zlkjbj.cn/some-group/some-project.git
SSH Clone URL:	git@gitlab.zlkjbj.cn:some-group/some-project.git
Using LDAP:	no
Using Omniauth:	no

GitLab Shell
Version:	3.0.0
Repositories:	/data/git-data/repositories
Hooks:		/opt/gitlab/embedded/service/gitlab-shell/hooks/
Git:		/opt/gitlab/embedded/bin/git

查看新環境的Gitlab版本:

[root@server-001 ~]# gitlab-rake gitlab:env:info

System information
System:		
Current User:	git
Using RVM:	no
Ruby Version:	2.4.4p296
Gem Version:	2.7.6
Bundler Version:1.16.2
Rake Version:	12.3.1
Redis Version:	3.2.11
Git Version:	2.17.1
Sidekiq Version:5.1.3
Go Version:	unknown

GitLab information
Version:	11.0.2             #新環境的版本為11.0.2
Revision:	d9540ee
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	postgresql
URL:		http://114.115.181.98
HTTP Clone URL:	http://114.115.181.98/some-group/some-project.git
SSH Clone URL:	ssh://git@114.115.181.98:52113/some-group/some-project.git
Using LDAP:	no
Using Omniauth:	no

GitLab Shell
Version:	7.1.4
Repository storage paths:
- default: 	/var/opt/gitlab/git-data/repositories
Hooks:		/opt/gitlab/embedded/service/gitlab-shell/hooks
Git:		/opt/gitlab/embedded/bin/git

知道問題后,下面是將新環境的Gitlab替換為8.9.5的版本:

yum remove -y gitlab-ce               #卸載新環境的Gitlab
yum install -y gitlab-ce-8.9.5         #指定安裝8.9.5的版本的gitlab

然后做導入操作(需要將備份文件放到指定的目錄下):

# gitlab-rake gitlab:backup:restore BACKUP=1531072861       #1531072861為你需要恢復備份的時間戳,文件名為:1531072861_gitlab_backup.tar 這種形式

然后登陸Gitlab界面查看數據即可!!!

二、問題解決

遷移后訪問首頁沒問題,但是訪問項目時會報500的錯誤,是gitlab數據遷移時的一個缺陷。日志如下:

Started GET "/davidb/workflow-test2" for 127.0.0.1 at 2016-05-25 11:18:10 -0500
Processing by ProjectsController#show as HTML
  Parameters: {"namespace_id"=>"davidb", "id"=>"workflow-test2"}
Completed 500 Internal Server Error in 242ms (ActiveRecord: 7.4ms)

OpenSSL::Cipher::CipherError (bad decrypt):
  app/models/project.rb:379:in `import_url'
  app/models/project.rb:409:in `external_import?'
  app/models/project.rb:401:in `import?'
  app/models/project.rb:417:in `import_in_progress?'
  app/controllers/projects_controller.rb:93:in `show'
  lib/gitlab/middleware/go.rb:16:in `call'

         解決辦法:

 

1、覆蓋原來gitlab的 db_key_base 到新的gitlab 

db_key_base  位置在 /etc/gitlab/gitlab-secrets.json  

 

2、EE版本執行命令
sudo gitlab-rails runner "Project.where(mirror: false).where.not(import_url: nil).each { |p| p.import_data.destroy if p.import_data }"

CE版本執行命令
sudo gitlab-rails runner "Project.where.not(import_url: nil).each { |p| p.import_data.destroy if p.import_data }"

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM