1. 程式人生 > >GitLab的安裝部署

GitLab的安裝部署

GitHub和GitLab的區別

相同點:二者都是基於web的Git倉庫,在很大程度上GitLab是仿照GitHub來做的,它們都提供了分享開源專案的平臺,為開發團隊提供了儲存、分享、釋出和合作開發專案的中心化雲端儲存的場所。

GitHub作為開原始碼庫及版本控制系統,擁有超過900萬的開發者使用者,目前仍然是最火的開源專案託管系統。GitHub同時提供公共倉庫和私有倉庫,但如果要使用私有倉庫,是需要付費的。

而GitLab解決了這個問題,你可以在上面建立私人的免費倉庫。

GitLab讓開發團隊對他們的程式碼倉庫擁有更多的控制,相比於GitHub,它有不少的特色:

允許免費設定倉庫許可權;允許使用者選擇分享一個project的部分程式碼;允許使用者設定project的獲取許可權,進一步的提升安全性;可以設定獲取到團隊整體的改進進度;通過innersourcing讓不在許可權範圍內的人訪問不到該資源。

從程式碼私有性方面來看,有時公司並不希望員工獲取到全部的程式碼,這個時候GitLab無疑是更好的選擇。但對於開源專案而言,GitHub依然是程式碼託管的首選。

GitLab基本介紹

GitLab是利用Ruby on Rails一個開源的版本管理系統,實現一個自託管的Git專案倉庫,可通過Web介面進行訪問公開的或者私人專案。
與Github類似,GitLab能夠瀏覽原始碼,管理缺陷和註釋。可以管理團隊對倉庫的訪問,它非常易於瀏覽提交過的版本並提供一個檔案歷史庫。團隊成員可以利用內建的簡單聊天程式(Wall)進行交流。
它還提供一個程式碼片段收集功能可以輕鬆實現程式碼複用,便於日後有需要的時候進行查詢。

Git的家族成員

Git:是一種版本控制系統,是一個命令,是一種工具。
Gitlib:是用於實現Git功能的開發庫。
Github:是一個基於Git實現的線上程式碼託管倉庫,包含一個網站介面,向網際網路開放。
GitLab:是一個基於Git實現的線上程式碼倉庫託管軟體,你可以用gitlab自己搭建一個類似於Github一樣的系統,一般用於在企業、學校等內部網路搭建git私服。

Gitlab的服務構成

Nginx:靜態web伺服器。
gitlab-shell:用於處理Git命令和修改authorized keys列表。
gitlab-workhorse: 輕量級的反向代理伺服器。
logrotate:日誌檔案管理工具。
postgresql:資料庫。
redis:快取資料庫。
sidekiq:用於在後臺執行佇列任務(非同步執行)。
unicorn:An HTTP server for Rack applications,GitLab Rails應用是託管在這個伺服器上面的。

GitLab工作流程

這裡寫圖片描述

GitLab Shell
GitLab Shell有兩個作用:為GitLab處理Git命令、修改authorized keys列表。
當通過SSH訪問GitLab Server時,GitLab Shell會:

限制執行預定義好的Git命令(git push, git pull, git annex)
呼叫GitLab Rails API 檢查許可權
執行pre-receive鉤子(在GitLab企業版中叫做Git鉤子)
執行你請求的動作 處理GitLab的post-receive動作
處理自定義的post-receive動作

當通過http(s)訪問GitLab Server時,工作流程取決於你是從Git倉庫拉取(pull)程式碼還是向git倉庫推送(push)程式碼。
如果你是從Git倉庫拉取(pull)程式碼,GitLab Rails應用會全權負責處理使用者鑑權和執行Git命令的工作;
如果你是向Git倉庫推送(push)程式碼,GitLab Rails應用既不會進行使用者鑑權也不會執行Git命令,它會把以下工作交由GitLab Shell進行處理:

呼叫GitLab Rails API 檢查許可權
執行pre-receive鉤子(在GitLab企業版中叫做Git鉤子)
執行你請求的動作
處理GitLab的post-receive動作
處理自定義的post-receive動作

GitLab Workhorse

GitLab Workhorse是一個敏捷的反向代理。它會處理一些大的HTTP請求,比如檔案上傳、檔案下載、Git push/pull和Git包下載。其它請求會反向代理到GitLab Rails應用,即反向代理給後端的unicorn。

GitLab環境部署

企業版7.3
記憶體2G以上
虛擬機器可以使用上網功能

手動部署

虛擬機器上網

