@[gitlab|gitlab迁移]html
最近公司内部的测试环境进行资源整合,须要把一些服务进行迁移,此次迁移gitlab的时候,遇到了一个小坑,在这里记录下:mysql
gitlab 从 A 服务器迁移至 B 服务器linux
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目录下
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