inux/Centos内核优化脚本
原创
©著作权归作者所有:来自51CTO博客作者sunsamson的原创作品,请联系作者获取转载授权,否则将追究法律责任
#!/bin/bash
#备份原有文档
mv /etc/sysctl.conf /etc/sysctl.conf.`date +"%Y-%m-%d_%H-%M-%S"`
#导入新参数
echo -e "kernel.sysrq = 0\n"\
"kernel.core_uses_pid = 1\n"\
"kernel.msgmnb = 65536\n"\
"kernel.msgmax = 65536\n"\
"kernel.shmmax = 2147483648\n"\
"kernel.shmall = 1048576\n"\
"net.core.wmem_default = 2097152\n"\
"net.core.wmem_max = 8388608\n"\
"net.core.rmem_default = 2097152\n"\
"net.core.rmem_max = 8388608\n"\
"net.core.netdev_max_backlog = 4096\n"\
"net.core.somaxconn = 51200\n"\
"net.ipv4.conf.default.rp_filter = 1\n"\
"net.ipv4.conf.default.accept_source_route = 0\n"\
"net.ipv4.ip_forward = 0\n"\
"net.ipv4.ip_local_port_range = 2048 65000\n"\
"net.ipv4.tcp_fin_timeout = 15\n"\
"net.ipv4.tcp_keepalive_time = 30\n"\
"net.ipv4.tcp_max_orphans = 3276800\n"\
"net.ipv4.tcp_max_syn_backlog = 32768\n"\
"net.ipv4.tcp_max_tw_buckets = 6000\n"\
"net.ipv4.tcp_mem = 262144 786432 1048576\n"\
"net.ipv4.tcp_rmem_max = 1048576\n"\
"net.ipv4.tcp_wmem_max = 1048576\n"\
"net.ipv4.tcp_rmem = 4096 131072 1048576\n"\
"net.ipv4.tcp_wmem = 4096 131072 1048576\n"\
"net.ipv4.tcp_sack = 1\n"\
"net.ipv4.tcp_syn_retries = 3\n"\
"net.ipv4.tcp_synack_retries = 3\n"\
"net.ipv4.tcp_syncookies = 1\n"\
"net.ipv4.tcp_timestamps = 0\n"\
"net.ipv4.tcp_tw_reuse = 1\n"\
"net.ipv4.tcp_tw_recycle = 1\n"\
"net.ipv4.tcp_window_scaling = 1\n" >/etc/sysctl.conf
#使新参数生效
sysctl -p
上一篇:inux/Centos内核详解
下一篇:Linux文件描述符修改
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
centos内核参数性能优化
centos内核参数性能优化
linux 性能