How To Increase the Maximum Number of File Descriptors RHEL / CentOS

Recently ran into a issue where a program running on RHEL was using up all the available File Descriptors. First we need to find out what the maximum number of open file descriptors is set to. We accomplish this by running the command:

# cat /proc/sys/fs/file-max

The output tells us it is set to 589420.

The vendor asked for this to be increased to 1639200. We can add change the value immediately by executing:

# sysctl -w fs.file-max=1639200

To make this a permanent setting applied everytime the system reboots an edit of /etc/sysctl.conf file is required. Add:

fs.file-max = 1639200

Save the changes to the file and execute sysctl -p, this will put the changes into effect.

# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
fs.file-max = 1639200

Thats all there is to it!

Leave a Reply

Your email address will not be published. Required fields are marked *