gitlab 502 not responding

問題是在我買了一個vps之後,在上面搭建 gitlab,安裝完成之後啓用主頁報出的,具體情況如下圖:
在這裏插入圖片描述
分析可能是因爲 gitlab 設置的端口號被佔用了;或者是因爲 gitlab 佔用的內存過多導致。

我的實際情況是在安裝完gitlab安裝包之後,系統執行指令過程中就一直開始報:OutOfMemory: ERROR: out of memory 的問題,這個很明顯就是 gitlab 佔用系統內存過多導致的了。


解決方法:

  1. 由於8080端口經常被佔用,因此在設置 extern_url 就指定另外的端口號:
    url

  2. 關於Unicorn Workers:
    CPU cores + 1 = unicorn workers,一般情況下設置爲2或者3就足夠了使用了;但需要注意的是:如果unicorn workers只有1,那麼將導致git只能通過ssh協議進行工作,因爲使用http協議時,分別需要各一個worker來接收和發送數據。

    由於這個gitlab只有我一個人使用,所以可以把unicorn workers設爲 2,保證http主頁能打開即可;
    workers

sudo vim /etc/gitlab/gitlab.rb
修改完上面兩項內容之後,保存退出

重新配置並啓動gitlab
sudo gitlab-ctl reconfigure
  1. 關於內存這一塊,gitlab 需要至少2GB的內存(RAM+SWAP),官方給出的建議如下:

    512MB RAM + 1.5GB of swap is the absolute minimum but we strongly advise against this amount of memory. See the unicorn worker section below for more advise.
    1GB RAM + 1GB swap supports up to 100 users but it will be slow
    2GB RAM is the recommended memory size and supports up to 100 users
    4GB RAM supports up to 1,000 users
    8GB RAM supports up to 2,000 users
    16GB RAM supports up to 4,000 users
    32GB RAM supports up to 8,000 users
    64GB RAM supports up to 16,000 users
    128GB RAM supports up to 32,000 users
    More users? Run it on multiple application servers

因爲我買的vps默認只有1G的 RAM(所以 gitlab 開啓之後,系統很長時間無論執行什麼命令都報 memory error),所以給機器另外開了2G的 swap。

dd if=/dev/zero of=/home/swap bs=1024 count=2097152
製作swap
mkswap /home/swap
掛載swap
swapon /home/swap

最後最好把swap寫到fstab中,使其自動掛載
sudo vim /etc/fstab

fstab
掛載完之後,可以看到系統的內存多出2G的swap空間:
free
vps的contorl panel也可以看到內存的使用情況(可以看到系統內存佔用確實很多):
swap


以上操作完之後,就可以看到熟悉的登陸界面了(根據機器內存和性能,還有和諧*網速,打開UI頁面速度還是挺慢的,不過對代碼push還是影響比較小)
gitlab

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章