Centos7安裝gitlab11 學習筆記之基礎概念、部署安裝、權限管理、issue管理

1、基礎介紹

  一、簡介

    一個基於GIT的源碼託管解決方案
    基於rubyonrails開發
    集成了nginx postgreSQL redis sidekiq等組件html

  二、安裝要求 

      2g內存以上,有點佔內存,個人2g內存建立項目適合就報503錯誤,調大一點就正常了linux

    這裏使用centos7 64位nginx


  三、默認用戶


    root/5iveL!fe,正常部署好登錄回要求改密碼git


  四、經常使用命令


    gitlab-ctl status
    gitlab-ctl start
    gitlab-ctl stop
      gitlab-ctl restart
    gitlab-ctl tail nginx 查看日誌web


  五、組件


    nginx 靜態web
    gitlab-shell 用於處理git命令和修改
    gitlab-workhorse 輕量級的反向代理服務器
    logrotate 日誌文件管理工具
    postgresql 數據庫
    redis 緩存數據庫
    sidekiq 用於在後臺執行隊列任務(異步執行)、
    unicorn gitlab rails 應用是託管在這個服務器上面的redis


  六、目錄


    /var/opt/gitlab/git-data/repositories/root:庫默認存儲目錄
    /opt/gitlab:應用代碼和相應的依賴程序
    /var/opt/gitlab:gitlab-ctl reconfigure命令編譯後的應用數據和配置文件,不須要認爲修改配置
    /etc/gilab:配置文件目錄
    /var/log/gitlab:此目錄下存放了gitlab各個組件產生的日誌
    /var/opt/gilab/backups/:備份文件生成的目錄sql


  七、變動主配置文件


    gitlab-ctl reconfigure 重置配置文件
    gitlab-ctl show-config 驗證配置文件
    gitlab-ctl restart 重啓gitlab服務shell

  八、指定一個開發需求

 

 

2、安裝gitlab

  一、安裝依賴


    yum install curl policycoreutils openssh-server openssh-clients postfix數據庫

    systemctl enable sshd
    systemctl start sshd
    systemctl enable postfix
    systemctl start postfixvim

  二、rpm安裝


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

 1 [root@web1 ~]# rpm -ivh gitlab-ce-11.10.4-ce.0.el7.x86_64.rpm
 2 warning: gitlab-ce-11.10.4-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
 3 Preparing...                          ################################# [100%]
 4 Updating / installing...
 5    1:gitlab-ce-11.10.4-ce.0.el7       ################################# [100%]
 6 It looks like GitLab has not been configured yet; skipping the upgrade script.
 7 
 8        *.                  *.
 9       ***                 ***
