天天看點

centos7.x搭建gitlab9.2.2

1、介紹

GitLab 是一個用于倉庫管理系統的開源項目。

2、官方硬體介紹配置

CPU

1 核心CPU最多支援100個使用者,所有的workers和背景任務都在同一個核心工作這将導緻GitLab服務響應會有點緩慢。

2 核心 支援500使用者,這也是官方推薦的最低标準。

4 核心支援2,000使用者。

8 核心支援5,000使用者。

16 核心支援10,000使用者。

32 核心支援20,000使用者。

64 核心支援40,000使用者。

如果想支援更多使用者,可以使用 叢集式架構

Memory

安裝使用GitLab需要至少4GB可用記憶體(RAM + Swap)! 由于作業系統和其他正在運作的應用也會使用記憶體, 是以安裝GitLab前一定要注意目前伺服器至少有4GB的可用記憶體. 少于4GB記憶體會導緻在reconfigure的時候出現各種詭異的問題, 而且在使用過程中也經常會出現500錯誤.

最後官方最後的提醒:

1GB 實體記憶體 + 3GB 交換分區 是最低的要求,但我們 強烈反對 使用這樣的配置。 檢視下面unicorn worker章節擷取更多建議。

2GB 實體記憶體 + 2GB 交換分區 支援100使用者,但服務響應會很慢。

4GB 實體記憶體 支援100使用者,也是 官方推薦 的配置。

8GB 實體記憶體 支援 1,000 使用者。

16GB 實體記憶體 支援 2,000 使用者。

32GB 實體記憶體 支援 4,000 使用者。

64GB 實體記憶體 支援 8,000 使用者。

128GB 實體記憶體 支援 16,000 使用者。

256GB 實體記憶體 支援 32,000 使用者。

關于官網的unicorn我并未詳細查閱,都是英文,看起來非常吃力!

3、GitLab服務構成

GitLab由以下服務構成:

nginx:靜态Web伺服器

gitlab-shell:用于處理Git指令和修改authorized keys清單

gitlab-workhorse:輕量級的反向代理伺服器

logrotate:日志檔案管理工具

postgresql:資料庫

redis:緩存資料庫

sidekiq:用于在背景執行隊列任務(異步執行)

unicorn:An HTTP server for Rack applications,GitLab Rails應用是托管在這個伺服器上面的。

經我統計,一共8個元件。

4、官方的推薦安裝方式

<code>1、安裝配置依賴項</code>

<code>如想使用Postfix來發送郵件,在安裝期間請選擇</code><code>'Internet Site'</code><code>. 您也可以用sendmai或者 配置SMTP服務 并 使用SMTP發送郵件.</code>

<code>在 Centos 6 和 7 系統上, 下面的指令将在系統防火牆裡面開放HTTP和SSH端口.</code>

<code>sudo</code> <code>yum </code><code>install</code> <code>curl policycoreutils openssh-server openssh-clients git -y</code>

<code>sudo</code> <code>systemctl </code><code>enable</code> <code>sshd</code>

<code>sudo</code> <code>systemctl start sshd</code>

<code>sudo</code> <code>yum </code><code>install</code> <code>postfix</code>

<code>sudo</code> <code>systemctl </code><code>enable</code> <code>postfix</code>

<code>sudo</code> <code>systemctl start postfix</code>

<code>sudo</code> <code>firewall-cmd --permanent --add-service=http</code>

<code>sudo</code> <code>systemctl reload firewalld</code>

<code>2. 添加GitLab倉庫,并安裝到伺服器上</code>

<code>curl -sS http:</code><code>//packages</code><code>.gitlab.cc</code><code>/install/gitlab-ce/script</code><code>.rpm.sh | </code><code>sudo</code> <code>bash</code>

<code>sudo</code> <code>yum </code><code>install</code> <code>gitlab-ce</code>

<code>如果你不習慣使用指令管道的安裝方式, 你可以在這裡下載下傳 安裝腳本 或者 手動下載下傳您使用的系統相應的安裝包(RPM</code><code>/Deb</code><code>) 然後安裝</code>

