gitlba的搭建與使用

 實驗環境繼續使用git的實驗環境,詳情請點擊鏈接https://www.cnblogs.com/cash-su/p/10131632.html

 

首先給服務器作一個本機的映射

[root@git1 ~]# echo "git1 127.0.0.1" >> /etc/hosts

 

gitlab安裝包下載

[root@git1 ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.2.3-ce.0.el7.x86_64.rpm

 


而後安裝包

[root@git1 ~]# yum -y localinstall gitlab-ce-11.2.3-ce.0.el7.x86_64.rpm #(這個方法是yum本地安裝rpm包,有依賴yum會本身找,不用本身安裝依賴包)

 


從新初始化gitlab

[root@git1 ~]# gitlab-ctl reconfigure

 


看下gitlab狀態

[root@git1 ~]# gitlab-ctl status
run: alertmanager: (pid 17423) 113s; run: log: (pid 17430) 112s
run: gitaly: (pid 17366) 115s; run: log: (pid 17376) 115s
run: gitlab-monitor: (pid 17394) 114s; run: log: (pid 17397) 114s
run: gitlab-workhorse: (pid 17352) 116s; run: log: (pid 17357) 115s
run: logrotate: (pid 16626) 432s; run: log: (pid 17362) 115s
run: nginx: (pid 16578) 438s; run: log: (pid 17361) 115s
run: node-exporter: (pid 16782) 414s; run: log: (pid 17379) 115s
run: postgres-exporter: (pid 17437) 112s; run: log: (pid 17446) 112s
run: postgresql: (pid 16105) 527s; run: log: (pid 17341) 116s
run: prometheus: (pid 17405) 113s; run: log: (pid 17413) 113s
run: redis: (pid 15958) 538s; run: log: (pid 17342) 116s
run: redis-exporter: (pid 16986) 280s; run: log: (pid 17396) 114s
run: sidekiq: (pid 16458) 450s; run: log: (pid 17344) 116s
run: unicorn: (pid 16391) 456s; run: log: (pid 17343) 116s

 

看gitlab的版本號

[root@git1 ~]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION 
11.2.3

 

咱們開始訪問私人倉庫地址就是服務器地址,默認的是80端口

 

 而後登錄gitlabhtml

登錄之後的加密node

打中文補丁

[root@git1 ~]# tar xf gitlab-11-2-stable-zh.tar.gz
查看補丁的版本號,須要補丁和gitlab的版本號一致
[root@git1 ~]# ls 
anaconda-ks.cfg gitlab-11-2-stable-zh.tar.gz Python-3.5.2.tgz
apache-maven-3.5.0-bin.tar.gz gitlab-ce-11.2.3-ce.0.el7.x86_64.rpm solo.tar.gz
apache-tomcat-8.5.31.tar.gz jdk-8u171-linux-x64.tar.gz wordpress-4.9.4-zh_CN.tar.gz
git-2.9.5.tar.gz jenkins-2.138.1-1.1.noarch.rpm
gitlab-11-2-stable-zh nexus-3.13.0-01-unix.tar.gz
[root@git1 ~]# cat gitlab-11-2-stable-zh/VERSION 
11.2.3
備份英文版的
[root@git1 ~]# cp -r /opt/gitlab/embedded/service/gitlab-rails{,.bak}
而後用中文補丁覆蓋剛纔的目錄
[root@git1 ~]# /bin/cp -rf gitlab-11-2-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/
複製完了重編譯,重啓
[root@git1 ~]# gitlab-ctl reconfigure
[root@git1 ~]# gitlab-ctl restart
ok: run: alertmanager: (pid 21626) 0s
ok: run: gitaly: (pid 21635) 0s
ok: run: gitlab-monitor: (pid 21645) 0s
ok: run: gitlab-workhorse: (pid 21649) 1s
ok: run: logrotate: (pid 21658) 0s
ok: run: nginx: (pid 21666) 0s
ok: run: node-exporter: (pid 21671) 1s
ok: run: postgres-exporter: (pid 21686) 0s
ok: run: postgresql: (pid 21702) 0s
ok: run: prometheus: (pid 21706) 0s
ok: run: redis: (pid 21717) 1s
ok: run: redis-exporter: (pid 21724) 0s
ok: run: sidekiq: (pid 21814) 0s
ok: run: unicorn: (pid 21829) 0s

 

補丁完了的樣子

建立一個項目linux

 

 

本身設定http的url和ssh的鏈接
修改gitlab的配置文件/etc/gitlab/gitlab.rb

 

[root@git1 ~]# vim /etc/gitlab/gitlab.rb

 

 

 

修改完了重編譯,重啓

[root@git1 ~]# gitlab-ctl reconfigure
[root@git1 ~]# gitlab-ctl restart

ok: run: alertmanager: (pid 28033) 0s
ok: run: gitaly: (pid 28045) 0s
ok: run: gitlab-monitor: (pid 28061) 0s
ok: run: gitlab-workhorse: (pid 28064) 0s
ok: run: logrotate: (pid 28073) 0s
ok: run: nginx: (pid 28075) 1s
ok: run: node-exporter: (pid 28084) 0s
ok: run: postgres-exporter: (pid 28089) 0s
ok: run: postgresql: (pid 28102) 0s
ok: run: prometheus: (pid 28126) 0s
ok: run: redis: (pid 28134) 1s
ok: run: redis-exporter: (pid 28221) 0s
ok: run: sidekiq: (pid 28364) 0s
ok: run: unicorn: (pid 28391) 0snginx

而後在從新登錄瀏覽器ip加端口號

測試推送

切換到git服務器上在工做區裏鏡像添加

[root@git mycode]# git remote add test1 http://192.168.200.148:8888/root/test.git

開始推送

[root@git mycode]# git push test1 master
Username for 'http://192.168.200.148:8888': root
Password for 'http://root@192.168.200.148:8888': 
Counting objects: 9, done.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (9/9), 679 bytes | 0 bytes/s, done.
Total 9 (delta 0), reused 0 (delta 0)
To http://192.168.200.148:8888/root/test.git
 * [new branch]      master -> master

推標籤(前提得有標籤,創建標籤和使用標籤詳情請看git隨筆https://www.cnblogs.com/cash-su/p/10131632.html)

[root@git mycode]# git push -u test1  v1.0
Username for 'http://192.168.200.148:8888': root
Password for 'http://root@192.168.200.148:8888': 
Total 0 (delta 0), reused 0 (delta 0)
To http://192.168.200.148:8888/root/test.git
 * [new tag]         v1.0 -> v1.0

克隆到本地

[root@git mycode]# git clone http://192.168.200.148:8888/root/test.git v1.0
Cloning into 'v1.0'...
Username for 'http://192.168.200.148:8888': root
Password for 'http://root@192.168.200.148:8888': 
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 9 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (9/9), done.
Checking connectivity... done.

克隆分支到本地

首先創建一個分支

[root@git mycode]# git branch dev
[root@git mycode]# git checkout dev
Switched to branch 'dev'
[root@git mycode]# git branch
* dev
  master
[root@git mycode]# touch dix.txt
[root@git mycode]# ls 
dix.txt  exe.txt  test.txt  v1.0
[root@git mycode]# git add *
[root@git mycode]# git commit -m "分支第一次提交"
[dev 08afd32] 分支第一次提交
 2 files changed, 1 insertion(+)
 create mode 100644 dix.txt
 create mode 160000 v1.0
[root@git mycode]# git push -u test1 dev
Username for 'http://192.168.200.148:8888': root
Password for 'http://root@192.168.200.148:8888': 
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 351 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: 
remote: To create a merge request for dev, visit:
remote:   http://192.168.200.148:8888/root/test/merge_requests/new?merge_request%5Bsource_branch%5D=dev
remote: 
To http://192.168.200.148:8888/root/test.git
 * [new branch]      dev -> dev
Branch dev set up to track remote branch dev from test1.

 

由於是在master主分支創建的分支,因此以前操做的都會有記錄

如今在克隆分支

[root@git /]# mkdir -p /test
[root@git /]# cd /test/
[root@git test]# git clone -b dev http://192.168.200.148:8888/root/test.git
Cloning into 'test'...
Username for 'http://192.168.200.148:8888': root
Password for 'http://root@192.168.200.148:8888': 
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 11 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (11/11), done.
Checking connectivity... done.
[root@git test]# ls 
test
[root@git test]# cd test/
[root@git test]# ls 
dix.txt  exe.txt  test.txt  v1.0

利用ssh鏈接與克隆

生成祕鑰對
[root@git test]# ssh-keygen -t rsa -C '491537692@qq.com' Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. 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: SHA256:7Niv6b5+dyQFTSeTwv+/AjmtsyIvN+lNFGR+Q+sln2c 491537692@qq.com The key's randomart image is: +---[RSA 2048]----+ | + ++..| | + = ++ | | o O . | | . + B .| | S .oo +E| | + .+....o| | . o ..+o .| | o B+o... .| | +&*++o....| +----[SHA256]-----+

 

 而後在瀏覽器上將公鑰內容添加上去

[root@git test]# cd ~/.ssh/
[root@git .ssh]# ls 
id_rsa  id_rsa.pub  known_hosts
[root@git .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDW/BG41541Ao7ZYEc1wWhIq65VbP66FE8W7RJFZ1pL9LtL9/Ey0V4g7YBJo3mExNDgaFrR+5/SPYt6BAvmDjbmiBJ3FOoKz+rgV73RBRG2WdV4TSKWDy5JVe4k09jgbXzZyfZZUSJHvbitEArjqX6X+ZJrRNWmOCFHAOE+iwwUyArYMwFFM+ckvlGxuN4ztbezLXZPlAnLzB2e84U1NVD5lGQoVmZb7FMZRXq661/+Mt9WTAx0MAW5PSUWicWycztaZnF4mkVwLTWxFug5M7DE8wCmt2S/YprQKgoFuCDI3gvK5jTXtLO4okfaNnOjI00ITjdCOaYfjIq4FdyQ7C1l 491537692@qq.com

 

複製ssh的鏈接

 

 克隆成功

[root@git .ssh]# cd ~
[root@git ~]# cd /test/
[root@git test]# ls 
[root@git test]# git clone -b dev git@192.168.200.148:root/test.git
Cloning into 'test'...
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 11 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (11/11), done.
Checking connectivity... done.
[root@git test]# ls 
test
[root@git test]# cd test/
[root@git test]# ls 
dix.txt  exe.txt  test.txt  v1.0

建立郵件,使用與分支合併的時候

首先開啓郵箱的smtp功能

開啓gitlab的postfix服務須要切換服務器到git1

 

[root@git1 ~]# systemctl start postfix
[root@git1 ~]# systemctl enable postfix
[root@git1 ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2018-12-16 15:04:16 CST; 2 days ago
 Main PID: 1266 (master)
   CGroup: /system.slice/postfix.service
           ├─ 1266 /usr/libexec/postfix/master -w
           ├─ 1268 qmgr -l -t unix -u
           └─27691 pickup -l -t unix -u

Dec 18 17:44:07 git1 postfix/pickup[27691]: 8610411BD74C: uid=997 from=<gitlab@192.168.200.148>
Dec 18 17:44:07 git1 postfix/cleanup[33642]: 8610411BD74C: message-id=<5c18c1668d06d_6ecc3fa4cd9a16ac4807...ail>
Dec 18 17:44:07 git1 postfix/qmgr[1268]: 8610411BD74C: from=<gitlab@192.168.200.148>, size=2746, nrcpt=1...tive)
Dec 18 17:44:08 git1 postfix/smtp[33644]: connect to example.com[2606:2800:220:1:248:1893:25c8:1946]:25: ...able
Dec 18 17:44:29 git1 postfix/smtp[33644]: connect to example.com[93.184.216.34]:25: Connection refused
Dec 18 17:44:29 git1 postfix/smtp[33644]: 8610411BD74C: to=<admin@example.com>, relay=none, delay=22, del...sed)
Dec 18 17:50:53 git1 postfix/qmgr[1268]: 8610411BD74C: from=<gitlab@192.168.200.148>, size=2746, nrcpt=1...tive)
Dec 18 17:50:53 git1 postfix/smtp[34188]: connect to example.com[2606:2800:220:1:248:1893:25c8:1946]:25: ...able
Dec 18 17:51:14 git1 postfix/smtp[34188]: connect to example.com[93.184.216.34]:25: Connection refused
Dec 18 17:51:14 git1 postfix/smtp[34188]: 8610411BD74C: to=<admin@example.com>, relay=none, delay=427, de...sed)
Hint: Some lines were ellipsized, use -l to show in 