[root@server1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 

GATEWAY=172.25.8.250

[root@server1 ~]# vim /etc/resolv.conf 

nameserver 114.114.114.114
[root@foundation8 ~]# iptables -t nat -I POSTROUTING -s 172.25.8.0/24 -j MASQUERADE
[[email protected] ~]# ping baidu.com
PING baidu.com (123.125.115.110) 56(84) bytes of data.
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=1 ttl=48 time=99.3 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=2 ttl=48 time=52.2 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=3 ttl=48 time=45.8 ms

1.配置yum源

vim /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
Enabled=1
gpgcheck=0

2、更新本地yum快取

[[email protected] ~]# yum repolist
[[email protected] ~]# yum makecache
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
gitlab-ce                                                | 2.9 kB     00:00     
source7.3                                                | 4.1 kB     00:00     
(1/4): source7.3/filelists_db                              | 3.3 MB   00:00     
(2/4): source7.3/other_db                                  | 1.5 MB   00:00     
(3/4): gitlab-ce/other_db                                  |  23 kB   00:00     
(4/4): gitlab-ce/filelists_db                              | 185 MB   00:58     
Metadata Cache Created

3、安裝GitLab社群版

[root@server1 ~]# yum install gitlab-ce -y        # 自動安裝最新版
[root@server1 ~]# gitlab-ctl start                # 啟動所有 gitlab 元件;

GitLab常用命令

gitlab-ctl start                                 # 啟動所有 gitlab 元件;
gitlab-ctl stop                                  # 停止所有 gitlab 元件;
gitlab-ctl restart                               # 重啟所有 gitlab 元件;
gitlab-ctl status                                # 檢視服務狀態;
gitlab-ctl reconfigure                           # 啟動服務;
vim /etc/gitlab/gitlab.rb                        # 修改預設的配置檔案;
gitlab-rake gitlab:check SANITIZE=true --trace   # 檢查gitlab;
gitlab-ctl tail                                  # 檢視日誌;
[root@server1 ~]# vim /etc/gitlab/gitlab.rb 

  13 external_url 'http://172.25.8.1'            # 訪問gitlib的地址

[root@server1 ~]# gitlab-ctl reconfigure

這裡寫圖片描述

GitLab使用

登入GitLab
1、在瀏覽器的位址列中輸入ECS伺服器的公網IP即可登入GitLab的介面
在瀏覽器訪問
http://172.25.8.1
這裡寫圖片描述
這裡寫圖片描述
這裡寫圖片描述
這裡寫圖片描述
這裡寫圖片描述

[root@server1 ~]# ssh-keygen
[root@server1 ~]# cat .ssh/id_rsa.pub

這裡寫圖片描述
這裡寫圖片描述
這裡寫圖片描述

[[email protected] ~]# yum install git -y
[[email protected] ~]# git config --global user.name "zmy"
[[email protected] ~]# git config --global user.email "[email protected]"
[[email protected] ~]# git clone [email protected]:root/test.git
Cloning into 'test'...
The authenticity of host 'server1 (172.25.8.1)' can't be established.
ECDSA key fingerprint is b2:90:c6:d0:1e:f1:c2:3d:18:fb:84:88:6a:4c:41:fe.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'server1,172.25.8.1' (ECDSA) to the list of known hosts.
warning: You appear to have cloned an empty repository.
[[email protected] ~]# cd test/
[[email protected] test]# echo "test" > /root/test.sh
[[email protected] test]# cp /root/test.sh ./
[[email protected] test]# git add test.sh
[[email protected] test]# git commit -m "test.sh"
[master (root-commit) 19a1ccb] test.sh
 1 file changed, 1 insertion(+)
 create mode 100644 test.sh
 [[email protected] test]# git commit -m "test.sh"
[master (root-commit) 19a1ccb] test.sh
 1 file changed, 1 insertion(+)
 create mode 100644 test.sh
[[email protected] test]# git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 206 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:root/test.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

這裡寫圖片描述
這裡寫圖片描述

相關推薦

DevOps實踐之Gitlab安裝部署

dha 定義 設置 oca color chkconfig smt 接下來 .sh All GitLab packages are posted to our package server and can be downloaded. We maintain five re

GitLab安裝部署

團隊 mir span rpm -ivh font wal ble 部署 組件 Gitlab介紹   GitLab是一個利用 Ruby on Rails 開發的開源應用程序,實現一個自托管的Git項目倉庫,可通過Web界面進行訪問公開的或者私人項目。 GitLab擁有與G

Docker-Gitlab 安裝部署筆記

Docker-Gitlab Docker是一個開源的應用容器引擎,讓開發者可以打包他們的應用以及依賴包到一個可移植的容器中,然後釋出到任何流行的 Linux 機器上,也可以實現虛擬化。容器是完全使用沙箱機制,相互之間不會有任何介面。這篇文章是我練習時,在

gitlab 安裝部署

修改 -i curl res https tla blog emctl ssh 1.安裝相關依賴yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python

docker-compose安裝部署gitlab中文版

1. 配置docker-compose 這裡用到了一箇中文版的docker映象。hub.docker.com/r/twang2218… version: '3' services: gitlab: image: 'twang2218/gitlab-ce-zh:9.4'

Gitlab安裝--jenkins安裝--(持續整合+自動化部署

參考地址:http://blog.51cto.com/12832314/2140304 Gitlab+jenkins持續整合+自動化部署 環境: centos6.5 一,gitlab安裝 0,java環境部署

CentOS7下的Django2整合部署三:Jenkins和GitLab安裝

Jenkins 安裝 JDK和Jenkins [[email protected] ~]# cd /usr/local/src/ [[email protected]-ct75211 src]# ll total 244436 -rw-r--r--. 1

centos7 安裝部署gitlab,及修改埠,查詢程序殺死程序

1. 安裝依賴軟體 yum -y install policycoreutils openssh-server openssh-clients postfix 2.設定postfix開機自啟,並啟動,postfix支援gitlab發信功能 systemctl ena

Docker實戰:使用Docker安裝部署Gitlab

配置Gitlab 剛剛啟動Gitlab的時候需要我們輸入一個密碼,這個密碼是管理員使用者的密碼。我們在登入那裡使用root作為使用者名稱,然後用剛剛設定的密碼,就可以以管理員身份登入Gitlab。 登入進去之後,點選右上角的齒輪圖示,即可進入到管理員頁面。在這裡我們可以設定很多東西。比如說,預設情況下每個使

CentOS 7 下 Gitlab 漢化安裝部署

        GitLab簡介 GitLab是利用Ruby On Rails開發的一個開源版本管理系統,實現了一個自託管的Git專案倉庫,是集程式碼託管,測試,部署於一體的開源git倉庫管理軟體,可通過web介面來進行訪問

centos7安裝部署gitlab伺服器

1. 安裝依賴軟體 yum -y install policycoreutils openssh-server openssh-clients postfix 2.設定postfix開機自啟,並啟動,postfix支援gitlab發信功能 systemctl ena

GitLab安裝部署

GitHub和GitLab的區別 相同點:二者都是基於web的Git倉庫,在很大程度上GitLab是仿照GitHub來做的,它們都提供了分享開源專案的平臺,為開發團隊提供了儲存、分享、釋出和合作開發專案的中心化雲端儲存的場所。 GitHub作為開原始碼庫及版

伺服器(centos7)上安裝部署gitlab伺服器 簡單案例

我這裡使用的是centos 7 64bit,我試過centos 6也是可以的!1. 安裝依賴軟體yum -y install policycoreutils openssh-server openssh-clients postfix2.設定postfix開機自啟,並啟動,postfix支援gitlab發信功

安裝部署gitlab伺服器以常見問題解決

GItlab的安裝 我這裡使用的是centos 7 64bit,我試過centos 6也是可以的! 1. 安裝依賴軟體 yum -y install policycoreutils openssh-server openssh-clients postfix 2.設定

gitlab-docker安裝部署(postgresql、redis分離)

file pub tlab emctl gre wiki issue postgre 郵件 GitLab是由GitLabInc.開發,使用MIT許可證的基於網絡的Git倉庫管理工具,且具有wiki和issue跟蹤功能。使用Git作為代碼管理工具,並在此基礎上搭建起來的web

fuel6.0安裝部署

信息 記錄 修改 ont pan compute spl auto 網絡配置   在經過一系列安裝openstack方式後,個人覺得fuel的安裝方式相對簡易,接下來記錄下安裝部署fuel6.0的過程。本教程適合想把fuel6.0部署後,雲主機需要連接外網的需求。   安裝

【原創 Spark動手實踐 1】Hadoop2.7.3安裝部署實際動手

dmi 遠程 nag proc host 一個 error img 連接 目錄: 第一部分:操作系統準備工作:   1. 安裝部署CentOS7.3 1611   2. CentOS7軟件安裝(net-tools, wget, vim等)   3. 更新CentOS

LNP 安裝部署

lnp一、安裝nginx1.安裝依賴包:yum install openssl openssl-devel pcre GeoIP perl-devel perl perl-ExtUtils-Embed GeoIP-devel libatomic libatomic_ops-devel2.安裝zlibtar -

Unity3D中tolua的“安裝部署和使用“教程

替換 部署 ref 比對 text asset gin 系統 .com 棄坑Cocos2d-x,轉戰Unity3D 考慮到項目一定會使用熱更,花了不少時間比對了lua的支持方案,最後定為tolua,原因不解釋。 俗話說,萬事開頭難,中間難,最後難……我反正是沒有找到如何安裝

hadoop分布式安裝部署具體視頻教程(網盤附配好環境的CentOS虛擬機文件/hadoop配置文件)

down hdf lan nag home 開機啟動 prop baidu ifcfg-eth 參考資源下載:http://pan.baidu.com/s/1ntwUij3視頻安裝教程:hadoop安裝.flvVirtualBox虛擬機:hadoop.part1-part