<code>curl -LJO https:</code><code>//mirrors</code><code>.tuna.tsinghua.edu.cn</code><code>/gitlab-ce/yum/el7/gitlab-ce-XXX</code><code>.rpm</code>

<code>curl -LJO https:</code><code>//mirrors</code><code>.tuna.tsinghua.edu.cn</code><code>/gitlab-ce/yum/el7/gitlab-ce-9</code><code>.2.2-ce.0.el7.x86_64.rpm</code>

<code>rpm -i gitlab-ce-9.2.2-ce.0.el7.x86_64.rpm </code>

<code>rpm -i gitlab-ce-XXX.rpm</code>

<code>3. 啟動GitLab</code>

<code>sudo</code> <code>gitlab-ctl reconfigure</code>

<code>4. 使用浏覽器通路GitLab</code>

<code>首次通路GitLab,系統會讓你重新設定管理者的密碼,設定成功後會傳回登入界面.</code>

<code>預設的管理者賬号是root,如果你想更改預設管理者賬号,請輸入上面設定的新密碼登入系統後修改帳号名.</code>

<code> </code><code>參數配置和故障排查請檢視 Omnibus GitLab 文檔 </code>

<code> </code><code>GitLab-CE中國鏡像源 清華大學TUNA開源鏡像站, 浙江大學開源鏡像站</code>

<code> </code> 

<code>       </code><code>*.                  *.</code>

<code>      </code><code>***                 ***</code>

<code>     </code><code>*****               *****</code>

<code>    </code><code>.******             *******</code>

<code>    </code><code>********            ********</code>

<code>   </code><code>,,,,,,,,,***********,,,,,,,,,</code>

<code>  </code><code>,,,,,,,,,,,*********,,,,,,,,,,,</code>

<code>  </code><code>.,,,,,,,,,,,*******,,,,,,,,,,,,</code>

<code>      </code><code>,,,,,,,,,*****,,,,,,,,,.</code>

<code>         </code><code>,,,,,,,****,,,,,,</code>

<code>            </code><code>.,,,***,,,,</code>

<code>                </code><code>,*,.</code>

<code>     </code><code>_______ __  __          __</code>

<code>    </code><code>/ ____(_) </code><code>/_/</code> <code>/   ____ _/ </code><code>/_</code>

