GitLab 502 error solution

1. First, check whether the port number in the configuration file /etc/gitlab/gitlab.rb is occupied

2. Another reason is that gitlab occupies too much memory, causing the server to crash

If the server memory is less than 2G, Gitlab cannot be started, and a 502 error will be reported.
The memory cannot be expanded and only the swap partition can be opened.

What does swap do?

Under Linux, SWAP is similar to "virtual memory" under Windows system. When the physical memory is insufficient, part of the hard disk space is used as the SWAP partition (virtualized as memory) to solve the problem of insufficient memory capacity.

SWAP means swap. As the name implies, when a process requests the OS to find insufficient memory, the OS will exchange the temporarily unused data in the memory and place it in the SWAP partition. This process is called SWAP OUT. When a process needs these data and the OS finds that there is free physical memory, it will exchange the data in the SWAP partition back into the physical memory. This process is called SWAP IN.

Of course, the swap size has an upper limit. Once the swap is used up, the operating system will trigger the OOM-Killer mechanism to kill the process that consumes the most memory to release the memory.

Resolve Gitlab 502 error by creating swap partition

  1. Check whether the swap partition is activated (none)
cat /proc/swaps 

Create if it doesn't show

dd if=/dev/zero of=/data/swap bs=512 count=8388616

Create swap size as bs*count=4294971392(4G);

  1. Use the mkswap command to make the newly created file into a swap partition
mkswap /data/swap
  1. Check whether the value in the kernel parameter vm.swappiness is 0, if it is 0, adjust it to 60 according to actual needs
#查看: 
cat /proc/sys/vm/swappiness
#设置: 
sysctl -w vm.swappiness=60
#若想永久修改,则编辑/etc/sysctl.conf文件,改文件中有vm.swappiness变量配置,默认为0
  1. Enable partition
swapon /data/swap
echo “/data/swap swap swap defaults 0 0” >> /etc/fstab

Use cat /proc/swaps again to see if the swap partition is activated

  1. Restart GitLab
#停止 GitLab
sudo gitlab-ctl stop
#启动 GitLab
sudo gitlab-ctl start
#重启 GitLab
sudo gitlab-ctl restart

Guess you like

Origin blog.csdn.net/dndndnnffj/article/details/111926896