Adjusting the 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.
Docker Images
The Nexus Repository Docker images are configured with adequate file limits. Some container platforms such as Amazon ECS override the default limits. On these platforms it is recommended that the Docker image be run with the following flags:
--ulimit nofile=65536:65536
Linux Environments
init.d
When using init.d
we manage the file handle limit by setting persistent limits for a Linux user.
Add the following to the
/etc/security/limits.conf
file where theuserid
is the user running Nexus Repository.<userid> - nofile 65536 <userid> - nproc 65536
Optional: Ubuntu ignores the
limits.conf
file for processes started by theinit.d
process. Edit the/etc/pam.d/common-session
file and uncomment the following line:# session required pam_limits.so
Restart the service for the change to take effect.
systemd
When using systemd
to launch the server, modify the configuration file to add a LimitNOFILE
line:
[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 the Nexus Repository for the change to take effect.
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
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 to activate the change.
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)
Create and edit the system file
/etc/launchd.conf
using this command:sudo sh -c 'echo "limit maxfiles 65536 65536" >> /etc/launchd.conf'
Reboot to activate the change.
Add a new line to
$install-dir/bin/nexus.vmoptions
containing:-XX:-MaxFDLimit
Restart Nexus Repository to activate the change.