Git,GitHub,GitLab,這三個東東長得好像呀,都是個啥?html
Git是Linus Torvalds(若是不知道這位大神是誰,請出門左轉,慢走不送~)爲了幫助管理Linux內核而開發的一個開放源代碼的版本控制軟件。python
GitHub,又名全球最大同行交友軟件(O(∩_∩)O哈哈~),是一個面向開源及私有項目的託管平臺,由於僅僅支持Git做爲惟一的版本庫格式,故名GitHub。nginx
GitLab是由GitLabInc.開發的,是基於MIT許可證的Git倉庫管理工具,具備Wiki和Issue跟蹤功能,目前有企業版和社區版兩個分支,對於我的來講,社區版應該是徹底夠用的。git
其實,簡單來講,能夠把GitLab看作是個我的版的GitHub,也就是說,能夠在本身服務器上部署一套GitLab服務,該服務能夠提供代碼倉庫託管等功能,用法與GibHub基本一致。redis
# 安裝並配置必要的依賴 [root@cos ~]# yum install -y curl policycoreutils-python openssh-server [root@cos ~]# systemctl enable sshd [root@cos ~]# systemctl start sshd # CentOS7系統中,在防火牆打開場景下,打開HTTP, HTTPS和SSH訪問 [root@cos ~]# firewall-cmd --permanent --add-service=http [root@cos ~]# firewall-cmd --permanent --add-service=https [root@cos ~]# systemctl reload firewalld # 安裝Postfix,用來發送通知郵件 [root@cos ~]# yum install postfix [root@cos ~]# systemctl enable postfix [root@cos ~]# systemctl start postfix
注意:爲了不下載失敗致使GitLab安裝失敗,能夠配置清華鏡像,鏡像配置操做以下sql
# GitLab Community Edition鏡像使用幫助 # https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/ # 1. 新建/etc/yum.repos.d/gitlab-ce.repo, 內容以下 [gitlab-ce] name=Gitlab CE Repository baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/ gpgcheck=0 enabled=1
使用yum安裝GitLab社區版shell
# yum安裝GitLab社區版 [root@cos ~]# yum makecache [root@cos ~]# yum install gitlab-ce Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.huaweicloud.com * epel: hkg.mirror.rackspace.com * extras: mirrors.huaweicloud.com * updates: mirrors.huaweicloud.com Resolving Dependencies --> Running transaction check ---> Package gitlab-ce.x86_64 0:12.9.1-ce.0.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================= Package Arch Version Repository Size ========================================================================================= Installing: gitlab-ce x86_64 12.9.1-ce.0.el7 gitlab-ce 721 M Transaction Summary ========================================================================================= Install 1 Package Total download size: 721 M Installed size: 721 M Is this ok [y/d/N]: y Downloading packages: gitlab-ce-12.9.1-ce.0.el7.x86_64.rpm | 721 MB 00:01:49 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : gitlab-ce-12.9.1-ce.0.el7.x86_64 1/1 It looks like GitLab has not been configured yet; skipping the upgrade script. *. *. *** *** ***** ***** .****** ******* ******** ******** ,,,,,,,,,***********,,,,,,,,, ,,,,,,,,,,,*********,,,,,,,,,,, .,,,,,,,,,,,*******,,,,,,,,,,,, ,,,,,,,,,*****,,,,,,,,,. ,,,,,,,****,,,,,, .,,,***,,,, ,*,. _______ __ __ __ / ____(_) /_/ / ____ _/ /_ / / __/ / __/ / / __ `/ __ \ / /_/ / / /_/ /___/ /_/ / /_/ / \____/_/\__/_____/\__,_/_.___/ Thank you for installing GitLab! GitLab was unable to detect a valid hostname for your instance. Please configure a URL for your GitLab instance by setting `external_url` configuration in /etc/gitlab/gitlab.rb file. Then, you can start your GitLab instance by running the following command: sudo gitlab-ctl reconfigure For a comprehensive list of configuration options please see the Omnibus GitLab readme https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md GitLab now ships with a newer version of PostgreSQL (11.7), but it is not yet enabled by default. To upgrade, please see: https://docs.gitlab.com/omnibus/settings/database.html#upgrade-packaged-postgresql-server Verifying : gitlab-ce-12.9.1-ce.0.el7.x86_64 1/1 Installed: gitlab-ce.x86_64 0:12.9.1-ce.0.el7 Complete!
安裝完成後,重點關注下面提示信息:數據庫
GitLab was unable to detect a valid hostname for your instance. GitLab沒法爲你的GitLab檢測到有效的主機名。 Please configure a URL for your GitLab instance by setting `external_url` configuration in /etc/gitlab/gitlab.rb file. 請經過配置`external_url`爲你的GitLab實例配置一個URL,該配置項在/etc/gitlab/gitlab.rb文件中。 Then, you can start your GitLab instance by running the following command: sudo gitlab-ctl reconfigure 而後,經過運行sudo gitlab-ctl reconfigure啓動你的GitLab實例
注意:配置完成後,須要使用sudo gitlab-ctl reconfigure
命令從新配置並啓動GitLab實例才行。緩存
在GitLab安裝完成後,首次登陸時,須要配置GitLab管理員密碼,以下圖所示。服務器
注意:管理員帳號爲root,管理員密碼很是重要,是維護GitLab服務的重要帳戶,儘可能不要搞忘了。
根據上面的安裝步驟安裝完成後後,啓動GitLab實例後,你可能會想,這下能夠愉快的與GitLab玩耍了吧、
砰,一大盆涼水澆過來、
GitLab是很是吃內存和服務器性能的,爲了在本身主機或者虛擬機上正常啓動和訪問,須要進行下面配置和調優。
先看下官方給出的推薦CPU,內存配置:
GitLab推薦至少2核CPU,只有1核的話,可能會致使GitLab服務卡死,沒法正常對外服務。
由上可知,內存配置主要影響GitLab服務的併發用戶數量,對於本身使用來講,感受2GB徹底夠用了。
GitLab配置文件路徑:/etc/gitlab/gitlab.rb
。下面對GitLab關鍵配置進行修改:
## GitLab URL ##! URL on which GitLab will be reachable. ##! 用戶訪問GitLab的URL地址 external_url 'http://cos' ###! Minimum worker_processes is 2 at this moment ###! GitLab默認開啓進程數爲CPU核數+1,能夠提升服務器的相應時間,太吃內存 ###! GitLab的最小工做進程,該參數最小值爲2,設爲1可能致使服務器卡死 unicorn['worker_processes'] = 2 ### **Only change these settings if you understand well what they mean** ###! 工程進程的內存限制,默認最小爲400MB,最大爲650MB unicorn['worker_memory_limit_min'] = "200 * 1 << 20" unicorn['worker_memory_limit_max'] = "300 * 1 << 20" # sidekiq併發數默認值爲25 sidekiq['concurrency'] = 5 ###! Changing any of these settings requires a restart of postgresql. ###! By default, reconfigure reloads postgresql if it is running. If you ###! change any of these settings, be sure to run `gitlab-ctl restart postgresql` ###! after reconfigure in order for the changes to take effect. ##! **recommend value is 1/4 of total RAM, up to 14GB.** ##! 數據庫緩存,默認值爲256MB ##!推薦值爲1/4的RAM大小,按推薦值確定崩了 postgresql['shared_buffers'] = "128MB" ##! 數據庫併發數 postgresql['max_worker_processes'] = 4
GitLab安裝配置完成後,咱們能夠經過gitlab-ctl start
命令啓動,gitlab-ctl stop
命令中止GitLab服務。
# 查看GitLab服務狀態 [root@cos ~]# gitlab-ctl status run: gitaly: (pid 2202) 830s; run: log: (pid 2201) 830s run: gitlab-workhorse: (pid 2212) 830s; run: log: (pid 2211) 830s run: logrotate: (pid 2217) 830s; run: log: (pid 2214) 830s run: nginx: (pid 2198) 830s; run: log: (pid 2197) 830s run: postgresql: (pid 2204) 830s; run: log: (pid 2203) 830s run: redis: (pid 2213) 830s; run: log: (pid 2210) 830s run: sidekiq: (pid 2195) 830s; run: log: (pid 2193) 830s run: unicorn: (pid 2196) 830s; run: log: (pid 2194) 830s
GitLab服務啓動後,咱們能夠經過Web頁面訪問GitLab服務。
接下來,會專門再寫一篇博客講述如何在Windows上經過Git客戶端像訪問GitHub同樣訪問GitLab,敬請期待~