GitLab

一、GitLab简介

GitLab 是一个用于仓库管理系统的开源项目。使用Git作为代码管理工具,并在此基础上搭建起来的web服务。可通过Web界面进行访问公开的或者私人项目。它拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供一个代码片段收集功能可以轻松实现代码复用。

常用的网站:

官网:https://about.gitlab.com/

国内镜像:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/

安装环境:

1、 CentOS 6或者7

2、 2G内存(实验)生产(至少4G)

3、 安装包:gitlab-ce-10.0.6-ce

4、 禁用防火墙,关闭selinux

二、GitLab安装

1、安装依赖

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd

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

sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix 

2、获取rpm包管理仓库并安装

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ee
安装其他版本可以去镜像下载对应版本安装
[root@wen src]# cd /usr/local/src/
[root@wen src]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.6-ce.0.el7.x86_64.rpm
[root@wen src]# rpm -ivh gitlab-ce-10.0.6-ce.0.el7.x86_64.rpm

3、配置

修改配置文件:/etc/gitlab/gitlab.rb
修改external_url 的地址为:"http://10.0.0.200" 或域名"http://gitlab.wenyule.com"  #注意要加引号
修改完主配置文件后,使用 gitlab-ctl reconfigure 重新配置gitlab

4、启动

重新配置gitlba后,在浏览地址栏中输入http://10.0.0.200

第一次登陆需要设置密码

配置root用户的密码,完成后进入系统:

设置中心可以设置中文

至此的GitLab安装已经完成

gitlab 可以个性化设置很多,设置登录封面,logo,登录选项.....

 

Gitlab Shell

Gitlab Shell有两个作用:
  为Gitlab处理Git命令、修改authorizedkeys列表。   当通过SSH访问Gitlab Server时,Gitlab Shell会限制执行预定义好的Git命令(git push,git pull,gitannex)
  调用Gitlab Rails API检查权限执行pre
-receive钩子(在GitLab企业版中叫做Git钩子)执行你请求的动作处理GitLab的post-receive动作。

处理自定义的post-receive动作当通过http(s)访问Gitlab Server时,工作流程取决于你是从Git仓库拉取(pul)代码还是向git仓库推送(push)代码。 如果你是从Git 仓库拉取(pull代码,Gitlab Rails应用会全权负责处理用户鉴权和执行Git命令的工作; 如果你是向Git 仓库推送(push)代码,Gitlab Rails 应用既不会进行用户鉴权也不会执行Git命令,它会把以下工作交由Gitlab Shell进行处理:调用GitabRails ApI检查权限。执行pre-receive钩子(在Gitlab企业版中叫做Git钩子)。
执行你请求的动作处理GitLab的post-receive动作处理自定义的post-receive动作 /usr/local/src/ gitlab-ctl reconfigure # 只要修改/etc/gitlab/gitlab.rb 就需要重新配置 gitlab-ctl tail restart [option] status

 

269491828

GITLAB备份管理

#配置文件中加入
gitlab rails['backup path']='/data/backup/gitlab'
gitlab rails['backup keep time']=604800              # 以秒计算
​
#如果自定义备份目录需要赋予git权限
mkdir /data/backup/gitlab
chown -R git.git /data/backup/gitlab
/usr/bin/gitlab-rake gitlab:backup:create #执行备份
​
#定时任务Crontab中加入
0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create

GITLAB数据恢复

#停止数据写入服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-rake gitlab:backup:restore BACKUP=1512811475_2017_12_09_10.2.2
gitlab-ctl restart

把先关服务

    rpm -uvp xxxxxx.rpm     升级gitlab

最好不要升级。真要升级采用数据导入的
原文地址:https://www.cnblogs.com/wenyule/p/10014579.html