Gitlab 
一、GitLab简介 
GitHub是2008年由Ruby on Rails编写而成,与业界闻名的Github类似;但要将代码上传到 GitHub上面,而且将项目设为私有还要收费。而 GitLab 则是开源免费的(社区版免费,企业版需要订阅),能够浏览源代码,管理缺陷和注释,非常适合在团队内部使用。 
1.1 Gitlab提供的功能 
代码托管服务 
访问权限控制 
问题跟踪,bug的记录、跟踪和讨论 
Wiki,项目中一些相关的说明和文档 
代码审查,可以查看、评论代码 
1.2 Gitlab(Github)和Git区别 
Github和Git是两回事。 
Git是版本控制系统,Github是在线的基于Git的代码托管服务。 
GitLab 是一个用于仓库管理系统的开源项目。使用Git作为代码管理工具,可通过Web界面进行访问公开的或者私人项目. 
1.3 Github PK Sourceforge 
为什么现在Github这么火,以至于世界顶级公司和项目的源码很多都托管在Github上 
Why? 
颜值高 
简洁大方

2011年,Github已经取代Sourceforge,成为最活跃的代码交流社区。这意味着在Open Source Community(开源社区),Git取代了SVN已经成为事实。

1.3.1 Github界面

1.3.2 Sourceforge界面

二、Gitlab安装 
2.1 环境配置 
硬件: 
Centos-6.x系列_x86_64 
Mem建议至少2G 
软件: 
gitlab-ce.x86_64 0:8.8.0-ce 
server client 
192.168.201.131 192.168.201.130(作为测试端) 
本次采用yum安装方式 
2.2 安装 
1、关闭SELinux

下面的命令实现永久关闭SELinux

[root@git ~]# sed -i 's/^SELINUX=./#&/;s/^SELINUXTYPE=./#&/;/SELINUX=.*/a SELINUX=disabled' /etc/sysconfig/selinux

下面的命令实现临时关闭SELinux

[root@git ~]# setenforce 0 
setenforce: SELinux is disabled

永久修改下主机名,需要重启系统之后生效

[root@git ~]# vi /etc/sysconfig/network 
NETWORKING=yes 
HOSTNAME=git.server.com #修改成你自己的主机名

临时修改

[root@git ~]#hostname git.server.com

添加域名

[root@git ~]#cat /etc/hosts 
192.168.201.131 git.server.com 
2、关闭firewall

临时关闭

[root@git yum.repos.d]# iptables -F 
[root@git yum.repos.d]# /etc/init.d/iptables stop 
iptables: Setting chains to policy ACCEPT: nat filter [ OK ] 
iptables: Flushing firewall rules: [ OK ] 
iptables: Unloading modules: [ OK ]

永久关闭,需要下次重启系统之后生效

[root@git yum.repos.d]# chkconfig iptables off 
3、同步时间 
[root@git yum.repos.d]# ntpdate time.nist.gov 
10 Apr 11:00:04 ntpdate[40122]: step time server 216.229.0.179 offset 53747.856066 sec 
4、配置yum源 
[root@git yum.repos.d]# cat gitlab.repo 
[gitlab-ce] 
name=gitlab-ce 
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6 
repo_gpgcheck=0 
gpgcheck=0 
enabled=1 
gpgkey=https://packages.gitlab.com/gpg.key 
注解: 
如果想要在centos7系列上安装,只需把el6修改成el7 
5、安装Gitlab 
[root@git yum.repos.d]# yum install curl openssh-server openssh-clients postfix cronie -y 
[root@git yum.repos.d]# yum install gitlab-ce-8.8.0 -y 
6、修改下配置文件 
[root@git ~]# vi /etc/gitlab/gitlab.rb 
external_url 'http://git.server.com' 
external_url 修改成自己的ip或者域名

修改配置文件之后,需要重新是配置文件生效下,初始化下

