使用的 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