gitlab部署

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了gitlab部署相关的知识,希望对你有一定的参考价值。

准备环境

yum install curl openssh-server openssh-clients postfix cronie
systemctl start postfix && systemctl enable postfix

安装gitlab

  1. 配置yum源
cat > /etc/yum.repo.d/gitlab-ce.repo << _EOF
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
_EOF
  1. 安装gitlab-ce
yum install -y gitlab-ce
  1. 配置并启动gitlab
gitlab-ctl reconfigure
  1. 登陆并重置root密码

安装完成之后通过http://ip访问,会输入两次密码,重置的是管理员root的密码,重置完成则可以通过root用户登陆管理

gitlab的特殊配置

  1. 配置gitlab的项目代码存储位置
# /etc/gitlab/gitliab.rb
git_data_dir = ({
    "default" => {"path" => "/data/gitlab"}
})
  1. 配置访问域名
external_url: "http://git.**.com"
  1. 数据备份目录
gitlab_rails[‘backup_path‘] = ‘/mnt/backups‘
  1. 使配生效
gitlab-ctl reconfigure

备份

gitlab-rake gitlab:backup:create

使用以上命令会在备份目录下创建一个名称类似为1393513186_gitlab_backup.tar的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的1393513186是备份创建的日期.

恢复

# 停止相关数据链接服务
gitlab-ctl stop  unicorn
gitlab-ctl stop  sidekiq

# 从1393513186编号备份中恢复
gitlab-rake gitlab:backup:restore BACKUP=1393513186

# 启动 gitlab
gitlab-ctl start

gitlab常用命令

Gitlab命令分为两部分:通用命令 和服务管理命令

  • 通用命令
help             帮助
reconfigure      修改配置文件之后,需要重新加载下
show-config      查看所有服务配置文件信息
uninstall        卸载这个软件
cleanse          删除gitlab数据,重新白手起家
  • 服务管理命令
start            启动所有服务
stop             关闭所有服务
restart          重启所有服务
status           查看所有服务状态
tail             查看日志信息
service-list     列举所有启动服务
graceful-kill    平稳停止一个服务

以上是关于gitlab部署的主要内容,如果未能解决你的问题,请参考以下文章

Gitlab代码管理仓库安装部署

Gitlab部署及汉化操作

Gitlab+jenkins持续集成+自动化部署

centos 7部署并汉化Gitlab及基础操作

centos 7安装gitlab及使用

gitlab 权限说明