【归档】kata worker_connections 过大导致 nginx 内存分配失败

使用的 kata 版本:1.12
nginx 版本:1.13

解决方案:把 worker_connections 调小,最好不超过 10k。

onlyoffice 部署在 kata 容器中,启动脚本使用 ulimit -n 设置 worker_connections 的值,由于 kata 中的 ulimit -n 值获取有问题,导致将 10 亿大的数设置给了 worker_connections,最终导致 nginx 无法正常运行,报错 malloc(257698035840) failed (12: Cannot allocate memory)

257698035840 = 1073741816 * 240

/etc/nginx/nginx.conf

root@eci-f6818f5cfd2d4618b0fca91730e27be0:/etc/nginx# cat nginx.conf 
user  nginx;
worker_processes 3;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections 1073741816;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;
    include /etc/nginx/sites-enabled/*;
    include /etc/nginx/conf.d/*.conf;
}

/var/log/nginx/error.log

2021/08/18 03:18:56 [emerg] 45#45: malloc(257698035840) failed (12: Cannot allocate memory)
2021/08/18 03:18:56 [emerg] 44#44: malloc(257698035840) failed (12: Cannot allocate memory)
2021/08/18 03:18:56 [emerg] 46#46: malloc(257698035840) failed (12: Cannot allocate memory)
2021/08/18 03:18:56 [alert] 43#43: worker process 45 exited with fatal code 2 and cannot be respawned
2021/08/18 03:18:56 [alert] 43#43: worker process 44 exited with fatal code 2 and cannot be respawned
2021/08/18 03:18:56 [alert] 43#43: worker process 46 exited with fatal code 2 and cannot be respawned

官方说明:http://mailman.nginx.org/pipermail/nginx/2020-June/059575.html
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值