Gitlab 升级1.7.2 to 8.4.5,解决http方式git 远程相关操作失败问题
去年给公司搭建的 gitlab 版本是 1.7.2 的,众所周知 gitlab 也是一个版本帝,不到一年时间都更新到 8.4.5 了,强迫症不能忍我还是升级了一下,我的 gitlab 是基于源码安装的,升级也很简单,过程算是顺利吧。
1.备份一下
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
2.停止 gitlab 服务
sudo service gitlab stop
3.执行更新脚本
cd /home/git/gitlab
sudo -u git -H ruby -Ilib -e 'require "gitlab/upgrader"' -e 'class Gitlab::Upgrader' -e 'def latest_version_raw' -e '"v8.4.5"' -e 'end' -e 'end' -e 'Gitlab::Upgrader.new.execute'
4.重启服务
sudo service gitlab start
sudo service nginx restart
5.检查 gitlab 状态
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
6.更新 gitlab shell
cd /home/git/gitlab-shell
sudo -u git -H git fetch
sudo -u git -H git checkout v`cat /home/git/gitlab/GITLAB_SHELL_VERSION`
一般这样就结束了,但是哪有这么顺利呢,如果过程中遇到 ruby 版本过低或者 bundler 过低的情况,记得要升级一下 ruby 和 bundler 之后再重新上面的步骤
一切正常后发现通过 http 的方式没有办法 pull 和 push 远程代码了,报错:
fatal: Couldn’t find remote ref master
通过 http git clone 代码的时候报错:
warning: You appear to have cloned an empty repository.
其实这是由于 8.0 版本以后 http 请求通过 gitlab-workhorse(gitlab-git-http-server)来处理了,所以继续需要一下步骤来处理一下就 OK 了。
1.安装 Go
curl -O --progress https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz
echo '43afe0c5017e502630b1aea4d44b8a7f059bf60d7f29dfd58db454d4e4e0ae53 go1.5.3.linux-amd64.tar.gz' | shasum -c - && \
sudo tar -C /usr/local -xzf go1.5.3.linux-amd64.tar.gz
sudo ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/
rm go1.5.3.linux-amd64.tar.gz
2.安装 gitlab-workhorse
cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git
cd gitlab-workhorse
sudo -u git -H git checkout 0.6.5
sudo -u git -H make
3.重新安装 init 脚本
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
4.重启一下 gitlab
sudo /etc/init.d/gitlab restart
5.重新配置 nginx
sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
6.重新配置 nginx 文件,然后重启 nginx
sudo nginx -t
sudo service nginx restart
好了,这样 git 的远程 pull 或者 push 就 OK 了,通过 http 的方式 clone 代码也没有问题了。
转载请注明: 转载自Ryan 是菜鸟 | LNMP 技术栈笔记
如果觉得本篇文章对您十分有益,何不 打赏一下
本文链接地址: Gitlab 升级 1.7.2 to 8.4.5,解决 http 方式 git 远程相关操作失败问题
本作品采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可