gitlab 从古老的 bitnami 版本 迁移到官方最新版本
这是我之前发布在 yuque 的文章。是我刚来新公司的时候帮公司搬迁 git 记录下来的,现在看来去掉敏感部分直接发布也没啥问题啦,就搬家过来,我自己也方便查 XD .
8.1.6 -> 10.1.4
首先需要分几个步骤
第一步
我将老版本 这里是从 bitnami gitlab 上安装的 8.1.4 版本
将这个版本下的所有现在有的数据进行备份。 使用
找到
/opt/gitlab-7.x.x-x/apps/gitlab/htdocs/config/gitlab.yml,将backup一项的路径改为"/data/backups_gitlab",注意目录的权限更改。
这个路径下面可以找到我们的 gitlab 配置文件,将 backup 的地址指定为我们想要其备份的地址。
之后开始备份,使用
cd /opt/gitlab-7.x.x-x/
./use_gitlab
cd /opt/gitlab-7.x.x-x/apps/gitlab/htdocs
bundle exec bin/rake gitlab:backup:create RAILS_ENV=production
报错情况1:
You have already activated rake 0.9.2.2,but our Gemfile requires rake 10.1.0,Using bundle exec may solve this.
原因是默认的path路径不对,需要执行下bitnami自带的环境变量设置脚本: 执行安装目录下use_gitlab即可解决。
报错情况2:笔者使用的数据库为MySQL,报错
Can't connect to local MySQL server through socket.
解决方法为用find指令找到MySQL实际使用的.sock文件,在报错中的目录下建立软链接。
之后我们就能在原来的机器上获得一个备份好的压缩包
这里注意 backup 的时候不能停机,备份的时候可能会去尝试链接还在运行的数据库,如果服务 down 了会链接失败。
第二步
由于我要到新机器上部署我的新版本,所以我在另外一台机器上下载好了跟之前 bitnami 一样的版本,这个版本是官方的 Omnibus 版本。我手动下载的 .rpm 包。
我这里采用手动安装:
sudo EXTERNAL_URL="http://127.0.0.1:8081" rpm -i gitlab-ee-9.5.2-ee.0.el7.x86_64.rpm
Installing the GitLab Package
With the desired package downloaded, use your systems package management tool to install it. For example:
DEB based (Ubuntu, Debian, Raspberry Pi):
sudo EXTERNAL_URL="http://gitlab.example.com" dpkg -i gitlab-ee-9.5.2-ee.0_amd64.deb
RPM based (CentOS, RHEL, Oracle, Scientific, openSUSE, SLES):
sudo EXTERNAL_URL="http://gitlab.example.com" rpm -i gitlab-ee-9.5.2-ee.0.el7.x86_64.rpmChange
http://gitlab.example.comto the URL at which you want to access your GitLab instance. Installation will automatically configure and start GitLab at that URL.
[root@iZ2ze9mbirr18cl7fb5ewtZ gitlab]# sudo EXTERNAL_URL="http://git.hundun.cn" rpm -i gitlab-ce-8.1.4-ce.0.el7.x86_64.rpm
gitlab: Thank you for installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:
sudo gitlab-ctl reconfigure
gitlab: GitLab should be reachable at http://iZ2ze9mbirr18cl7fb5ewtZ
gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
gitlab: And running reconfigure again.
gitlab:
gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
gitlab:
It looks like GitLab has not been configured yet; skipping the upgrade script.
执行 sudo gitlab-ctl reconfigure 会开始配置下载好的 gitlab ,之后我们就可以使用 gitlab-ctl 来执行 gitlab 的 start|end|restart 等等命令了。
可以通过 ps -ef 查看 gitlab 的 nginx 读取哪儿的配置文件如下:
nginx: master process /opt/gitlab/embedded/sbin/nginx -p /var/opt/gitlab/nginx
所以我们可以在 /var/opt/gitlab 下面找到最新的配置文件。
Next, install the GitLab package. Change `http://gitlab.example.com` to the URL at which you want to access your GitLab instance. Installation will automatically configure and start GitLab at that URL. HTTPS requires additional configuration after installation.
sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ee
其实当我们在安装的时候 让我们设置的一个地址可以让外部访问,那个地址会让 gitlab 自动生成一个 nginx 配置文件,监听的 server_name 就是我们设置的地址,如果需要反向代理我们可能需要去 gitlab 的 nginx 配置目录下面修改这个监听地址。如果没有反向代理,看上去直接设置之后就可以使用了(这里一般都是需要定制的,感觉 gitlab 这个也给自动设置有点过于优化了。不过也体现出人家尽量提升用户体验的感觉吧)。
第三步
拷贝备份到新机器上 这个简单 scp 一下就行了 like this
scp /home/a.txt root@192.168.0.8:/home/root
从本地 传输到 192.168.0.8
然后就是 restore
现将之前的复制包 拷贝到 omnibus 版本的 backup 目录
之后停掉其中两个服务并且 check 其状态。
恢复完毕之后让我们 check 其状态。
sudo cp 11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar /var/opt/gitlab/backups/Stop the processes that are connected to the database. Leave the rest of GitLab running:
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiqVerify
sudo gitlab-ctl statusNext, restore the backup, specifying the timestamp of the backup you wish to restore:
This command will overwrite the contents of your GitLab database!
这里会重写数据库和内容,因为是恢复备份所有都会清掉所以特意让我们注意。
sudo gitlab-rake gitlab:backup:restore BACKUP=1493107454_2018_04_25_10.6.4-ceNext, restore /etc/gitlab/gitlab-secrets.json if necessary as mentioned above.
Restart and check GitLab:
sudo gitlab-ctl restart
sudo gitlab-rake gitlab:check SANITIZE=trueIf there is a GitLab version mismatch between your backup tar file and the installed version of GitLab, the restore command will abort with an error. Install the correct GitLab version and try again.
这里特别注意,所有的恢复迁移工作都是建立在备份的版本和安装的新版本相同的情况下。
第四步
通过官方渠道升级到最新版本。(未完待续)
# Debian/Ubuntu
dpkg -i gitlab-ce-XXX.deb # CentOS/RHEL
rpm -Uvh gitlab-ce-XXX.rpm
分别使用这两个包管理工具进行升级。
升级过于老旧的版本需要脚本放得很缓慢,基本上最多 3个 mirror 一升,否则就会出错。而且是无法挽回的错误又得重来。另外记得每次升级完成后 重启然后修改 nginx 参数。
完成升级之后可以留意一下 git 的 host 是否正常。例如如果你使用阿里云却不配置对外访问地址,那么git host 应该会出现非常奇怪的地址。所以需要配置 gitlab 配置文件将对外地址项改成域名。然后 gitlab-ctl reconfigure 一下生效即可。
虽然这里记录的东西最少,但是这里几乎最耗时,来来回回包括查资料差不多 8 小时吧。最开始还想一步到位升上去简直太天真了。
之后 linux 下删除软件尽量使用对方提供的现成方法,并且找到所有的删掉可以使用 find 方法。
find / -iname 'xxx'
QA:
Q: 卡在卸载gitlab然后再次安装执行sudo gitlab-ctl reconfigure的时候往往会出现:ruby_block[supervise_redis_sleep] action run,会一直卡无法往下进行!
A:
1、按住CTRL+C强制结束;
2、运行:sudo systemctl restart gitlab-runsvdir;
3、再次执行:sudo gitlab-ctl reconfigure
https://www.cnblogs.com/springwind2006/p/6872773.html
Q: 数据库恢复密码丢了。
A: https://docs.gitlab.com/ee/security/reset_root_password.html#doc-nav
Reference:
https://packages.gitlab.com/app/gitlab/gitlab-ce/search gitlab 发布包地址
http://xlindo.com/2015/08/18/gitlab备份与恢复操作方法/ gitlab bitnami 备份恢复文档
https://community.bitnami.com/t/upgrade-bitnami-gitlab-ce-version/48641 bitnami 官方论坛关于升级问题
https://docs.gitlab.com.cn/omnibus/update/README.html#updating-from-gitlab-66-and-higher-to-the-latest-version gitlab 官方文档 -> Updating GitLab via omnibus-gitlab
https://docs.gitlab.com/ee/raketasks/backup_restore.html#restore restore for Omnibus
https://about.gitlab.com/installation/#centos-7 官方安装文档
https://docs.gitlab.com/ee/policy/maintenance.html#versioning 官方推荐升级路径
https://about.gitlab.com/blog/categories/releases/ 官方 relase 文档
https://www.jianshu.com/p/a86a1529d253 nginx反向代理 gitlab
https://docs.gitlab.com/omnibus/settings/smtp.html gitlab SMTP settings
gitlab 从古老的 bitnami 版本 迁移到官方最新版本的更多相关文章
- Webstorm官方最新版本for Mac版本 不用注册码/破坏原文件
首先,说明下我自己安装的时候看到网上无外乎两种方法: 下载别人封装好的安装包,把JetbrainsCrack.jar复制到/Applications/WebStorm.app/Contents/bin ...
- Apple历史应用以及开发工具版本(Xcode官方历史版本等等)
1.Xcode 官方历史版本下载:(需要登录开发者账号) https://developer.apple.com/download/more/
- [Angular] 删除旧版本,升级安装最新版本
目录 删除旧版本 清除未卸载干净的angular-cli缓存 对于Linux 对于Windows 安装最新版本 查看安装版本 创建新项目 删除旧版本 npm uninstall -g angular- ...
- 记录下pytorch代码从0.3版本迁移到0.4版本要做的一些更改。
1. UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to in ...
- CoreData的简单使用(二)数据的增删改查,轻量级的版本迁移
上一篇中我们已经使用CoreData创建了一个SQLite数据库 CoreData的简单使用(一)数据库的创建 现在对数据库进行数据的CRUD(增删改查) 1.Data Model 的设置 创建一个D ...
- CentOS 6.6 升级GCC G++ (当前最新版本为v6.1.0) (完整)
---恢复内容开始--- CentOS 6.6 升级GCC G++ (当前最新GCC/G++版本为v6.1.0) 没有便捷方式, yum update.... yum install 或者 添加y ...
- phpstudy2016最新版本mysql无法使用innodb的问题解决
这里顺便记录一下今天遇见的神奇问题,在使用官方最新版本的phpstudy中,其它组件一切正常,但是奇怪的发现mysql是无法开启innodb的,以下为最新的下载地址: http://www.phpst ...
- Struts2漏洞拉响网站安全红色警报以及把Struts2更新为最新版本Struts2.3.15.1步骤
360网站安全检测平台今日发布红色警报称,广泛应用在国内大型网站系统的Struts2框架正在遭到黑客猛烈攻击.利用Struts2“命令执行漏洞”,黑客可轻易获得网站服务器ROOT权限.执行任意命令,从 ...
- 【转】CentOS 6.6 升级GCC G++ (当前最新版本为v6.1.0) (完整)
原文地址:https://www.cnblogs.com/lzpong/p/5755678.html 我这里是centos7 升级到gcc8.1,过程差不多,参考这篇文章,记录一下. ---原文--- ...
随机推荐
- GitLab CI/CD的官译【原】
CI / CD方法简介 软件开发的持续集成基于自动执行脚本,以最大限度地减少在开发应用程序时引入错误的可能性.从新代码的开发到部署,它们需要较少的人为干预甚至根本不需要干预. 它涉及在每次小迭代中不断 ...
- [Tools] 多媒体视频处理工具FFmpeg
FFMpeg FFmpeg是一套可以用来记录.转换数字音频.视频,并能将其转化为流的开源计算机程序.采用LGPL或GPL许可证.它提供了录制.转换以及流化音视频的完整解决方案.它包含了非常先进的音频/ ...
- 使用别的电脑连接另一台电脑当中的虚拟机中的kylin项目
环境说明: 本机A的ip:192.168.0.242 服务器B的ip:192.168.0.125 服务器上的虚拟机C的ip:192.168.43.129 目前状态: B上面能访问C上的站点kylin站 ...
- 服务网格Istio初探
1. 服务网格Istio初探 1.1. 什么是Istio 它是一个完全开源的服务网格.什么是服务网格? 这个术语通常用于描述构成这些应用程序的微服务网络以及应用之间的交互.随着规模和复杂性的增长,服务 ...
- React 的setState 理解
我们都知道在React中,setState() 方法是用来改变组件状态的,在项目中也一直用,也没有出现什么问题(使用方法太简单了),但今天看了一篇文章,提到了setState 使用时的两个注意点,加深 ...
- Android中自定义环形图2
如图: 自定义属性,在values文件夹下创建 attrs.xml <?xml version="1.0" encoding="utf-8"?> & ...
- git https解决免ssL和保存密码
1.打开windows的git bash set GIT_SSL_NO_VERIFY=true git clonegit config --global http.sslVerify false 2 ...
- easyui datagrid Column Group 列组、 复杂表头 嵌套表头 组合表头 (转载)
核心: rowspan:2 //占两行 colspan:3 //占三列 所有的colspan下的二级列表头,统一放在一个数组里. 文章一: 转载来源:https://blog.csdn.ne ...
- prometheus学习系列十一: Prometheus和AlertManager的高可用
前面的系列中, prometheus和alertmanager都是单机部署的,会有单机宕机导致系统不可用情况发生.本文主要介绍下prometheus和alertmanager的高可用方案. 服务的高可 ...
- centos 服务器 nginx 负载均衡服务安装
yum -y install gcc gcc-c++ autoconf automake libtool make cmake yum -y install zlib zlib-devel opens ...