[root@git ~]#gitlab-ctl reconfigure #这里会花费一定的时间 
Recipe: gitlab::gitlab-rails 
* execute[clear the gitlab-rails cache] action run 
- execute /opt/gitlab/bin/gitlab-rake cache:clear 
* execute[clear the gitlab-rails cache] action run 
- execute /opt/gitlab/bin/gitlab-rake cache:clear 
Recipe: gitlab::unicorn 
* service[unicorn] action restart 
- restart service service[unicorn] 
Recipe: gitlab::redis 
* ruby_block[reload redis svlogd configuration] action create 
- execute the ruby block reload redis svlogd configuration 
Recipe: gitlab::postgresql 
* ruby_block[reload postgresql svlogd configuration] action create 
- execute the ruby block reload postgresql svlogd configuration 
Recipe: gitlab::unicorn 
* ruby_block[reload unicorn svlogd configuration] action create 
- execute the ruby block reload unicorn svlogd configuration 
Recipe: gitlab::sidekiq 
* ruby_block[reload sidekiq svlogd configuration] action create 
- execute the ruby block reload sidekiq svlogd configuration 
Recipe: gitlab::gitlab-workhorse 
* service[gitlab-workhorse] action restart 
- restart service service[gitlab-workhorse] 
* ruby_block[reload gitlab-workhorse svlogd configuration] action create 
- execute the ruby block reload gitlab-workhorse svlogd configuration 
Recipe: gitlab::nginx 
* ruby_block[reload nginx svlogd configuration] action create 
- execute the ruby block reload nginx svlogd configuration 
Recipe: gitlab::logrotate 
* ruby_block[reload logrotate svlogd configuration] action create 
- execute the ruby block reload logrotate svlogd configuration

Running handlers: 
Running handlers complete 
Chef Client finished, 222/303 resources updated in 08 minutes 35 seconds

如果在此期间没有出现error,证明成功

7、启动Gitlab服务 
[root@git ~]# gitlab-ctl start 
ok: run: gitlab-workhorse: (pid 1407) 263s 
ok: run: logrotate: (pid 1403) 263s 
ok: run: nginx: (pid 1404) 263s 
ok: run: postgresql: (pid 1405) 263s 
ok: run: redis: (pid 1402) 263s 
ok: run: sidekiq: (pid 1400) 263s 
ok: run: unicorn: (pid 1401) 263s 
gitlab-workhorse这个“工作马”,就是gitlab-Git-http-server(GitlabV8.0出现,V8.2名称变更为Gitlab-workhorse) 
sidekiq 多线程启动 
unicorn是ruby的http server,可以通过http://localhost:8080端口访问 
重启服务的一些命令 
gitlab-ctl start|stop|status|restart 
8、登录 
http://192.168.201.131/users/sign_in 
由于第一次登陆,需要设置密码

登录

登录之后的界面

9、卸载 
重新安装清理 
1,卸载 
[root@git Gitlab-cn]# gitlab-ctl uninstall 
2,删除文件 
[root@git Gitlab-cn]#rm -rf /etc/gitlab/* /var/log/gitlab/ /var/opt/gitlab/ /opt/gitlab/ 
2.3 汉化 
查看版本 
[root@git .ssh]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION 
8.8.0 
下载汉化包并汉化 
[root@git hanhua]# git clone https://gitlab.com/larryli/gitlab.git Gitlab-cn && cd Gitlab-cn

生成补丁,

[root@git Gitlab-cn]#git diff origin/8-8-stable origin/8-8-zh > /tmp/8.8.diff

备份/opt/gitlab/embedded/service目录下的gitlab-rails目录,该目录下的内容主要是web应用部分

[root@git Gitlab-cn]#cp -rf /opt/gitlab/embedded/service/gitlab-rails /tmp/gitlab-rails

关闭gitlab这个服务

打补丁

[root@git Gitlab-cn]#patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /tmp/8.8.diff 
。。。。 
patching file public/ci/build-canceled.svg 
patching file public/ci/build-failed.svg 
patching file public/ci/build-pending.svg 
patching file public/ci/build-running.svg 
patching file public/ci/build-skipped.svg 
patching file public/ci/build-success.svg 
patching file public/ci/build-unknown.svg 
patching file public/deploy.html 
至此打补丁完成

测试是否汉化成功 
[root@git ~]# gitlab-ctl start 
ok: run: gitlab-workhorse: (pid 1407) 263s 
ok: run: logrotate: (pid 1403) 263s 
ok: run: nginx: (pid 1404) 263s 
ok: run: postgresql: (pid 1405) 263s 
ok: run: redis: (pid 1402) 263s 
ok: run: sidekiq: (pid 1400) 263s 
ok: run: unicorn: (pid 1401) 263s 
登录 
http://192.168.201.131/users/sign_in