10      *****               *****
11     .******             *******
12     ********            ********
13    ,,,,,,,,,***********,,,,,,,,,
14   ,,,,,,,,,,,*********,,,,,,,,,,,
15   .,,,,,,,,,,,*******,,,,,,,,,,,,
16       ,,,,,,,,,*****,,,,,,,,,.
17          ,,,,,,,****,,,,,,
18             .,,,***,,,,
19                 ,*,.
20   
21 
22 
23      _______ __  __          __
24     / ____(_) /_/ /   ____ _/ /_
25    / / __/ / __/ /   / __ `/ __ \
26   / /_/ / / /_/ /___/ /_/ / /_/ /
27   \____/_/\__/_____/\__,_/_.___/
28   
29 
30 Thank you for installing GitLab!
31 GitLab was unable to detect a valid hostname for your instance.
32 Please configure a URL for your GitLab instance by setting `external_url`
33 configuration in /etc/gitlab/gitlab.rb file.
34 Then, you can start your GitLab instance by running the following command:
35   sudo gitlab-ctl reconfigure
36 
37 For a comprehensive list of configuration options please see the Omnibus GitLab readme
38 https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
39 
40 [root@web1 ~]# 

     也能夠yum方式安裝,添加如下源便可

1 或者添加yum源
2 [root@web1 yum.repos.d]# vim gitlab-ce.repo
3 
4 [gitlab-ce]
5 name=gitlab-ce
6 baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever
7 gpgcheck=0
8 enabled=1
9 ~                                                    

 

  三、修改配置文件

 

    vim /etc/gilab/gitlab.rb

      external_url 'http://192.168.216.51'

   四、重置配置文件,gitlab就生效了

 

    gitlab-ctl reconfigure

   五、測試

    

    流程:修改密碼>root用戶登錄>登錄進入界面

 

    如今已經登錄進來了

3、Gitlab的權限管理

  首先建立對象流程

    建立組

    建立用戶

    建立項目

    受權項目用戶

 

    

  一、建立一個組

 

  點擊create

 

 

    下面向組裏面添加成員,這裏尚未建立用戶,開始建立用戶

 

 

  二、建立三個用戶

 

 

  點擊create建立,以此類推建立三個

 

    建立完用戶和組就能夠建立項目了

    pm 項目管理

    dev1 開發者

    dev2 開發者

    

  三、建立一個項目

 

    新建了一個proj1/test的庫

 

 

  

  四、添加ssh keys

 

    SSH KEY

      我的SSH KEY:建立ssh key >將公鑰導入用戶ssh key

      Deploy KEY:建立deploy key >將deploy key 導入gitlab並在項目中容許

 

   1)我的 SSH KEY

    複製公鑰,粘貼到,user setting>SSH Keys

 1 [root@web1 ~]# cd /root/.ssh/
 2 [root@web1 .ssh]# ll 
 3 total 4
 4 -rw-r--r-- 1 root root 519 Apr 18 17:28 known_hosts
 5 [root@web1 .ssh]# ssh-keygen
 6 Generating public/private rsa key pair.
 7 Enter file in which to save the key (/root/.ssh/id_rsa): 
 8 Enter passphrase (empty for no passphrase): 
 9 Enter same passphrase again: 
10 Your identification has been saved in /root/.ssh/id_rsa.
11 Your public key has been saved in /root/.ssh/id_rsa.pub.
12 The key fingerprint is:
13 SHA256:+QcJvTcCplOp7IlgcFpKVKIS5SsRfkKbQntbQ9eMPBE root@web1
14 The key's randomart image is:
15 +---[RSA 2048]----+
16 |o*o. ..E*        |
17 |*+= . .+ =       |
18 |*B+o o  B .      |
19 |+B+.o..= + o     |
20 |+ +.  = S = o    |
21 | o . o o . + .   |
22 |    . o   . .    |
23 |           .     |
24 |                 |
25 +----[SHA256]-----+
26 [root@web1 .ssh]# ll
27 total 12
28 -rw------- 1 root root 1679 May  8 16:40 id_rsa
29 -rw-r--r-- 1 root root  391 May  8 16:40 id_rsa.pub
30 -rw-r--r-- 1 root root  519 Apr 18 17:28 known_hosts
31 [root@web1 .ssh]# cat id_rsa.pub 
32 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4n1yMW2IoWIU0NtcaBzc3nn+M1mWeeOKi9DB8QrLDk3YtjO2WPZ1MpF+CYiH59NWlKRRypNpccfiS8aMeA5zHnR33gvuK/C6j40McXOs5q/2xjvlD19yk4nSMp46EBv2lIQqfonzOvlVpZbwihUce6I30vLRkDcBMmDuY4JQR+o/72jM8GCt/809YGvVMe3zESc6ava2uoGksataW9Cr3ORiMPilgwx+l00JHEsPxqZ6bNFsLGCPI4UONj2pRD9VR/Os3Zr80oKxM4B+1TZHExTQicQoBLdm53n8LZOgxItvywTPR40EZiro9FlWFBrHlJMJWHSAzXd8GdsLOILOb root@web1 33 [root@web1 .ssh]#

 

    首先須要兩個開發者設置密碼,登錄進去設置ssh key

 

 

    設置好密碼分別登錄

 

    linux 系統爲dev1

 

 

    windows爲dev2

    window,安裝git

      下載地址:https://gitforwindows.org/

    設置目錄,選一個目錄右鍵Git bash here

    

 

 

   五、測試效果

    測試如下,已經打通權限了,提示彷佛是個空庫

    linux測試

1 [root@web1 .ssh]# git clone git@192.168.216.51:proj1/test.git 2 Cloning into 'test'... 3 The authenticity of host '192.168.216.51 (192.168.216.51)' can't be established.
4 ECDSA key fingerprint is SHA256:kvAeuWOn6RFSXvl5qFIszQEx9gLizuZER+I4VJkpAso. 5 ECDSA key fingerprint is MD5:b7:ef:e0:3c:8f:97:01:c2:5c:9a:2e:fc:4d:e2:99:83. 6 Are you sure you want to continue connecting (yes/no)? yes 7 Warning: Permanently added '192.168.216.51' (ECDSA) to the list of known hosts. 8 warning: You appear to have cloned an empty repository.

    

    windows測試

 

 

   

4、Gitlab的issue管理

    建立milestone

    建立issue

    建立分支

    合併分支

    Todos

 

    Fix #issue_id

    Close #issue_id

 

  一、第一步建立Milestone

    圖示以下:

 

 

   

 

 

 

 

 

 

   二、建立issue

    以下圖示:

 

 

 

 

 

 

 

 

 

 

     

 

    以此類推,建立一共四個issue

 

  三、dev1 建立分支,開發首頁

 1 [root@web1 test]# ll 
 2 total 16
 3 -rw-r--r-- 1 root root  8 May  7 20:36 123.html
 4 -rw-r--r-- 1 root root 12 May  7 20:39 456.html
 5 -rw-r--r-- 1 root root 25 May  7 20:25 index.html
 6 -rw-r--r-- 1 root root 14 May  7 20:36 news.html
 7 drwxr-xr-x 3 root root 32 May  8 18:13 test
 8 [root@web1 test]# cd test
 9 [root@web1 test]# ll 
10 total 4
11 -rw-r--r-- 1 root root 6 May  8 18:13 readme
12 [root@web1 test]# git checkout -b shouye 13 Switched to a new branch 'shouye'
14 [root@web1 test]# git status 15 # On branch shouye
16 nothing to commit, working directory clean
17 [root@web1 test]# echo "<h1>welcom to web1</h1>" >index.html 18 [root@web1 test]# ll 
19 total 8
20 -rw-r--r-- 1 root root 24 May  9 11:58 index.html
21 -rw-r--r-- 1 root root  6 May  8 18:13 readme27 [root@web1 test]# git add . 28 [root@web1 test]# git commit -m "shouye"
29 [shouye 0a6efde] shouye
30  1 file changed, 1 insertion(+)
31  create mode 100644 index.html
32 [root@web1 test]# git push origin shouye 33 Counting objects: 4, done.
34 Delta compression using up to 4 threads.
35 Compressing objects: 100% (2/2), done.
36 Writing objects: 100% (3/3), 295 bytes | 0 bytes/s, done.
37 Total 3 (delta 0), reused 0 (delta 0)
38 remote: 
39 remote: To create a merge request for shouye, visit:
40 remote:   http://192.168.216.51/proj1/test/merge_requests/new?merge_request%5Bsource_branch%5D=shouye
41 remote: 
42 To git@192.168.216.51:proj1/test.git
43 * [new branch] shouye -> shouye 44 [root@web1 test]# 

 

    dev1登錄gitlab  web界面,點擊repository,能夠看到一個push上來的代碼文件

 

 

  四、合併到主幹

 

    dev1登錄gitlab  web界面

    點擊repository--》create merge request--》填寫相關信息交給pm處理--》點擊sumbmit merge request

  

 

    填上相關信息,這個合併須要pm來作,dev1提交申請

 

 

     提交後的狀態以下:

 

 

    

   pm登錄gitlab web界面

  能夠看到一個merge requests--》點擊旁邊的todos---》檢查代碼確認---》點擊merge

     限制能夠看到是open狀態,檢查沒有問題就點merge

 

 

 

 

     

  點擊branches 能夠看到merged

 

 

    切換dev1帳戶,查看並點擊done完成

 

 

    切換pm,點擊milestones能夠看到整個進度

 

     接着點擊下面issues看看

 

     仍是open狀態,不該該啊,應該完成的就不是open狀態

 

    接下來須要點擊這個完成的issue,而後點擊close issue 就能夠了

 

 

      每次完成還須要點close有點麻煩,接下來看看如何解決

 

      切換到主幹pull如下,而後能夠後面能夠試試dev1   切換到master能不能上傳,這裏就不演示了,是不能上傳的,由於dev1的權限是開發者

 1 [root@web1 test]# git checkout master  2 Switched to branch 'master'
 3 [root@web1 test]# ll 
 4 total 4
 5 -rw-r--r-- 1 root root 6 May  8 18:13 readme
 6 [root@web1 test]# git pull  7 remote: Enumerating objects: 1, done.
 8 remote: Counting objects: 100% (1/1), done.
 9 remote: Total 1 (delta 0), reused 0 (delta 0)
10 Unpacking objects: 100% (1/1), done.
11 From 192.168.216.51:proj1/test
12    7ec452a..b19d103  master     -> origin/master
13 Updating 7ec452a..b19d103
14 Fast-forward
15  index.html | 1 +
16  1 file changed, 1 insertion(+)
17  create mode 100644 index.html
18 [root@web1 test]# ll 19 total 8
20 -rw-r--r-- 1 root root 24 May  9 15:23 index.html
21 -rw-r--r-- 1 root root  6 May  8 18:13 readme
22 [root@web1 test]#

     

    建立第2個分支新聞,news,並上傳

 

 1 [root@web1 test]# git checkout -b news  2 Switched to a new branch 'news'
 3 [root@web1 test]# echo "news " >news.html  9 [root@web1 test]# git add . 10 [root@web1 test]# git commit -m "close #2"
11 [news 9503883] close #2
12  1 file changed, 1 insertion(+)
13  create mode 100644 news.html
14 [root@web1 test]# git push origin news
15 Counting objects: 4, done.
16 Delta compression using up to 4 threads.
17 Compressing objects: 100% (2/2), done.
18 Writing objects: 100% (3/3), 309 bytes | 0 bytes/s, done.
19 Total 3 (delta 0), reused 0 (delta 0)
20 remote: 
21 remote: To create a merge request for news, visit:
22 remote:   http://192.168.216.51/proj1/test/merge_requests/new?merge_request%5Bsource_branch%5D=news
23 remote: 
24 To git@192.168.216.51:proj1/test.git
25  * [new branch]      news -> news
26 [root@web1 test]# 

 

注意:

git commit -m "close #2"的意義在於添加標籤close #2 上一部最後須要點擊close issue,這裏添加close標籤就不用點了,會自動生效。

 gitlab 上面的操做和第一個分支首頁同樣,只是最後不須要在去點close,這是由於添加了close #2 的註釋

 

 

轉載請註明出處:http://www.javashuo.com/article/p-ermgxgsg-he.html 

相關文章
相關標籤/搜索