我这里只讨论从4.2到5.0升级过程,并且用的是Nginx和启用HTTPS配置。
第一,升级时开始运行的帐号和目录
sudo -s 进入root权限下
然后要cd /home/gitlab/gitlab下运行升级的脚本。
第二,使用正确的版本的gitlab-shell
参考升级文档https://github.com/gitlabhq/gitlabhq/wiki/From-4.2-to-5.0
注意其中第二步,git clone gitlab-shell之后要立刻让gitlab-shell切换到v1.1.0 tag.
先查看一下有几个tag
root@ubuntu1204-dell:/home/git/gitlab-shell# git tag
v1.0.3
v1.1.0
v1.2.0
git log --oneline --decorate
e8d93d0 (HEAD, tag: v1.1.0, master) up to 1.1.0
然后用reset命令切到这个tag
git reset --hard e8d93d0
第三步,修改gitlab-shell中的配置文件
# Url to gitlab instance. Used for api calls
gitlab_url: "https://your_git_server/"
第四步,让gitlab-shell访问本地gitlab server的REST API时禁止启用SSL证书
参考这个帖子:https://github.com/gitlabhq/gitlabhq/issues/3292
so i had to add string not to check certificate at /home/git/gitlab-shell/lib/gitlab_net.rb
from:
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = (url.port == 443)
request = Net::HTTP::Get.new(url.request_uri)
http.start {|http| http.request(request) }
to:
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = (url.port == 443)
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl?
request = Net::HTTP::Get.new(url.request_uri)
http.start {|http| http.request(request) }
第五步,Nginx中的gitlab配置, 也许对大家有用,仅供参考:
File Edit Options Buffers Tools Help
# GITLAB
# Maintainer: @randx
# App Version: 4.0
upstream gitlab {
server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}
server {
listen *:443; # e.g., listen 192.168.1.1:80;
ssl on;
ssl_certificate /etc/nginx/sites-available/server.crt;
ssl_certificate_key /etc/nginx/sites-available/server.key;
server_name localhost;
#ubuntu1204-dell source.myserver.com; # e.g., server_name source.example.com;
root /home/git/gitlab/public;
# individual nginx logs for this gitlab vhost
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;
location / {
# serve static files from defined root folder;.
# @gitlab is a named location for the upstream fallback, see below
try_files $uri $uri/index.html $uri.html @gitlab;
}
# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://gitlab;
}
}
这样才能让
sudo -u git -H /home/git/gitlab-shell/bin/check
和
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
检查全部通过。
并且才能解决客户端git clone 不能访问的问题。