修改gitlab的配置文件

[root@git1 ~]# cp -r /etc/gitlab/gitlab.rb{,.bak}
[root@git1 ~]# vim /etc/gitlab/gitlab.rb

 

 

 

 

修改完了重編譯,重啓

[root@git1 ~]# gitlab-ctl reconfigure
[root@git1 ~]# gitlab-ctl restart

進入郵件控制檯

[root@git1 ~]# gitlab-rails console

-------------------------------------------------------------------------------------
GitLab: 11.2.3 (06cbee3)
GitLab Shell: 8.1.1
postgresql: 9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)git

irb(main):001:0> Notify.test_email('493115250@qq.com','this is title','hello').deliver_now程序員

Notify#test_email: processed outbound mail in 540.8msredis

Sent mail to 493115250@qq.com (3359.6ms)
Date: Tue, 18 Dec 2018 18:34:20 +0800
From: GitLab <493115250@qq.com>
Reply-To: GitLab <noreply@192.168.200.148>
To: 493115250@qq.com
Message-ID: <5c18cd2c44d7a_96593f9fb05daf7c72fe@git1.mail>
Subject: this is title
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Auto-Submitted: auto-generated
X-Auto-Response-Suppress: Allsql

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><p>hello</p></body></html>apache

=> #<Mail::Message:69954716508780, Multipart: false, Headers: <Date: Tue, 18 Dec 2018 18:34:20 +0800>, <From: GitLab <493115250@qq.com>>, <Reply-To: GitLab <noreply@192.168.200.148>>, <To: 493115250@qq.com>, <Message-ID: <5c18cd2c44d7a_96593f9fb05daf7c72fe@git1.mail>>, <Subject: this is title>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>, <Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>>
irb(main):002:0> vim

提別說明Notify.test_email('收件人','標題','內容').deliver_now

 

 

 

註冊帳號

 

 

 

開啓註冊時郵箱驗證功能

 

 

註冊時會提示郵箱驗證

 

 

 

 用戶名時su,當時打錯了

 

 

建立組用戶切換root

 

 

gitlab的權限
guest訪客,只能發表評論,不能讀寫
reporter報告者
只能克隆,不能提交代碼,產品測試用的
developer開發人員
能夠進行代碼的讀寫,普通程序員用的
master主程序員
能夠添加項目成員,添加標籤,建立和保護分支產品經理用的
owner全部者
有全部的權限,通常不用

 

 

添加成功之後會自動發郵件給成員

 

 

給建立一個項目

相關文章
相關標籤/搜索