Optimization of kernel parameters of Linux server
Linux kernel parameter tuning is mainly achieved by modifying the parameters of the / proc pseudo file system and / etc/sysctl.conf configuration file.
The directory structure of / proc is as follows:
/ proc/driver drive-related information
/ proc/fs file system parameters
/ proc/net network information
/ proc/pid information for each process
/ proc/sys kernel parameters
/ proc/scsi information related to scsi
/ proc/meminfo memory related information
/ proc/cpuinfo CPU related information
/ proc/loadavg system load
Modules or drivers loaded by / proc/modules system
/ proc/partitions system partition information
/ proc/version kernel version information
/ proc/stat CPU utilization, disk, memory page
/ proc/devices list of available devices
/ proc/sys/kernel general kernel parameters
/ proc/sys/vm memory management parameters
/ proc/sys/dev device-related information
/ proc/sys/net network information
The files in a process directory are described as follows:
File descriptor opened by the / proc/pid/fd process
Executable file for / proc/pid/exe process
/ proc/pid/cmdline some parameters of the current process running
/ proc/pid/environ the environment variable of the current process
/ proc/pid/status the basic status of the current process
Vim / etc/sysctl.conf
Net.ipv4.tcp_syncookies = 1 # enable SYN Cookies. Can prevent a small amount of SYN***.
Net.ipv4.ip_local_port_range = 10000 65535 # set the port range for outbound connections
Net.ipv4.route.gc_timeout = 100 # Route cache refresh frequency
Net.core.netdev_max_backlog = 16384 # allow queuing for more messages
Net.core.somaxconn = 16384 # specify a larger accept queue backlog
Net.ipv4.tcp_max_syn_backlog = 16384 # increase the length of the SYN queue
Net.ipv4.tcp_synack_retries = 1 # number of times to resend the response
Net.ipv4.tcp_retries2 = 5 # number of times to resend data to the remote host
Net.ipv4.tcp_keepalive_time = 1200 # how often the kernel sends Keepalive messages to remote hosts
Net.ipv4.tcp_keepalive_intvl = 30 # interval at which the kernel sends probe messages to remote hosts
System optimization script:
#! / bin/bash
Yum-y groupinstall "Development tools"
Cd / usr/local/src
Wget https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Rpm-ivh epel-release-6-8.noarch.rpm
Sed-I's etc/selinux/config SelinuxplenforcingAccording to SELINUXAfter
Sed-I 's/start on control-alt-delete/#start on control-alt-delete/' / etc/init/control-alt-delete.conf
Sed-I 's@exec / sbin/shutdown-r now "Control-Alt-Delete pressed" @ # exec / sbin/shutdown-r now "Control-Alt-Delete pressed" @' / etc/init/control-alt-delete.conf
Service iptables stop
Chkconfig iptables off
Ulimit-SHn 65534
Echo "ulimit-SHn 65534" > > / etc/rc.local
Cat > > / etc/sysctl.conf