记一次绿色版bitnami gitlab-7.13.1升级至最新版本gitlab-ce-11.4.6-ce.0.el7.x86_64

公司2016年安装了绿色版的bitnami gitlab-7.13.1 ,三年来一直没有更新 ,这两天着手将gitlab-7.13.1更新至最新的版本gitlab-ce-11.4.6-ce.0.el7.x86_64

现状:
1、系统环境是centos6.x-i386 ,尴尬了
2、gitlab版本太旧,而且不好维护,特别是绿色版忧伤
3、gitlab 很多新功能无法使用

新环境:(目标)
1、系统环境 CentOS Linux release 7.3.1611 X86_64
2、gitlab将更新至最新的 gitlab-ce-11.4.6-ce.0.el7.x86_64

由于更换新系统以及gitlab更新跨度比较大,采取逐级更新的方法(避免出错,毕竟开发的心血都存在这里了,对吧)
先将 bitnami gitlab-7.13.1备份好 ,迁移备份数据到新系统同版本gitlab-ce-7.13.1进行恢复
然后在新系统逐级升级,这里用的都是rpm包安装的gitlab-ce

升级版本详情:
老系统绿色版bitnami_gitlab-7.13.1 -> 新系统 gitlab-ce-7.13.1-ce.0.el7.x86_64
新系统升级顺序:(你也可以验证下跨多几个版本试试,我没有测试,怕出错)
gitlab-ce-7.13.1-ce.0.el7.x86_64.rpm
gitlab-ce-7.14.0-ce.0.el7.x86_64.rpm
gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm
gitlab-ce-8.17.8-ce.0.el7.x86_64.rpm
gitlab-ce-9.0.0-ce.0.el7.x86_64.rpm
gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm
gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
gitlab-ce-10.8.7-ce.0.el7.x86_64.rpm
gitlab-ce-11.0.0-ce.0.el7.x86_64.rpm
gitlab-ce-11.4.6-ce.0.el7.x86_64.rpm

gitlab-ce官网包都在这里:https://packages.gitlab.com/gitlab/gitlab-ce/
如果访问下载比较慢的话,也可以到国内的镜像下载:https://mirrors.zju.edu.cn/gitlab-ce/yum/el7/

一、旧系统gitlab-7.13备份

## 老的gitlab目录结构 大家看看(gitlab目录为/data/gitlab-7.13.1-0/)

## 老的gitlab备份

cd /data/gitlab-7.13.1-0/
./use_gitlab
cd apps/gitlab/htdocs
bundle exec bin/rake gitlab:backup:create RAILS_ENV=production

#可能要比较久,备份完成之后,备份文件存在了 /data/gitlab-7.13.1-0/apps/gitlab/htdocs/tmp/backups/1542860325_gitlab_backup.tar

二、centos7系统准备(最小安装)

## 系统基础软件包安装

yum -y install gcc gcc-c++ autoconf net-snmp net-snmp-libs lrzsz libtool libtool-ltdl libtool-ltdl-devel make unzip sharutils rsync telnet nc wget vim ntpdate openssl openssl-devel sysstat

## 安装policycoreutils-python (gitlab-ce-10以上版本有依赖)

yum -y install policycoreutils-python

## 关闭Selinux/firewalld

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

三、新系统gitlab-ce-7.13.1-ce.0.el7.x86_64.rpm安装

## 直接rpm安装即可

rpm -i gitlab-ce-7.13.1-ce.0.el7.x86_64.rpm

#主要都安装在 /opt/gitlab/ 目录

## 配置,根据新安装的日志提示直接执行一下命令完成初始(简单的很)
## 初始化之前,需要修改/etc/gitlab/gitlab.rb文件的external_url参数值,默认为主机名称,你可以在/etc/hosts加条映射
## 这里直接修改为了我的服务器ip地址 external_url ‘http://192.168.3.111’

gitlab-ctl reconfigure

## 查看下状态

[root@gitlab-centos7 tools]# gitlab-ctl status
run: logrotate: (pid 11732) 235s; run: log: (pid 11731) 235s
run: nginx: (pid 11620) 240s; run: log: (pid 11619) 240s
run: postgresql: (pid 11111) 641s; run: log: (pid 11110) 641s
run: redis: (pid 10989) 677s; run: log: (pid 10988) 677s
run: sidekiq: (pid 11559) 247s; run: log: (pid 11558) 247s
run: unicorn: (pid 11508) 248s; run: log: (pid 11507) 248s

