安装依赖软件:
yum -y install policycoreutils openssh-server openssh-clients postfix
设置postfix开机自启,并启动,postfix支持gitlab发信功能:
systemctl enable postfix && systemctl start postfix
下载rpm包并安装:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.0.0-ce.0.el7.x86_64.rpm
备份:gitlab-rake gitlab:backup:create
rpm -i gitlab-ce-12.0.0-ce.0.el7.x86_64.rpm
配置:
/etc/gitlab/gitlab.rb
重置并启动GitLab
执行:
gitlab-ctl reconfigure
gitlab-ctl restart
注意⚠️:
配置:gitlab-ctl reconfigure(等待时间较长) 若安装过程遇到“ ruby_block[wait for redis service socket] action run”处卡住,可通过alt+c退出,并执行systemctl restart gitlab-runsvdir,再继续执行gitlab-ctl reconfigure,如安装过程遇到报错信息,可重复执行gitlab-ctl reconfigure,如继续卡住,可以kill 掉之前的gitlab-ctl reconfigure进程。
备份:
gitlab-rake gitlab:backup:create.
gitlab-backup create STRATEGY=copy(12.1之后的版本)
备份文件会生成到备份目录
恢复:
# 停止相关数据连接服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-rake gitlab:backup:restore 1594227698_2020_07_09_12.4.0
gitlab-ctl start
gitlab-ctl status
gitlab-rake gitlab:check SANITIZE=true (检查恢复情况)
注意:恢复操作默认使用的是git用户权限,所以拷贝过来的文件要给予git权限,否则报权限不够
仓库迁移:
vim /etc/gitlab/gitlab.rb
找到git_data_dir,修改为你的目标地址
gitlab-ctl stop
如果已经有历史数据(没有直接省去这步):
rsync -av /var/opt/gitlab/git-data/repositories /data/gitlab/git-data/
重新配置:
gitlab-ctl reconfigure
启动服务:
gitlab-ctl start
卸载:
gitlab-ctl stop (停服务)
rpm -e gitlab-ce (卸载gitlab)
ps aux | grep gitlab (查看进程)
kill -9 进程
删除所有包含gitlab文件
find / -name gitlab | xargs rm -rf
升级:
安装原相同版本
恢复备份数据
检查数据是否正常
升级到目标版本(如果跨大版本,一定要查看官网是否需要先升级到原来版本的最后一个版本,然后再升级到目标版本)
hooks检查
老版本升级
由于公司老的gitlab是通过源码安装的方式安装的,且安装的数据库为mysql,而omnibus-gitlab默认安装使用的数据库为postgresql,故首先将将原来老的gitlab备份的格式修改为postgresql格式
-
生成最新的备份数据
$ sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
-
创建工作目录
$ sudo -u git -H mkdir -p tmp/backups/postgresql
$ sudo -u git -H mv tmp/backups/TIMESTAMP_gitlab_backup.tar
-
导出mysql最新的数据,且兼容postgresql格式
$ cd tmp/backups/postgresql
$ sudo -u git -H mysqldump --compatible=postgresql --default-character-set=utf8 -r gitlabhq_production.mysql -uxxxx gitlabhq_production –pxxxxx
-
将mysql格式转换为postgresql格式
$ sudo -u git -H git clone https://github.com/gitlabhq/mysql-postgresql-converter.git -b gitlab
$ sudo -u git -H mkdir db
$ sudo -u git -H python mysql-postgresql-converter/db_converter.py gitlabhq_production.mysql db/database.sql
-
将转换后的数据文件替换到备份数据中
$ sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql
浙公网安备 33010602011771号