<code>   </code><code>/ / __/ / __/ /   / __ `/ __ \</code>

<code>  </code><code>/ </code><code>/_/</code> <code>/ / </code><code>/_/</code> <code>/___/</code> <code>/_/</code> <code>/ </code><code>/_/</code> <code>/</code>

<code>  </code><code>\____</code><code>/_/</code><code>\__</code><code>/_____/</code><code>\__,_</code><code>/_</code><code>.___/</code>

<code>gitlab: Thank you </code><code>for</code> <code>installing GitLab!</code>

<code>gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:</code>

<code>gitlab: GitLab should be reachable at http:</code><code>//localhost</code>

<code>gitlab: Otherwise configure GitLab </code><code>for</code> <code>your system by editing </code><code>/etc/gitlab/gitlab</code><code>.rb </code><code>file</code>

<code>gitlab: And running reconfigure again.</code>

<code>gitlab: </code>

<code>gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme</code>

<code>gitlab: https:</code><code>//gitlab</code><code>.com</code><code>/gitlab-org/omnibus-gitlab/blob/master/README</code><code>.md</code>

<code>It looks like GitLab has not been configured yet; skipping the upgrade script.</code>

gitlab所有的工程目錄都在/var/opt/gitlab/下,你可以在這個目錄看到他們所有的元件

5、更改gitlab配置

vim /etc/gitlab/gitlab.rb

<code>#修改GitLab配置檔案中的external_url,修改這個配置會影響GitLab裡面顯示的倉庫連結</code>

<code>external_url </code><code>'http://gitlab.abc.com'</code>

<code>#時間區域,但是我修改這個時區後無法正常通路,失敗原因為查詢</code>

<code>gitlab_rails[</code><code>'time_zone'</code><code>] = </code><code>'Asia/Shangha'</code> 

<code>#修改gitlab資料存儲路徑</code>

<code>git_data_dirs({ </code><code>"default"</code> <code>=&gt; { </code><code>"path"</code> <code>=&gt; </code><code>"/data/gitlab_data"</code><code>}})</code>

<code>#設定nginx監控端口,通路的時候是http://gitlab.abc.com:9000</code>

<code>nginx[</code><code>'listen_port'</code><code>] = 9000</code>

<code>#Gitlab 修改備份檔案預設目錄</code>

<code>gitlab_rails[</code><code>'backup_path'</code><code>] = </code><code>'/data/gitlab_backups'</code>

<code>#163郵箱配置</code>

<code>gitlab_rails[</code><code>'smtp_enable'</code><code>] = </code><code>true</code>

<code>gitlab_rails[</code><code>'smtp_address'</code><code>] = </code><code>"smtp.163.com"</code>

<code>gitlab_rails[</code><code>'smtp_port'</code><code>] = 25</code>

<code>gitlab_rails[</code><code>'smtp_user_name'</code><code>] = </code><code>"[email protected]"</code>

<code>gitlab_rails[</code><code>'smtp_password'</code><code>] = </code><code>"xxxxxx"</code>

<code>gitlab_rails[</code><code>'smtp_domain'</code><code>] = </code><code>"163.com"</code>

<code>gitlab_rails[</code><code>'smtp_authentication'</code><code>] = </code><code>"login"</code>

<code>gitlab_rails[</code><code>'smtp_enable_starttls_auto'</code><code>] = </code><code>true</code>

<code>gitlab_rails[</code><code>'gitlab_email_from'</code><code>] = </code><code>'[email protected]'</code>

<code>gitlab_rails[</code><code>'gitlab_email_display_name'</code><code>] = </code><code>'Gitlab'</code>

6、啟動gitlab

<code>sudo</code> <code>gitlab-ctl start</code>

啟動後,登陸web界面,記得使用管理者賬号關閉開放注冊認證sign-up,禁止别人注冊使用。

7、gitlab備份

Gitlab 建立備份,會在備份目錄/data/gitlab_data下生成tar檔案

<code>gitlab-rake gitlab:backup:create</code>

8、gitlab常用指令

<code>檢視服務狀态</code>

<code>$ </code><code>sudo</code> <code>gitlab-ctl status</code>

<code>啟動服務</code>

<code>$ </code><code>sudo</code> <code>gitlab-ctl start</code>

<code>關閉服務</code>

<code>$ </code><code>sudo</code> <code>gitlab-ctl stop</code>

<code>重新開機服務</code>

<code>$ </code><code>sudo</code> <code>gitlab-ctl restart</code>

<code>設定完配置後重新加載配置</code>

<code>$ </code><code>sudo</code> <code>gitlab-ctl reconfigure</code>

<code>檢視nginx日志</code>

<code>gitlab-ctl </code><code>tail</code> <code>nginx</code><code>/gitlab_access</code><code>.log</code>

9、漢化

<code>#漢化</code>

<code>https:</code><code>//gitlab</code><code>.com</code><code>/xhang/gitlab</code>

10、不小心把signin登陸視窗關閉了,可以使用這個辦法解決

<code>#Gitlab - 如何解決 "No authentication methods configured on login page" ? (gitlab version : 9.2.2)  </code>

<code>sudo</code> <code>gitlab-psql -l 檢視資料庫清單</code>

<code>gitlab-psql gitlabhq_production</code>

<code>UPDATE application_settings </code><code>set</code> <code>signin_enabled=</code><code>true</code><code>;</code>

<code>\q</code>

<code>sudo</code> <code>gitlab-ctl restart</code>

參考:

<a href="http://www.jianshu.com/p/a22eaa1fcfe7" target="_blank">http://www.jianshu.com/p/a22eaa1fcfe7</a>

<a href="https://docs.gitlab.com.cn/ce/install/requirements.html" target="_blank">https://docs.gitlab.com.cn/ce/install/requirements.html</a>

<a href="https://bbs.gitlab.com.cn/" target="_blank">https://bbs.gitlab.com.cn</a>

https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

本文轉自 yanconggod 51CTO部落格,原文連結:http://blog.51cto.com/yanconggod/1941718

繼續閱讀