2.4 实战测试 
http客户端测试

创建测试目录

[root@client ~]# mkdir test2 
[root@client ~]# cd test

把服务器的上仓库clone下来

[root@cleint test2]# git clone http://git.server.com/root/test.git 
Cloning into 'test'... 
warning: You appear to have cloned an empty repository. 
Checking connectivity... done. 
[root@git test2]# ls 
test 

[root@cleint test2]# git config --global user.name "Administrator" 
[root@client test2]# git config --global user.email "admin@example.com" 
[root@client test2]# cd test/ 
[root@client test]# ls 
[root@client test]# touch README.md 
[root@client test]# vi README.md 
[root@client test]# git add README.md 
[root@client test]# git commit -m "add README" 
[master (root-commit) 874889b] add README 
1 file changed, 1 insertion(+) 
create mode 100644 README.md 
[root@client test]# git push -u origin master 
Username for 'http://git.server.com': root 
Password for 'http://root@git.server.com': adminroot 
Counting objects: 3, done. 
Writing objects: 100% (3/3), 223 bytes | 0 bytes/s, done. 
Total 3 (delta 0), reused 0 (delta 0) 
To http://git.server.com/root/test.git 
* [new branch] master -> master 
Branch master set up to track remote branch master from origin. 
从web上查看test仓库下是否上传了README.md这个文件

上传成功 
ssh客户端测试

生成公钥

