gitlab升级

公司gitlab项目的升级

公司gitlab使用源码方式安装,版本为7.2,因为最近结合ldap来进行使用,但是ldap中的block_auto_created_users选项到7.10才支持。所以要升级。
参考官方帮助文档:
http://doc.gitlab.com/ce/update/patch_versions.html
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/7.9-to-7.10.md

从7.2升级到7.9版本

依赖包和软件升级

因为版本的升级跨度大,这版本直接肯定有很多新的功能需要扩展包进行支持,所以根据目前最新版(7.12)的源码安装教程重新安装依赖包,并且升级redis服务(测试时出现问题,所以提前升级)。
安装依赖包:

sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config cmake nodejs libkrb5-dev

升级redis:

wget http://download.redis.io/releases/redis-3.0.3.tar.gz
tar xvf redis-3.0.3.tar.gz
cd redis-3.0.3/
make 
make  install
#会在/usr/local/bin/下边生成相应的bin文件
cp redis.conf /etc/redis/
#修改redis.conf文件,对应/etc/init.d/redis-server中进行修改
daemonize yes  #使redis可以后台运行
pidfile /var/run/redis/redis-server.pid
bind 127.0.0.1
logfile /var/log/redis/redis-server.log
dir /var/lib/redis

:升级后,因为redis的bin文件更换了地方,要修改/home/git/gitlab-shell/config.yml为:bin: "/usr/local/bin/redis-cli"

备份并停止服务
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
/etc/init.d/gitlab stop
下载最新的稳定版的代码
sudo -u git -H git fetch --all
sudo -u git -H git checkout v7.9.3

LATEST_TAG为想要升级到的版本号,国内的网络fetch的时候可能会有问题,需要连接vpn。

更新最新的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`
Install libs, migrations, etc.

断开VPN连接,并且修改ruby源来提高速度和成功率

注意:下边的bundle install命令使用的默认源是https://rubygems.org/,国内很慢,可以更换成淘宝的源,更改方法为:
vim /home/git/gitlab/Gemfile 修改 其中的source "https://rubygems.org"source "https://ruby.taobao.org"

cd /home/git/gitlab

#PostgreSQL
sudo -u git -H bundle install --without development test mysql --deployment

# MySQL
sudo -u git -H bundle install --without development test postgres --deployment

sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
sudo -u git -H bundle exec rake assets:clean RAILS_ENV=production
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production
开启服务
sudo service gitlab start
sudo service nginx restart
检测升级是否成功
  • 检测环境
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
  • 检测项目
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

从7.9升级到7.13版本

备份
sudo service gitlab stop
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
更新gitlab
sudo -u git -H git fetch --all
sudo -u git -H git checkout -- db/schema.rb # local changes will be restored automatically
sudo -u git -H git checkout 7-13-stable
更新gitlab-shell
cd /home/git/gitlab-shell
sudo -u git -H git fetch
sudo -u git -H git checkout v2.6.3

Install libs, migrations, etc

注:更换/home/git/gitlab/Gemfile中的ruby源

cd /home/git/gitlab

# MySQL installations (note: the line below states '--without ... postgres')
sudo -u git -H bundle install --without development test postgres --deployment

# PostgreSQL installations (note: the line below states '--without ... mysql')
sudo -u git -H bundle install --without development test mysql --deployment

# Run database migrations
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production

# Clean up assets and cache
sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production

# Update init.d script
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
更新配置文件

因为配置文件中ldap的语法是不同的,所以将老gitlab.yml备份,用gitlab.yml.example替换他,并更改其中必要的配置。 ldap部分的配置如下:

ldap:
    enabled: true
    servers:
      ##########################################################################
      #
      # Since GitLab 7.4, LDAP servers get ID's (below the ID is 'main'). GitLab
      # Enterprise Edition now supports connecting to multiple LDAP servers.
      #
      # If you are updating from the old (pre-7.4) syntax, you MUST give your
      # old server the ID 'main'.
      #
      ##########################################################################
      main: # 'main' is the GitLab 'provider ID' of this LDAP server
        label: 'LDAP'
        host: 'ldap-url/IP'
        port: 389
        uid: 'uid'
        method: 'plain' # "tls" or "ssl" or "plain"
        bind_dn: 'cn=xx,dc=xxx,dc=xx'
        password: 'admin-passwd'
        active_directory: true
        block_auto_created_users: true
        base: 'dc=xxx,dc=xx'
        user_filter: ''
启动服务
sudo service gitlab start
sudo service nginx restart
检查状态
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
修复

根据上边检查的结果进行修复

sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值