环境介绍:
CentOS 6.8 final
gitlab:8.6.5
需求:gitlab从8.6.5升级到8.11.7
升级之前Backup备份
# su - git $ cd /home/git/gitlab $ bundle exec rake gitlab:backup:create RAILS_ENV=production
备份的文件在/home/git/gitlab/tmp/backups目录下:
# service gitlab stop
$ su - git $ cd /home/git/gitlab $ git fetch --all
$ git checkout -- Gemfile.lock db/schema.rb $ git checkout v8.11.7 -b v8.11.7
如果报错,删除修改过的文件
$ vi VERSION
将8.6.5替换为8.11.7
$ cd /home/git/gitlab-shell $ git fetch
$ git checkout v`cat /home/git/gitlab/GITLAB_SHELL_VERSION` -b v`cat /home/git/gitlab/GITLAB_SHELL_VERSION`
$ cd /home/git/gitlab-workhorse $ git fetch
$ git checkout v`cat /home/git/gitlab/GITLAB_WORKHORSE_VERSION` -b v`cat /home/git/gitlab/GITLAB_WORKHORSE_VERSION`
$ make
$ cd /home/git/gitlab 修改Gem source $ gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
# PostgreSQL $bundle install --without development test mysql --deployment # MySQL $bundle install --without development test postgres --deployment
# Optional: clean up old gems $bundle clean # Run database migrations $bundle exec rake db:migrate RAILS_ENV=production
# Clean up assets and cache $bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
# service gitlab start # service nginx restart
检查GitLab及其环境是否配置正确:
$ bundle exec rake gitlab:env:info RAILS_ENV=production
确保没有报错,运行一次更彻底的检查:
$bundle exec rake gitlab:check RAILS_ENV=production
如果所有项目是绿色的,那么恭喜你升级完成!
gitlab从8.6.5升级到8.11.7到此结束。
$ mysqldump -uroot -pxxxx gitlabhq_production > /tmp/gitlabhq_production.sql
$ cp /home/git/.ssh/authorized_keys /tmp/authorized_keys
$ cd /home/git/gitlab $ bundle exec rake gitlab:backup:create RAILS_ENV=production
备份的文件在/home/git/gitlab/tmp/backups目录下
$cd /home/git $tar zxvf repositories.tar.gz
如果权限有异常,直接重新赋权
$ chown -R git.git /home/git/repositories/
$ mysql -uroot -pxxx gitlabhq_production < gitlabhq_production.sql
$ cat authorized_keys >> /home/git/.ssh/authorized_keys
$ cd /home/git/gitlab/ $ bundle exec rake gitlab:import:repos RAILS_ENV=production $ bundle exec rake gitlab:satellites:create RAILS_ENV=production
$ bundle exec rake gitlab:check RAILS_ENV=production
如果检测没有异常,可以重启gitlab服务
# /etc/init.d/gitlab restart
如果报错:
git.exe push –progress “origin” master:master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 350 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: GitLab: An unexpected error occurred (redis-cli returned 1).
remote: error: hook declined to update refs/heads/master
To http://192.168.3.124/caoyang/test1121.git
! [remote rejected] master -> master (hook declined)
error: failed to push some refs to ‘http://192.168.4.251/caoyang/test1121.git’
屏蔽 /home/git/gitlab-shell/config.yml 47行redis配置