[root@node6 .ssh]# ssh-keygen 
Generating public/private rsa key pair. 
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa. 
Your public key has been saved in /root/.ssh/id_rsa.pub. 
The key fingerprint is: 
d9:0d:43:2b:17:cc:3b:01:fa:c9:cb:2c:6e:b7:27:6d root@node6 
The key's randomart image is: 
+--[ RSA 2048]----+ 
| .+o | 
| . .+o | 
| . . =o | 
| o *o+ | 
| S ... | 
| o . | 
| . +. | 
| ...o E | 
| ....= | 
+-----------------+ 
[root@node6 .ssh]# 
[root@node6 .ssh]# ls 
id_rsa id_rsa.pub 
[root@node6 .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAoOLsYhPPlHPOnGh6SoVDPlVn2o8rfO55J60Gz7E0EDB0ugKgTu4VGOE8vVta7HH5exNAjw2UqHIliYcmVvrj5eFbvXLdLYGypiMfuP4H7dVwGXfxSzeG17aIbZma0fpB2bTQr3tN+nVA7tokVSmO+jC61/H6Qj9G1TEiedq0wtTuSQ8pza5hyeWRO9oi0W7ccZkYg7lSQ3Eo2n2/RJbmQHWdIcoBO8c64h5vq/gB1s7ZjHKUjSFvGTyHu7uYE6yD2PXylavLfq2FHUc4syV8yAvyW2ehgIcc+xDWMFC85SNuPvTOt0YNzG628gWB2lm+D8CPhZBUbz2IUkFN0jEdyQ== root@node6

添加这个(如果是真实的域名,这步不需要做)

[root@node6 .ssh]# vi /etc/hosts 
192.168.201.131 git.server.com

测试是否可用

[root@node6 .ssh]# ssh -T git@git.server.com 
The authenticity of host 'git.server.com (192.168.201.131)' can't be established. 
RSA key fingerprint is 45:1f:76:55:cb:72:fe:65:22:75:10:eb:d5:2e:35:d5. 
Are you sure you want to continue connecting (yes/no)? yes 
Warning: Permanently added 'git.server.com,192.168.201.131' (RSA) to the list of known hosts. 
Welcome to GitLab, Administrator! 
证明成功

拉取数据

[root@node6 .ssh]# git clone git@git.server.com:root/test.git 
Initialized empty Git repository in /root/.ssh/test/.git/ 
remote: Counting objects: 3, done. 
remote: Total 3 (delta 0), reused 0 (delta 0) 
Receiving objects: 100% (3/3), 223 bytes, done 
FAQ 
官方文档 
https://www.gitlab.com.cn/ 
英文版: 
https://git-scm.com/book/en/v2 
中文版: 
https://git-scm.com/book/zh/v2 
http://www.cnblogs.com/herry52/p/5680020.html

本文出自 “xinsz08の平行时空” 博客,请务必保留此出处http://xinsz08.blog.51cto.com/10565212/1915883

Gitlab的介绍及使用相关推荐

  1. GitLab分支介绍

    GitLab简介: GitLab是由GitLabInc.开发,使用MIT许可证的基于网络的Git仓库管理工具,且具有wiki和issue跟踪功能.使用Git作为代码管理工具,并在此基础上搭建起来的we ...

  2. 关于公司Gitlab使用介绍和操作简单介绍

    Gitlab使用介绍 一.公司 Gitlab 代码平台 Gitlab 代码平台为公司的主要代码仓库,请使用自己的Email 注册账号(用户名称要求中文真实姓名):注册完成后联系技术主管添加相应的 gr ...

  3. GitLab CI 介绍

    一.简介 GitLab CI 即是 gitlab continuous integration,意思是持续集成.中心思想是当每一次 push 到 gitlab 的时候,都会触发一次脚本执行,脚本的内容 ...

  4. 【DevOps】centos7 下的 gitlab托管服务器的介绍与安装

    文章目录 前言 gitlab的介绍 gitlab 和github的区别 gitlab的安装 1. 实验环境: 2. 安装和配置必要的依赖项 3. 添加yum源 4. 更新本地yum缓存,并安装 5. ...

  5. GitLab CI流水线配置文件.gitlab-ci.yml详解(三)

    GitLab CI流水线配置文件.gitlab-ci.yml详解 - contents:: 目录 本文讲解在 :ref:GitLab的汉化与CI持续集成gitlab-runner的配置 <con ...

  6. Gitlab CI(一)

    Gitlab CI流程设计与思考 repo添加ci完整流程 新增Repo CI注册需要开发者提供的信息和我们这边需要反馈的信息. CI注册需要提供的信息: 1. Repo url 2. 需要注册哪些C ...

  7. gitlab run成功 但无法访问_gitlab 部署 管理

    目录 1.gitlab基本介绍 2.安装前的准备 3.gitlab安装 4.gitlab管理 gitlab基本介绍 GitLab概述: 是一个利用 Ruby on Rails 开发的开源应用程序,实现 ...

  8. GitLab CI 自动部署netcore web api 到Docker

    前端篇文章中,我们已经成功的将asp.net core webapi在Docker容器中运行,并且部署了一套自己的GitLab环境. .Net & Docker(二)5分钟快速用Docker部 ...

  9. Docker搭建自己的GitLab

    Docker搭建自己的GitLab docker 介绍 **GitLab: ** GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务 **Do ...

最新文章

  1. Android屏幕像素密度适配详解
  2. 9 大主题卷积神经网络(CNN)的 PyTorch 实现
  3. 硬中断与软中断的区别!!!
  4. 使用Python操作MySQL数据库
  5. 如何理解计算机程序中的宏?
  6. html:(10):添加空格和hr
  7. C#LeetCode刷题之#485-最大连续1的个数(Max Consecutive Ones)
  8. mysql账号相关的操作和安全管理
  9. 3D视频的质量评价报告 (MSU出品)
  10. c语言中用分数表示结果,C语言实例 计算分数的精确值
  11. 【Java程序设计】接口与多态
  12. Mac终端扫描附近wifi信号强度/信道
  13. 使用arcface+CrossEntropyLoss处理普通分类
  14. 计算机管理里边设置访问权限,电脑访问权限设置_电脑软件访问权限设置
  15. linux link 硬链接,Linux系统中的硬链接(hard link)与软链接(symbolic link)
  16. React中过渡动画的编写方式
  17. for(int num:nums)
  18. 腾讯云服务器到期未续费,CVM实例被释放还能找回文件吗?
  19. ES6中字符串和数组新增的方法
  20. 健身运动燃烧脂肪的三个必要条件

热门文章

  1. Android在线源码网站推荐
  2. 似乎在梦中见过的样子 (KMP)
  3. 运行tomcat报错:Address localhost:1099 is already in use
  4. 计算机职称照图片,全国职称计算机报名如何上传照片。怎么提示你无需上传照片。可以直接进行报名呢...
  5. 网站建设(5)——博客程序的选择和部署
  6. php药膳 源码,-道家药膳
  7. 个人面经整理海尔测试
  8. 数智化时代,驱动企业转型升级的“三驾马车”是什么?
  9. vim工具——常用插件
  10. 直播报名 | Apache Kylin Meetup