Wednesday, March 12, 2014

Linux How to set kernel parameters in sysctl.conf file permanently

How to set kernel parameters in sysctl.conf file permanently in Linux? Specifically RHEL in this case, but this applies to centos as well. Even Suse I believe :)  The kernel parameters can be tuned dynamically with the sysctl command.  Meaning you can change a kernel parameter on the fly.  But this won’t survive a reboot.  To make this type of change permanently the best and possibly easiest way is to either edit the /etc/sysctl.conf file and then save it with the sysctl -p command below.

Edit /etc/sysctl.conf file

# vi /etc/sysctl.conf
Add or change whatever entries you need to in sysctl.conf, as given below.
kernel.sem=1000 32000 32 512 kernel.msgmni = 1024 fs.file-max = 65535 net.ipv4.tcp_max_syn_backlog = 8192 # set cause we are now a router net.ipv4.ip_forward = 1 # Controls the maximum size of a message, in bytes kernel.msgmnb = 32768 # Controls the default maxmimum size of a mesage queue kernel.msgmax = 65536 # Controls the maximum shared segment size, in bytes kernel.shmmax = 68719476736 # Controls the maximum number of shared memory segments, in pages kernel.shmall = 4294967296
Confirm that there are no duplicate entries in the /etc/sysctl.conf file. To install the newly configured kernel paramaters, run the sysctl command with the -p parameter. This loads the sysctl settings from the default file /etc/sysctl.conf.
# sysctl -p

No comments:

Post a Comment