The troubleshooting experience of docker deploying JAVA application OOM - the road to dream

Symptoms:

 Use docker to deploy JAVA applications, and tomcat is used as a middleware container. When starting the application, an error is always reported and the Java virtual machine cannot be created, and then OOM

Error message:

No useful information was found from the docker container log or the system log, and I also tried to change the image tomcat version, docker version, and docker-compose version, but failed to solve the problem

So according to the error message: library initialization failed - unable to allocate file descriptor table - out of memory

access information

docker startup error library initialization failed - unable to allocate file descriptor table - out of memory

library initialization failed - unable to allocate file descriptor table - out of memoryAborte_Tiny-V的博客-CSDN博客

Query the file descriptor related settings of the current system according to the consulted information, and find that the value set in the limits.conf of the current system is very large

 

So far, finally found the root of the problem.

Solution:

 Global solution: Modify the system configuration limits.conf

* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
* soft memlock unlimited
* hard memlock unlimited
* soft core unlimited
* hard core unlimited

 To solve the current problem of docker:

vim  /etc/systemd/system/docker.service

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd --default-ulimit nofile=65535:65535 -H fd://

systemctl daemon-reload

systemctl restart docker

The ulimits parameter is specified in the docker-compose yml file:

The reference is as follows:


以下是一个示例docker-compose.yml文件中指定nproc和nofile参数的配置:

version: '3'
services:
  web:
    build: .
    ulimits:
      nproc: 2048
      nofile:
        soft: 65535
        hard: 65535
    command: python app.py
    ports:
      - "5000:5000"

 

Summary: For system parameter optimization, it is not that the larger the value, the better. It needs to be adjusted according to the actual situation, rather than blindly increasing the parameter value. 

Guess you like

Origin blog.csdn.net/qq_34777982/article/details/130521687