部署本地gitlab

一、gitlab简介

      GitLab是利用 Ruby on Rails 一个开源的版本管理系统,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目。它拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找。

依赖组件:ruby 1.9.3+,nginx、MySQL,git,redis, Sidekiq。 

gitlab组件详解:

        nginx:静态web服务器

        gitlab-shell:用于处理git命令和修改authorized keys列表

        git-workhorse:轻量级反向代理服务器

        logrotate:日志文件管理工具

        postgresql:数据库

        redis:缓存数据库

        sidekiq:用于在后台执行队列任务(异步执行)

        unicorn:gitlab rails应用是托管在这个服务器上面的

最低配置内存2G

相关目录:

/var/opt/gitlab/git-data/repositories/rot:库默认存储目录

/opt/gitlab:应用代码和相应的依赖程序

/var/opt/gitlab:gitlab-ctl reconfigure命令编译后的应用数据和配置文件,不需要人为修改

/etc/gitlab:配置文件目录

/var/log/gitlab:此目录存放gitlab各个组件产生的日志

/var/opt/gitlab/backups:备份文件生成目录

特点:

1. Web框架使用Ruby on Rails。

2. 基于MIT代码发布协议。

3. 需要gitolite协同工作。

二、安装gitlab

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

清华镜像:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

安装依赖:

sudo yum install curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld

RPM安装

rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.9.5-ce.0.el7.x86_64.rpm

注意:如果安装不了,请修改yum源

#vim /etc/yum.repos.d/gitlab-ce.repo[gitlab-ce]
name=gitlab-ce
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=

# 再执行
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.9.5-ce.0.el7.x86_64.rpm
rpm -ivh gitlab-ce-7.10.0~omnibus.2-1.x86_64.rpm

修改配置文件:

#vim /etc/gitlab/gitlab.rb
external_url 'http://your_ip_address'

配置:

gitlab-ctl reconfigure

相关命令:

gitlab-ctl status       查看状态

gitlab-ctl start          启动

gitlab-ctl stop          关闭

gitlab-ctl restart       重启

gitlab-ctl tail nginx   查看nginx日志

gitlab-ctl show-config   验证配置

访问:

http://your_ip_address

blob.png

默认用户:root

默认密码:5iveL!fe

登录后修改密码!!!!

blob.png

新密码登录:

blob.png

项目管理案例:

加入你们公司有一个项目组,包含pm dev1 dev2,一天pm有一个需求需要dev1 dev2完成,那么我们应该怎么去创建组和用户呢?

创建项目:

blob.pngCreate a new repository and  ssh-key

blob.png

blob.png

git clone git@192.168.56.11:root/car2share.git
cd car2share
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

blob.png

posted @ 2018-04-10 10:30  GeminiMp  阅读(1366)  评论(0编辑  收藏  举报