您的位置:首页 > 其它

内核参数sysctl.conf的优化

2010-07-12 09:41 399 查看
安装的Centos5.5_x86_64原来的sysctl.conf如下
#cat /etc/sysctl.conf |grep -v '^$' |grep -v '#'
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
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
在最后面添加如下参数
fs.file-max = 6553600
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65536
net.core.rmem_default = 16777216
net.core.rmem_max=16777216
net.core.wmem_default = 16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 65536 16777216
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_tw_recycle = 1
net.core.netdev_max_backlog = 30000
net.ipv4.tcp_no_metrics_save=1
net.core.somaxconn = 262144
net.ipv4.tcp_max_orphans = 8000
net.ipv4.tcp_max_syn_backlog = 8000
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2

运行sysctl -p,使配置生效
这里的"fs.file-max = 6553600"其实是由"fs.file-max = 512 * PROCESSES"得到的,我们指定PROCESSES的值为12800,即为"fs.file-max =512 *12800"。
kernel.shmmax:表示单个共享内存段的最大值,以字节为单位,此值一般为物理内存的一半,不过大一点也没关系,这里设定的为4GB,
即"4294967295/1024/1024/1024=4G"
kernel.shmmni:表示单个共享内存段的最小值,一般为4kB,即4096bit
kernel.shmall:表示可用共享内存的总量,单位是页,在32位系统上一页等于4kB,也就是4096字节
fs.file-max:表示文件句柄的最大数量。文件句柄表示在Linux系统中可以打开的文件数量。
ip_local_port_range:表示端口的范围,为指定的内容。
kernel.sem:表示设置的信号量,这4个参数内容大小固定。
net.core.rmem_default:表示接收套接字缓冲区大小的缺省值(以字节为单位)。
net.core.rmem_max :表示接收套接字缓冲区大小的最大值(以字节为单位)
net.core.wmem_default:表示发送套接字缓冲区大小的缺省值(以字节为单位)。
net.core.wmem_max:表示发送套接字缓冲区大小的最大值(以字节为单位)。本文出自 “无云安全技术站” 博客,请务必保留此出处http://hx100.blog.51cto.com/44326/347872
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: