Gitlab--安裝及漢化


簡介

gitlab是一個利用 Ruby on Rails 開發的開源應用程序,實現一個自托管的Git 項目倉庫,可通過Web界面迚行訪問公開的戒者私人項目。
Ruby on Rails 是一個可以使你開發、部署、維護 web 應用程序變得簡單的框架。
GitLab 擁有與Github 類似的功能,能夠瀏覽源代碼,管理缺陷和注釋。可以管理團隊對倉庫的訪問,
它非常易於瀏覽提交過的版本並提供一個文件歷史庫。它還提供一個代碼片段收集功能可以輕松實現代碼
復用,便於日后有需要的時候迚行查找。
GitLab 中文網:https://www.gitlab.cc/installation/#centos-7

gitlab和github的區別

相同點: 二者都是基於web 的Git 倉庫,在很大程度上GitLab 是仿照GitHub 來做的,它們都提供了分享開源項目的平台,為開發團隊提供了存儲、分享、發布和合作開發項目的中心化於存儲的場所。
不同點:
1、GitHub 如果要使用私有倉庫,是需要付費的。GitLab 可以在上面創建私人的免費倉庫。
2、GitLab 讓開發團隊對他們的代碼倉庫擁有更多的控制,相比於GitHub,它有不少的特色:
     允許免費設置倉庫權限;
     允許用戶選擇分享一個project 的部分代碼;
     允許用戶設置project 的獲取權限,進一步的提升安全性;
     可以設置獲取到團隊整體的改進進度;通過innersourcing 讓不在權限范圍內的人訪問不到該資源。
總結:從代碼私有性方面來看,有時公司並不希望員工獲取到全部的代碼,這個時候GitLab 無疑是更好的選擇。但對於開源項目而言,GitHub 依然是代碼托管的首選。

git 相關概念:
git 是一種版本控制系統,是一個命令,是一種工具
gitlib 是用於實現git 功能的開發庫
github 是一個基於git 實現的在線代碼托管倉庫,包含一個網站界面,向虧聯網開放
gitlab 是一個基於git 實現的在線代碼倉庫托管軟件,一般用亍在企業內部網絡搭建git 私服
注: gitlab-ce 社區版 ; gitlab-ee 是企業版,收費

安裝

溫馨提示:
本次gitlab的環境是:
操作系統:centos7
主機名:gitlab
IP: 192.168.192.131
內存: 8G(這里要重要的提示一下,內存最少4G,不然會出現訪問超時的錯誤,譬如:502)
防火牆: 關閉狀態(這里可以開,可以不開,下面有開防火牆的設置方法)

gitlab rpm安裝包百度雲下載:https://pan.baidu.com/s/1a57PWAvCQcxMBI2qwfyR2g

gitlab 漢化包百度雲下載:https://pan.baidu.com/s/1DVZXrfH08JRYNuBw6zvLJQ

百度雲鏈接永久有效,如果鏈接失效可以聯系我

安裝依賴

安裝依賴包:

[root@gitlab ~]# yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python

這里安裝了postfix,主要的原因是因為我們要使用gitlab的發郵件的功能,先啟動一下postfix
[root@gitlab ~]# systemctl start postfix
Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.
[root@gitlab ~]# systemctl status postfix.service
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2019-01-04 15:38:30 CST; 17s ago
  Process: 10951 ExecStart=/usr/sbin/postfix start (code=exited, status=1/FAILURE)
  Process: 10948 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  Process: 10943 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=75)

Jan 04 15:38:28 gitlab systemd[1]: Starting Postfix Mail Transport Agent...
Jan 04 15:38:28 gitlab aliasesdb[10943]: /usr/sbin/postconf: fatal: parameter inet_interfaces: no local interface found for ::1
Jan 04 15:38:29 gitlab aliasesdb[10943]: newaliases: fatal: parameter inet_interfaces: no local interface found for ::1
Jan 04 15:38:29 gitlab postfix[10951]: fatal: parameter inet_interfaces: no local interface found for ::1
Jan 04 15:38:30 gitlab systemd[1]: postfix.service: control process exited, code=exited status=1
Jan 04 15:38:30 gitlab systemd[1]: Failed to start Postfix Mail Transport Agent.
Jan 04 15:38:30 gitlab systemd[1]: Unit postfix.service entered failed state.
Jan 04 15:38:30 gitlab systemd[1]: postfix.service failed.

