Centos8 中安裝GitLab


Centos8 中安裝GitLab

1,安裝依賴

yum install -y curl policycoreutils-python openssh-server

centos8沒有policycoreutils-python yum源,不用管

2,啟動ssh並設置為開機自啟動

systemctl enable sshd

systemctl start sshd

 

3,添加http服務到firewalld,pemmanent表示永久生效,若不加--permanent系統下次啟動后就會失效

systemctl start firewalld

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
systemctl reload firewalld

 

4,啟動postfix

systemctl enable postfix

systemctl start postfix

 

5,下載gitlab

去這個路徑下找最新的: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8 ; 下面的命令對應也跟着修改
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/gitlab-ce-12.10.1-ce.0.el8.x86_64.rpm

 

6,安裝

rpm -i gitlab-ce-12.10.1-ce.0.el8.x86_64.rpm

 


成功如圖:

7,編輯ip和端口

 

vim /etc/gitlab/gitlab.rb

gitlab-ctl reconfigure

gitlab-ctl restart

 

8,訪問gitlab ip+端口
如果輸入端口和ip一直無法響應,可以關閉防火牆
systemctl stop firewalld

如果訪問502,查看

https://www.cnblogs.com/fuhua/p/15414744.html

14.之后在本機瀏覽器輸入地址 http://ip+端口 提示502錯誤!



15.gitlab官方文檔中說的是當CPU到達100%時會返回502錯誤,這個錯誤來自包Unicorn。

由於我們安裝的gitlab是14.3.3版本,Unicorn包已被棄用,改名為Puma,所以我們可以初步判斷是Puma包導致的502報錯。

參考鏈接:502 Gateway Timeout after Unicorn spins at 100% CPU

 

 

16.輸入命令top查看cpu占用狀態,發現command為bundle這個操作占用了99.3%的cpu,這明顯是不合理的。

 

 17.實時打印 puma包的日志,發現輸出"Errno::EADDRINUSE: Address already in use - bind(2) for "127.0.0.1" port 8080"。原因就很清晰了,是因為8080端口被占用。

#實時打印puma包的日志
sudo gitlab-ctl tail puma

 

15.查看占用端口為8080並且狀態為LISTEN的進程

發現8080端口被進程Id:58799 進程名:nginx:maser 的進程占用了,這是gitlab自帶的nginx默認的監聽端口。

而包puma也需要監聽8080端口,產生了沖突導致puma 執行build失敗。

puma包在執行build失敗之后會無限重試,導致了死循環把cpu跑到了100%。

netstat -anp |grep 8080

 

16.接下來只需要給puma包設置默認監聽端口不是8080就好了,我這里設置為8081

vim /etc/gitlab/gitlab.rb

新增

puma['port'] = 8081

 

 17.依次執行下面命令
復制代碼

#停止gitlab
gitlab-ctl stop

#重新加載gitlab配置
gitlab-ctl reconfigure

#重新運行gitlab
gitlab-ctl restart

#監視cpu狀態
top

復制代碼

 

18.可以看到兩個CPU占用非常高的進程,此時如果您在本機訪問搭建的gitlab地址,依舊會提示502。

因為此時gitlab正在構建,我們什么都不需要做。只需要等到這兩個CPU占用很高的進程CPU降低后就可以訪問了。

 

 

 

注:如果遠程訪問不是提示502錯誤,而是提示連接失敗之類的。80%都是因為服務器防火牆限制或者雲服務器提供商防火牆限制。

 

#停止服務器防火牆
sudo systemctl stop firewalld

 


重新配置並啟動

gitlab-ctl reconfigure

gitlab-ctl restart
開啟:
gitlab-ctl start
關閉:
gitlab-ctl stop

9,成功如圖:

10,第一次登錄需要修改root密碼, 密碼8位以上,修改完就可以登錄
使用設置的新密碼,登錄

其他操作類似添加賬號,倉庫等等自己百度


免責聲明!

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



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