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.rpm
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.
[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
原文地址:https://www.cnblogs.com/piperck/p/11620413.html
- HDUOJ-----1166敌兵布阵
- HDUOJ------2492Ping pong
- HDUOJ----2489 Minimal Ratio Tree
- HDUOJ----2487Ugly Windows
- HDUOJ--------1003 Max Sum
- HDUOJ -----1864 最大报销额(动态规划)
- 行受影响 是什么意思
- c++课程设计(日历)
- 一个程序,让你理解运算符重载操作
- HDUOJ ---1423 Greatest Common Increasing Subsequence(LCS)
- 在运算符重载++,--,+=,-=...
- 排序一栏(总结帖)
- 编程思想 之「异常及错误处理」
- nyoj-----284坦克大战(带权值的图搜索)
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- vue-qr二维码插件使用简介
- Codeforces Round #547 (Div. 3)F1. Same Sum Blocks (Easy)
- 手机软键盘弹起导致页面变形的一种解决方案
- Codeforces Round #547 (Div. 3)F2. Same Sum Blocks (Hard)
- 《 动态规划_ 入门_最大连续子序列 》
- docker搭建elasticsearch集群
- 用canvas实现手写签名功能
- Codeforces Round #547 (Div. 3)G. Privatization of Roads in Treeland
- 《 动态规划_ 入门_最大连续子序列_HDU_1003 》
- 2015 09CCF计算机软件能力认证试题第三题
- 《内蒙古自治区第十二届大学生程序设计竞赛试题_D: 正品的概率》
- Elasticsearch: Painless script编程
- mysql实现定时全量备份
- 在浏览器调起本地应用的方法
- 《内蒙古自治区第十二届大学生程序设计竞赛试题_G: 最大收益》