gitlab遷移小記

gitlab遷移小記

@[gitlab|gitlab遷移]html

最近公司內部的測試環境進行資源整合,須要把一些服務進行遷移,此次遷移gitlab的時候,遇到了一個小坑,在這裏記錄下:mysql

gitlab 從 A 服務器遷移至 B 服務器linux

1、在B服務器上部署gitlab環境

可參考 centos6安裝部署git服務器(gitlab6.4)

2、打包A服務器上的數據

cd /home/git/
tar zcvf /tmp/repositories.tar.gz ./repositories   #打包倉庫文件
mysqldump -uroot -pxxxx gitlabhq_production > /tmp/gitlabhq_production.sql  #備份sql文件
cp /home/git/.ssh/authorized_keys  /tmp/authorized_keys #備份keys

cd /tmp
scp repositories.tar.gz  gitlabhq_production.sql  authorized_keys root@B:/tmp/ #複製到B服務器的/tmp目錄下

在B服務器上導入數據

cd /tmp/
tar zxvf repositories.tar.gz
/bin/cp -r repositories /home/git/  #導入倉庫
chown -R git.git /home/git/repositories/ #受權
cat authorized_keys >> /home/git/.ssh/authorized_keys #導入keys
mysql -uroot -pxxx gitlabhq_production < gitlabhq_production.sql #導入數據庫

cd /home/git/gitlab/
sudo -u git -H bundle exec rake gitlab:import:repos RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production
sudo chmod -R ug+rwX,o-rwx /home/git/repositories/
sudo chmod -R ug-s /home/git/repositories/
find /home/git/repositories/ -type d -print0 | sudo xargs -0 chmod g+s

#檢測
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

檢測沒有問題的話就能夠重啓下gitlab,而後打開看看數據什麼的都有了。nginx

遇到的坑

遷移以後,就該進行測試了,,測試了ssh協議的沒有問題,可是測試http協議的時候,卻出現了以下問題git

[root@git aaaa]# git clone http://git.linuxyan.com/username/git-test.git
Cloning into 'git-test'...
Username for 'http://git.linuxyan.com': username
Password for 'http://username@git.linuxyan.com': 
fatal: protocol error: bad line length character: 285
fatal: The remote end hung up unexpectedly

原本覺得是gitlab的問題,可是gitlab的日誌裏面都顯示正常。在這裏糾結了很久。
後來去查看nginx的日誌,錯誤日誌裏面也沒有東西,可是訪問日誌裏面有以下日誌,兩個401狀態github

"GET /username/git-test.git/info/refs?service=git-upload-pack HTTP/1.1" 401 0 "-" "git/1.8.4.1"
"GET /username/git-test.git/info/refs?service=git-upload-pack HTTP/1.1" 401 0 "-" "git/1.8.4.1"
"GET /username/git-test.git/info/refs?service=git-upload-pack HTTP/1.1" 200 282 "-" "git/1.8.4.1"
"POST /username/git-test.git/git-upload-pack HTTP/1.1" 200 669 "-" "git/1.8.4.1"

後來在https://github.com/gitlabhq/gitlabhq/issues/5774這裏看到說有多是nginx的版本過低形成的,因而去nginx的官網下載了最新穩定版1.6.1版本的nginx,安裝以後,重啓nginx和gitlab問題解決。web

相關文章
相關標籤/搜索