通用命令
sudo gitlab-ctl start # 启动所有 gitlab 组件;
sudo gitlab-ctl stop # 停止所有 gitlab 组件;
sudo gitlab-ctl restart # 重启所有 gitlab 组件;
sudo gitlab-ctl status # 查看服务状态;
sudo gitlab-ctl reconfigure # 启动服务;
sudo vim /etc/gitlab/gitlab.rb # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
sudo gitlab-ctl tail # 查看日志;
安装
1.vim /etc/yum.repos.d/gitlab-ce.repo
复制以下内容:
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
2、更新本地yum缓存
sudo yum makecache
3、安装GitLab社区版
sudo yum install gitlab-ce-x.x.x #安装指定版本 若不包含-x.x.x则不能指定版本,安装为最新版本
***注意备份gitlab-secrets.json文件与gitlab.rb 数据恢复会用
升级
***注***:https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations
(gitlab官方升级指南,偶尔成功,一般情况无法访问-_-||建议多次刷新)
卸载
1、停止gitlab
gitlab-ctl stop
2、卸载gitlab(注意这里写的是gitlab-ce)
rpm -e gitlab-ce
3、查看gitlab进程
4、杀掉runsvdir进程
5、删除所有包含gitlab文件
备份
手动
gitlab提供的备份命令为gitlab-rake,备份命令使用如下:
gitlab-rake gitlab:backup:create
该命令会备份gitlab仓库、数据库、用户、用户组、用户密钥、权限等信息。
备份文件目录:/var/opt/gitlab/backups/(默认)
备份地址可修改配置文件../gitlab/gitlab.rb
修改属性gitlab_rails['backup_path'] = "/../.../" 备份地址
修改属性gitlab_rails[‘backup_keep_time’] = 604800 备份留存时间
其中backup_keep_time是以秒为单位进行计算的
修改后需要通过sudo gitlab-ctl reconfigure 对git配置进行刷新
自动
建议使用系统crontab命令
以实现每天凌晨4点进行一次自动备份为例,系统的crontab配置如下:
vim /etc/crontab
0 4 * * * root /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
systemctl restart crond (通过该命令使定时任务生效)
恢复
步骤1: 启动新git
sudo gitlab-ctl start # 启动所有 gitlab 组件;
步骤2: 拷贝备份文件至backups目录下
步骤3: gitlab服务器上停止相关数据连接服务
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
步骤4: 数据恢复命令gitlab-rake gitlab:backup:restore BACKUP=(此处填写备份编号)
备份编号为 备份文件名称去除 "_gitlab_backup.tar"
步骤5: 手工恢复gitlab-secrets.json文件与gitlab.rb
gitlab.rb可重新设置,为git启动的基本配置
步骤6: 重设、重启服务并检查
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
sudo gitlab-rake gitlab:check SANITIZE=true