GitLab 7.9 升级到 8.0.1

1.gitlab8.0更新说明

GitLab 8.0 现在完全集成了持续集成工具 (GitLab CI) ,此外还完全重写了 UI,节省了至少 50% 的磁盘空间。更快的合并,内置持续集成(CI)到 GitLab 本身,提高了界面和导航,以及“通过电子邮件回复”功能,它可以使用户通过移动设备就能够对某个问题上迅速发表评论,或者合并请求。

GitLab 8.0 主要改进:

更好的 HTTP 支持

邮件快速回复

Gmail 快速打开

改善文件上传功能

改进 Mattermost

Web hooks 的 SSL 认证

更多更新请查看gitlab官网https://github.com/gitlabhq/gitlabhq/blob/master/CHANGELOG

2.gitlab7.9环境

2.1 gitlab7.9安装说明

系统为CentOS6.7,gitlab7.9为源码安装,默认位置为/home/git/gitlab,我安装位置:/usr/local/git/gitlab,因此请注意你的gitlab安装位置是否使用默认,相应更改下面的配置

2.2 升级准备

由于gitlab使用git用户管理,因此我们应当以git身份执行相关配置,升级前请检查gitlab运行正常

sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

2.3 备份gitlab

升级有风险,因此先做好备份

sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production

如果gitlab运行在虚拟机中,最好给虚拟机做快照,以便更新失败时恢复

2.4 停止gitlab

升级前先停止gitlab运行

service gitlab stop

service gitlab stop

2.5检查gitlab相关组件版本

#gitlab8.0组件版本要求
Redis version >= 2.4.0
Ruby version >= 2.1.0
Git version >= 1.7.10
GitLab Shell version >= 2.6.5

组件版本要求如下,如果版本过低请升级,升级参考2.6,2.7步骤

2.6 升级git版本

#检查git版本
git --version
#升级git
cd /opt/
curl -L --progress https://www.kernel.org/pub/software/scm/git/git-2.4.3.tar.gz | tar xz
./configure
make prefix=/usr/local all -j 4
make prefix=/usr/local install

2.7 升级ruby版本

#下载
wget ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.6.tar.gz
#安装
tar xvf ruby-2.1.6.tar.gz
cd ruby-2.1.6
./configure --disable-install-rdoc
make -j 4
make install
#配置
gem install bundler --no-ri --no-rdoc
#如果/usr/bin/下存在ruby链接,先删除
ln -s /usr/local/bin/ruby /usr/bin/ruby
ln -s /usr/local/bin/gem /usr/bin/gem
ln -s /usr/local/bin/bundle /usr/bin/bundle

3.升级gitlab到8.0.1

3.1 使用git命令升级gitlab到8.0.1

#进入gitlab安装目录
cd /usr/local/git/gitlab
sudo -u git -H git fetch --all
sudo -u git -H git checkout -- Gemfile.lock db/schema.rb
#获取最新版本,保存在LATEST_TAG变量中
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
#commit是为了提交更改,不然无法cheout到最新版本
sudo -u git git commit -a
sudo -u git -H git checkout $LATEST_TAG -b $LATEST_TAG
#验证当前版本
sudo -u git git branch -l
#注意:checkout到gitlab8.0.1之后,/usr/local/git/gitlab下的文件为8.0.1版本,但是config/gitlab.yml,config/database.yml等配置文件仍位旧版本7.9的配置文件,后面会更新这些文件

3.2升级gitlab-shell

#进入gitlab-shell主目录
cd /usr/local/git/gitlab-shell/
sudo -u git -H git fetch
#注意下面路径/usr/local/git/gitlab为gitlab安装目录,如果你的位于/home/git/gitlab请更改下面命令
sudo -u git -H git checkout v`cat /usr/local/git/gitlab/GITLAB_SHELL_VERSION` -b v`cat /usr/local/git/gitlab/GITLAB_SHELL_VERSION`
#验证gitlab版本
sudo -u git git branch -l

3.3安装gitlab-git-http-server

3.3.1下载go 1.5版本

#下载go 1.5版本
cd /opt
curl -O --progress https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.5.linux-amd64.tar.gz
ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/
ln -s /usr/local/bin/go /usr/bin/

3.3.2安装gitlab-git-http-server

cd /usr/local/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-git-http-server.git
cd gitlab-git-http-server/
sudo -u git -H make

3.4安装ruby依赖包

#由于ruby官网链接过慢,因此更改ruby源
cd /usr/local/git/gitlab
#修改Gemfile文件
source "https://rubygems.org/" 改为 source "http://ruby.taobao.org/"
#修改Gemfile.lock文件
remote: https://rubygems.org/ 改为 remote:
#执行安装(使用mysql,如果你使用postgress,请更改下面postgress为mysql)
yum install cmake
sudo -u git -H bundle install --without postgres development test aws --deployment

3.5迁移数据库

安装依赖

yum install nodejs

建立表结构,如果不导入表结构,迁移数据库时会提示找不到表ci_builds

cat gitlab_builds.sql

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/15333.html