## 可以登录你的web查看了
浏览器直接访问 external_url 的 http://192.168.3.111 即可
登录GitLab的默认用户名密码如下:
Username: root
Password: 5iveL!fe

四、旧的备份数据恢复至新服

## 初始化完成之后,数据目录 /var/opt/gitlab/
同步 1542860325_gitlab_backup.tar 至新服务器的 /var/opt/gitlab/backups/

## 执行备份恢复命令

gitlab-rake gitlab:backup:restore BACKUP=1542860325
###恢复日志如下
Unpacking backup ... done
Restoring database ...
Decompressing database ... [DONE]
Restoring PostgreSQL database gitlabhq_production ... SET
psql:/var/opt/gitlab/backups/db/database.sql:6: ERROR: unrecognized configuration parameter "lock_timeout"
SET
SET
...
* xxxxxxx ... [DONE]
* xxxxx ... [DONE]
Put GitLab hooks in repositories dirs [DONE]
done
Restoring uploads ...
done
This will rebuild an authorized_keys file.
You will lose any data stored in authorized_keys file.
Do you want to continue (yes/no)? yes

....................................................................
Deleting tmp directories ... done
done
done
done

## 完成,重启一下:

gitlab-ctl restart

## 用你之前的管理员账号登录上去,检查数据正确性 数据都有了,好感动

五、通过rpm逐级更新至最新版本

rpm -Uvh gitlab-ce-7.14.0-ce.0.el7.x86_64.rpm

更新完 gitlab-ctl restart一下即可,检查数据
然后就一步一步的更新至最新版本,每更新一个版本都要 gitlab-ctl restart 一下,检查数据。如果打开502 千万不要慌,等多一会,服务器启动有延时

rpm -Uvh gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm
rpm -Uvh gitlab-ce-8.17.8-ce.0.el7.x86_64.rpm
rpm -Uvh gitlab-ce-9.0.0-ce.0.el7.x86_64.rpm
rpm -Uvh gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm
rpm -Uvh gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
rpm -Uvh gitlab-ce-10.8.7-ce.0.el7.x86_64.rpm
rpm -Uvh gitlab-ce-11.0.0-ce.0.el7.x86_64.rpm
rpm -Uvh gitlab-ce-11.4.6-ce.0.el7.x86_64.rpm

放一下最后一张图给大家看下

[root@gitlab-centos7 backups]# gitlab-ctl status
run: alertmanager: (pid 5737) 9635s; run: log: (pid 2054) 78960s
run: gitaly: (pid 5748) 9635s; run: log: (pid 2030) 78960s
run: gitlab-monitor: (pid 5758) 9635s; run: log: (pid 2051) 78960s
run: gitlab-workhorse: (pid 5761) 9634s; run: log: (pid 2017) 78960s
run: logrotate: (pid 19481) 2434s; run: log: (pid 2016) 78960s
run: nginx: (pid 5778) 9633s; run: log: (pid 2023) 78960s
run: node-exporter: (pid 5796) 9633s; run: log: (pid 2039) 78960s
run: postgres-exporter: (pid 5803) 9632s; run: log: (pid 2077) 78959s
run: postgresql: (pid 5813) 9632s; run: log: (pid 2019) 78960s
down: prometheus: 9621s, normally up; run: log: (pid 2020) 78960s
run: redis: (pid 5834) 9631s; run: log: (pid 2029) 78960s
run: redis-exporter: (pid 5838) 9631s; run: log: (pid 2037) 78960s
run: sidekiq: (pid 5845) 9630s; run: log: (pid 2028) 78960s
run: unicorn: (pid 5857) 9628s; run: log: (pid 2018) 78960s

上面是gitlab-ce-11.4.6-ce启动的服务

## 我这里单独把prometheus给停了的,因为发现这个监控服务很占磁盘io

转载请注明:Huangdc » 记一次绿色版bitnami gitlab-7.13.1升级至最新版本gitlab-ce-11.4.6-ce.0.el7.x86_64

results matching ""

    No results matching ""