在啟動的時候出現了上面的報錯,原因是因為: /etc/postfix/main.cf 中的 inet_interfaces = localhost 把這一個參數改為: inet_interfaces = all
[root@gitlab ~]# vim /etc/postfix/main.cf
原參數:
inet_interfaces = localhost
改為:
inet_interfaces = all
保存,然后在重啟
[root@gitlab ~]# systemctl start postfix

yum安裝

yum 安裝gitlab:

使用這種方式安裝的gitlab永遠都是最新版的,也會比較慢
[root@gitlab ~]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
[root@gitlab ~]# yum -y install gitlab-ce

rpm安裝

rpm 安裝gitlab:

這里采用了 清華大學開源軟件鏡像站 下載並安裝(速度快),使用的是gitlab-ce-11.6.1的版本

下載gitlab安裝包
這里采用了 清華大學開源軟件鏡像站(https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/) 下載並安裝(速度快),使用的是gitlab-ce-11.6.1的版本

下載gitlab安裝包(沒有wget命令請自行使用yum -y install wget 安裝)
[root@gitlab ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.6.1-ce.0.el7.x86_64.rpm

安裝gitlab
[root@gitlab ~]# rpm -ivh gitlab-ce-11.6.1-ce.0.el7.x86_64.rpm 

這里說一下rpm安裝gitlab安裝后的目錄和文件的作用:
/opt/gitlab/                # gitlab的程序安裝目錄
/etc/gitlab/gitlab.rb       # gitlab的配置文件
/var/opt/gitlab             # gitlab目錄數據目錄
/var/opt/gitlab/git-data    # 存放倉庫數據
/var/log/gitlab/            # 日志地址
/var/opt/gitlab/            # 各服務地址

gitlab管理命令

gitlab‐ctl reconfigure      # 更改配置文件后需重新配置
gitlab‐ctl status           # 查看目前gitlab所有服務運維狀態
gitlab‐ctl stop             # 停止gitlab服務
gitlab‐ctl stop nginx       # 單獨停止某個服務
gitlab‐ctl tail             # 查看所有服務的日志

配置

gitlab配置

安裝完成后,修改gitlab的配置文件(在/etc/gitlab/gitlab.rb)

更改URL地址為本地IP地址:
原參數:
external_url 'http://gitlab.example.com'
改為:
external_url 'http://192.168.192.131'

配置gitlab並啟動(配置完成會自動啟動)
[root@gitlab ~]# gitlab-ctl reconfigure

查看啟動狀態:
[root@gitlab ~]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      11178/master        
tcp        0      0 0.0.0.0:8060            0.0.0.0:*               LISTEN      15433/nginx: master 
tcp        0      0 127.0.0.1:9121          0.0.0.0:*               LISTEN      15622/redis_exporte 
tcp        0      0 127.0.0.1:9090          0.0.0.0:*               LISTEN      15472/prometheus    
tcp        0      0 127.0.0.1:9187          0.0.0.0:*               LISTEN      15450/postgres_expo 
tcp        0      0 127.0.0.1:9093          0.0.0.0:*               LISTEN      15284/alertmanager  
tcp        0      0 127.0.0.1:9100          0.0.0.0:*               LISTEN      15442/node_exporter 
tcp        0      0 127.0.0.1:9229          0.0.0.0:*               LISTEN      15339/gitlab-workho 
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      15738/unicorn maste 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      15433/nginx: master 
tcp        0      0 127.0.0.1:9168          0.0.0.0:*               LISTEN      15329/puma 3.12.0 ( 
tcp        0      0 127.0.0.1:8082          0.0.0.0:*               LISTEN      15706/sidekiq 5.2.3 
tcp        0      0 127.0.0.1:9236          0.0.0.0:*               LISTEN      15302/gitaly        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1005/sshd           
tcp6       0      0 :::25                   :::*                    LISTEN      11178/master        
tcp6       0      0 :::9094                 :::*                    LISTEN      15284/alertmanager  
tcp6       0      0 :::22                   :::*                    LISTEN      1005/sshd           
udp        0      0 127.0.0.1:323           0.0.0.0:*                           690/chronyd         
udp        0      0 0.0.0.0:56458           0.0.0.0:*                           11209/local         
udp        0      0 0.0.0.0:68              0.0.0.0:*                           759/dhclient        
udp6       0      0 ::1:323                 :::*                                690/chronyd         
udp6       0      0 :::9094                 :::*                                15284/alertmanager  

看到一堆服務,但是那個是gitlab相關的呢,使用下面命令查看:
[root@gitlab ~]# gitlab-ctl status
run: alertmanager: (pid 15284) 2231s; run: log: (pid 13802) 2409s
run: gitaly: (pid 15302) 2231s; run: log: (pid 13583) 2413s
run: gitlab-monitor: (pid 15329) 2230s; run: log: (pid 13703) 2412s
run: gitlab-workhorse: (pid 15339) 2230s; run: log: (pid 13526) 2415s
run: logrotate: (pid 15354) 2230s; run: log: (pid 13543) 2414s
run: nginx: (pid 15433) 2229s; run: log: (pid 13534) 2415s
run: node-exporter: (pid 15442) 2229s; run: log: (pid 13606) 2412s
run: postgres-exporter: (pid 15450) 2228s; run: log: (pid 13824) 2408s
run: postgresql: (pid 15460) 2228s; run: log: (pid 13485) 2417s
run: prometheus: (pid 15472) 2228s; run: log: (pid 13769) 2409s
run: redis: (pid 15485) 2227s; run: log: (pid 13477) 2417s
run: redis-exporter: (pid 15622) 2227s; run: log: (pid 13729) 2411s
run: sidekiq: (pid 15706) 2202s; run: log: (pid 13503) 2416s
run: unicorn: (pid 15719) 2201s; run: log: (pid 13494) 2417s

上面發現配置個gitlab竟然啟動了一堆的東西,什么鬼。。。。
其實這些啟動的都是gitlab服務需要的組件服務

Gitlab的服務有很多的組件構成的,如:
nginx:              靜態web服務器
gitlab‐workhorse:   輕量級的反向代理服務器
logrotate:         日志文件管理工具
postgresql:        數據庫
redis:             緩存數據庫
sidekiq:           用於在后台執行隊列任務(異步執行),(Ruby)
unicorn:           An HTTP server for Rack applications,GitLab Rails應用是托管在這個服務器上面的。(RubyWeb Server,主要使用Ruby編寫)

 防火牆設置

防火牆設置(防火牆也會引起502的錯誤)
關閉防火牆:
[root@gitlab ~]# systemctl stop firewalld.service
[root@gitlab ~]# iptables -F

設置防火牆:
[root@gitlab ~]# firewall-cmd --permanent --add-service=http
[root@gitlab ~]# systemctl reload firewalld

測試

使用瀏覽器訪問服務器IP(http://192.168.192.131)

出現上面的web界面說明安裝成功了

但是竟然是英文的,對英文好的朋友當然最喜歡了,可是我這英語呆很苦惱呀,還好有漢化的方法,預知漢化如何,請看下面,哈哈。。。。。。

漢化

說明:gitlab中文社區版的項目,v7-v8.8是由Larry Li發起的"GitLab 中文社區版項目"(https://gitlab.com/larryli/gitlab)
    從 v8.9之后,@xhang開始繼續該漢化項目(https://gitlab.com/xhang/gitlab)

具體漢化方式:

1) 停止gitlab服務
[root@gitlab ~]# gitlab-ctl stop

2) 安裝git命令(有的可以不在次安裝)
[root@gitlab ~]# yum -y install git

3) git clone 漢化包並打補丁
[root@gitlab ~]# git clone https://gitlab.com/xhang/gitlab.git

這里下載的速度會出現很慢的情況,下面提供了百度雲盤的下載
百度雲下載地址: https://pan.baidu.com/s/1DVZXrfH08JRYNuBw6zvLJQ (永久有效,如果鏈接失效可以聯系我)
在百度雲上下載后,上傳到服務器上然后解壓在執行下面的命令

[root@gitlab ~]# cd gitlab

# 比較漢化標簽和原標簽,導出 patch 用的 diff 文件到/root下 
[root@gitlab gitlab]# git diff v11.5.6 v11.5.6-zh > ../11.5.6-zh.diff

# 將11.5.6-zh.diff作為補丁更新到gitlab中 
# 這里需要用到patch命令,需要安裝一下
[root@gitlab gitlab]# yum -y install patch
[root@gitlab gitlab]# patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /root/11.5.6-zh.diff

溫馨提示: 這里回車后,會提示是否要覆蓋文件,一路回車就行

# 啟動gitlab
[root@gitlab ~]# gitlab-ctl start

溫馨提示: 啟動后稍等1-2分鍾在訪問web,不然會出現502的錯誤

502錯誤如下圖:

 

查看是否漢化成功了:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM