3

I am trying to update nexus from 3.2.0 to nexus 3.7.1 ,getting a max file descriptors error message

using docker container sonatype/nexus3:3.7.1

i tried to increase the descriptors to 65536 but it is not reflecting when i try with ulimit

I did: cat /etc/security/limits.conf

nexus hard nofile 65536 nexus soft nofile 65536

restarted my docker container

values: ulimit -n 1024 ulimit -Hn 4096 ulimit -Sn 1024

enter image description here

Swat
  • 475

2 Answers2

4

Looks to be explained in the Nexus docs here https://help.sonatype.com/repomanager3/system-requirements#SystemRequirements-AdequateFileHandleLimits


On most Linux systems, persistent limits can be set for a particular user by editing the /etc/security/limits.conf file. To set the maximum number of open files for both soft and hard limits for the nexus user to 65536, add the following line to the /etc/security/limits.conf file, where "nexus" should be replaced with the user ID that is being used to run the repository manager:

nexus - nofile 65536

This change will only take effect the next time the nexus process user opens a new session. Which essentially means that you will need to restart NXRM.

On Ubuntu systems there is a caveat: Ubuntu ignores the /etc/security/limits.conf file for processes started by init.d.

So if NXRM is started using init.d there, edit /etc/pam.d/common-session and uncomment the following line ( remove the hash # and space at the beginning of the line):

# session    required   pam_limits.so

For more information refer to your specific operating system documentation.

If you're using systemd to launch the server the above won't work. Instead, modify the configuration file to add a LimitNOFILE line:

[Unit] 
Description=nexus service 
After=network.target

[Service] 
Type=forking  
LimitNOFILE=65536
ExecStart=/opt/nexus/bin/nexus start 
ExecStop=/opt/nexus/bin/nexus stop 
User=nexus 
Restart=on-abort

[Install] 
WantedBy=multi-user.target
1

OP asked for a way to increase ulimit for a process running inside a Docker container, in this case Nexus Repository server. While the answer given above covers some scenarios for increasing ulimit for processes running under an init system such as systemd, the mechanism is different for Docker.

To increase the number of handles within a container, you need to either execute the "ulimit" command within the container's Dockerfile

RUN ulimit 65536

or, if you can't/don't want to build your own container, then you can pass --ulimit nofile=65536:65536 as a parameter on the docker run command that starts the container.

In kubernetes, you accomplish the same thing by adding a 'resource' section to the pod spec for your container, something like:

   ...
     spec:
      containers:
      - name: Nexus
        image: sonatype/nexus3:3.7.1
        resources:
          limits:
            nofile: 65536  # Set the maximum number of file handles