gitlab部署后内存占用过多

在部署gitlab后发现gitlab启动了非常多的bundle。

百度了一下原来是我的服务器cpu核心数太多了,gitlab建议如果您这台机器只使用与gitlab的话unicorn['worker_processes'] 这个默认是cpu核心数加一,所以开启的进程就会很多,我们只要把这个参数指定一下就好了,编辑配置文件gitlab.rb

去掉下面的注释

unicorn['worker_processes'] = 2

之后执行

docker exec -it gitlab gitlab-ctl reconfigure

docker exec -it gitlab gitlab-ctl restart

也可以重启容器。

但是发现没有效果,我的gitlab版本为13.10.5。后来又采用和很多方法包括限制docker容器的CPU和内存,限制docker容器的内存有效果但是无法减少bundle的数量,治标不治本。

最后仔细研究配置文件gitlab.rb,发现如下:

################################################################################

#unicorn['enable'] = false
# unicorn['worker_timeout'] = 60
###! Minimum worker_processes is 2 at this moment
###! See https://gitlab.com/gitlab-org/gitlab-foss/issues/18771
unicorn['worker_processes'] = 4

### Advanced settings
# unicorn['listen'] = 'localhost'
# unicorn['port'] = 8080
# unicorn['socket'] = '/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket'
# unicorn['pidfile'] = '/opt/gitlab/var/unicorn/unicorn.pid'
# unicorn['tcp_nopush'] = true
# unicorn['backlog_socket'] = 1024

###! **Make sure somaxconn is equal or higher then backlog_socket**
# unicorn['somaxconn'] = 1024

###! **We do not recommend changing this setting**
# unicorn['log_directory'] = "/var/log/gitlab/unicorn"

### **Only change these settings if you understand well what they mean**
###! Docs: https://docs.gitlab.com/ee/administration/operations/unicorn.html#unicorn-worker-killer
###!       https://github.com/kzk/unicorn-worker-killer
unicorn['worker_memory_limit_min'] = "200 * 1 << 20"
unicorn['worker_memory_limit_max'] = "300 * 1 << 20"

# unicorn['exporter_enabled'] = false
# unicorn['exporter_address'] = "127.0.0.1"
# unicorn['exporter_port'] = 8083

################################################################################
## GitLab Puma
##! Tweak puma settings. You should only use Unicorn or Puma, not both.
##! Docs: https://docs.gitlab.com/omnibus/settings/puma.html
################################################################################

# puma['enable'] = true
# puma['ha'] = false
# puma['worker_timeout'] = 60
puma['worker_processes'] = 4

注意#unicorn['enable'] = false和下面的# puma['enable'] = true

原因找到了,这个版本的gitlab不是使用的unicorn而是puma,所以应该修改的配置是

puma['worker_processes'] = 4

修改后然后重启服务,问题解决

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值