GitLab安装、迁移与恢复

安装GitLab版本,与之前版本保持一致(Centos 7)
Refer to:https://www.gitlab.com.cn/installation/#

1.下面的命令将会打开系统防火墙 HTTP 和 SSH 的访问
yum install curl policycoreutils openssh-server openssh-clients
systemctl enable sshd
systemctl start sshd

yum install postfix
systemctl enable postfix
systemctl start postfix

firewall-cmd –permanent –add-service=http
systemctl reload firewalld

2.添加 GitLab 镜像源并安装
curl -sS http://packages.gitlab.com.cn/install/gitlab-ce/script.rpm.sh | sudo bash
yum install gitlab-ce
安装指定版本:yum install gitlab-ce-8.10.5

或者手动安装
curl -LJO https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-XXX.rpm
rpm -ivh gitlab-ce-XXX.rpm
安装指定版本:rpm -ivh gitlab-ce-8.10.5-ce.0.el7.x86_64.rpm

添加国内源,国外源太慢,修改下载源
以下操作针对CentOS 7 ,其他的请戳 https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
vi /etc/yum.repos.d/gitlab-ce.repo
复制代码

[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key

进行安装
yum makecache
yum install -y gitlab-ce

3.配置并启动 GitLab
gitlab-ctl reconfigure

问题:安装GitLab出现ruby_block[supervise_redis_sleep] action run
在卸载gitlab然后再次安装执行sudo gitlab-ctl reconfigure的时候往往会出现:ruby_block[supervise_redis_sleep] action run,会一直卡无法往下进行!

解决方案:
1. 按住CTRL+C强制结束;
2. 运行:systemctl restart gitlab-runsvdir
3. 再次执行:gitlab-ctl reconfigure

4.重启或重新加载配置
gitlab-ctl reconfigure
gitlab-ctl status
gitlab-ctl stop
gitlab-ctl start

5.GitLab备份
gitlab-rake gitlab:backup:create
使用以上命令会在/var/opt/gitlab/backups目录下创建一个名称类似为1481598919_gitlab_backup.tar的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的1481598919是备份创建的日期
/etc/gitlab/gitlab.rb 配置文件须备份
/var/opt/gitlab/nginx/conf nginx配置文件
/etc/postfix/main.cfpostfix 邮件配置备份

6.自定义GitLab的备份目录
vi /etc/gitlab/gitlab.rb

修改如下参数值
external_url ‘http://192.168.48.124:8181
gitlab_rails[‘manage_backup_path’] = true
gitlab_rails[‘backup_path’] = “/data/data_back/gitlab_data”
gitlab_rails[‘backup_archive_permissions’] = 0644
gitlab_rails[‘backup_keep_time’] = 604800
gitlab_rails[‘gitlab_shell_ssh_port’] = 50022
postgresql[‘shared_buffers’] = “8192MB” # recommend value is 1/4 of total RAM, up to 14GB.

7.GitLab备份
gitlab-rake gitlab:backup:create

8.GitLab迁移与恢复
停止相关数据连接服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq

给备份文件赋予权限
chmod 777 /data/data_back/gitlab_data/1505263544_gitlab_backup.tar

从1481598919编号备份中恢复
gitlab-rake gitlab:backup:restore BACKUP=1505263544
1505263544为备份文件开头时间信息

9.启动Gitlab
gitlab-ctl start

10.访问Gitlab
http://192.168.48.124:8181

11.安装git客户端
yum install git-core

猜你喜欢

转载自blog.csdn.net/czy3y/article/details/77983023