Skip to main content

Adjusting File Handle Limits

This topic covers how to adjust file handle limits in Linux and MacOS. It also provides details on ensuring container platforms do not override the file handle limits configured in our Docker images.

Adjusting File Handle Limits in Linux Environments

systemd Users

If you're using systemd to launch the server, jump to the systemd Users section.

In Linux, you can usually set persistent limits for a specific user by editing the /etc/security/limits.conf file.

Add the lines like below to this file where <userid> is the user ID you are using to run Sonatype Nexus Repository:

<userid> - nofile 65536
<userid> - nproc 65536

Restart Sonatype Nexus Repository for the change to take effect.

Ubuntu

Ubuntu ignores the /etc/security/limits.conf file for processes started by init.d.

If Nexus Repository is started using init.d there, edit /etc/pam.d/common-session and uncomment the following line by removing the hash and space () at the beginning of the line:

# session    required   pam_limits.so

Restart Sonatype Nexus Repository for the change to take effect.

systemd Users

If you're using systemd to launch the server, do not use the steps above. Instead, modify the configuration file to add a LimitNOFILE line like in the following example:

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

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

[Install]
WantedBy=multi-user.target

Restart Sonatype Nexus Repository for the change to take effect.

Adjusting File Handle Limits in MacOS Environments

The method to modify the file descriptor limits on MacOS has changed a few times over the years. Please note your OS version and follow the appropriate instructions.

For OS X Yosemite (10.10) and newer

  1. Create the file: /Library/LaunchDaemons/limit.maxfiles.plist

    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
      <plist version="1.0">
        <dict>
          <key>Label</key>
            <string>limit.maxfiles</string>
          <key>ProgramArguments</key>
            <array>
              <string>launchctl</string>
              <string>limit</string>
              <string>maxfiles</string>
              <string>65536</string>
              <string>65536</string>
            </array>
          <key>RunAtLoad</key>
            <true/>
          <key>ServiceIPC</key>
            <false/>
        </dict>
      </plist>

    If this file already exists, then ensure the value is at least 65536 as shown.

    The file must be owned by root:wheel and have permissions -rw-r--r--.

    sudo chmod 644 /Library/LaunchDaemons/limit.maxfiles.plist
    sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
    

    Reboot the operating system to activate the change.

  2. Add a new line to $install-dir/bin/nexus.vmoptions containing:

    -XX:-MaxFDLimit

    Restart Nexus Repository to activate the change.

For OS X Lion (10.7) up to OS X Mavericks (10.9)

  1. Create and edit the system file /etc/launchd.conf using this command:

    sudo sh -c 'echo "limit maxfiles 65536 65536" >> /etc/launchd.conf'

    Reboot the operating system to activate the change.

  2. Add a new line to $install-dir/bin/nexus.vmoptions containing:

    -XX:-MaxFDLimit

    Restart Nexus Repository to activate the change.

Docker Images and File Limits

The Nexus Repository Docker images are configured with adequate file limits. Some container platforms such as Amazon ECS will override the default limits. On these platforms it is recommended that the Docker image be run with the following flags:

--ulimit nofile=65536:65536