Linux Kernel Optimizer
Linux Kernel Optimizer
[email protected]
#!/bin/bash
host=$(hostname)
ARCH=$(uname -m)
which bc
if [ $? -ne 0 ]; then
echo "This script require GNU bc, cf. http://www.gnu.org/software/bc/"
echo "On Linux Debian/Ubuntu you can install it by doing : apt-get install bc"
fi
# Disable syncookies (syncookies are not RFC compliant and can use too much
resources)
net.ipv4.tcp_syncookies = 0
# RFC1337
net.ipv4.tcp_rfc1337 = 1
# Defines the local port range that is used by TCP and UDP
# to choose the local port
net.ipv4.ip_local_port_range = 1024 65535
# tells the kernel how many TCP sockets that are not attached
# to any user file handle to maintain
net.ipv4.tcp_max_orphans = $max_orphan
# How may times to retry before killing TCP connection, closed by our side
net.ipv4.tcp_orphan_retries = 1
net.core.netdev_max_backlog = 2500
net.core.somaxconn = 65000
vm.swappiness = 5
vm.watermark_scale_factor = 200
# You can monitor the kernel behavior with regard to the dirty
# pages by using grep -A 1 dirty /proc/vmstat
vm.dirty_background_ratio = $vm_dirty_bg_ratio
vm.dirty_ratio = $vm_dirty_ratio
# required free memory (set to 1% of physical ram)
vm.min_free_kbytes = $min_free
# system open file limit
fs.file-max = $file_max
Script to optimize Ubuntu Kernel
[email protected]
# Core dump suidsafe
fs.suid_dumpable = 2
kernel.printk = 4 4 1 7
kernel.core_uses_pid = 1
kernel.sysrq = 0
kernel.msgmax = 65536
kernel.msgmnb = 65536
sysctl -p
>/etc/security/limits.conf cat << EOF
* soft nofile 500000
* hard nofile 500000
root soft nofile 500000
root hard nofile 500000
EOF