gitlab完整遷移
環境介紹:
CentOS 6.7
gitlab:6.3.1
需求:gitlab從A伺服器遷移至B伺服器
第一、在B伺服器上部署gitlab環境
參考《GitLab完整搭建(版本6.3.1)》
第二、備份A伺服器上的資料
1).打包倉庫檔案
#su- git $cd/home/git/ $tarzcvf repositories.tar.gz ./repositories
2).備份sql檔案
$mysqldump-uroot -pxxxx gitlabhq_production > /tmp/gitlabhq_production.sql
3).備份keys
$cp/home/git/.ssh/authorized_keys /tmp/authorized_keys
4).複製1-3步的檔案到B伺服器
$scprepositories.tar.gz gitlabhq_production.sql authorized_keys [email protected]:/tmp/
第三、在B伺服器上匯入資料
1). 匯入倉庫,檢查許可權
$cd/home/git $tarzxvf repositories.tar.gz
如果許可權有異常,直接重新賦權
$chown-R git.git /home/git/repositories/
2).匯入資料庫
$mysql-uroot -pxxx gitlabhq_production < gitlabhq_production.sql
3).
$catauthorized_keys >> /home/git/.ssh/authorized_keys
4.將檔案匯入ruby
$cd/home/git/gitlab/ $bundleexec rake gitlab:import:repos RAILS_ENV=production $bundleexec rake gitlab:satellites:create RAILS_ENV=production
5).檢測
$bundleexec rake gitlab:check RAILS_ENV=production
如果檢測沒有異常,可以重啟gitlab服務
#/etc/init.d/gitlab restart
第四、驗證git pull/push與異常解決
1). git pull
2). git push
如果報錯:
git.exe push --progress "origin"master:master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 350 bytes | 0bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: GitLab: An unexpected erroroccurred (redis-cli returned 1).
remote: error: hook declined to updaterefs/heads/master
To http://192.168.4.251/caoyang/test1121.git
! [remote rejected] master -> master(hook declined)
error: failed to push some refs to'http://192.168.4.251/caoyang/test1121.git'
遮蔽 /home/git/gitlab-shell/config.yml 28行redis配置