gitlab迁移小记
时间:2017-03-05 17:48 来源:linux.it.net.cn 作者:IT
最近公司内部的测试环境进行资源整合,需要把一些服务进行迁移,这次迁移gitlab的时候,遇到了一个小坑,在这里记录下:
gitlab 从 A 服务器迁移至 B 服务器
一、在B服务器上部署gitlab环境
可参考 centos6安装部署git服务器(gitlab6.4)
二、打包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,然后打开看看数据什么的都有了。
遇到的坑
迁移之后,就该进行测试了,,测试了ssh协议的没有问题,但是测试http协议的时候,却出现了如下问题
[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状态
"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问题解决。
(责任编辑:IT)
最近公司内部的测试环境进行资源整合,需要把一些服务进行迁移,这次迁移gitlab的时候,遇到了一个小坑,在这里记录下:
一、在B服务器上部署gitlab环境可参考 centos6安装部署git服务器(gitlab6.4)二、打包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,然后打开看看数据什么的都有了。 遇到的坑迁移之后,就该进行测试了,,测试了ssh协议的没有问题,但是测试http协议的时候,却出现了如下问题 [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的日志里面都显示正常。在这里纠结了好久。 "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问题解决。 (责任编辑:IT) |