echo "# swappiness=0的时候表示最大限度使用物理内存,然后才是 swap空间" >> /etc/sysctl.conf
echo -e "vm.swappiness = 0
" >> /etc/sysctl.conf
echo "# ARP参数,检查一次相邻层记录的有效性的周期。当相邻层记录失效" >> /etc/sysctl.conf
echo -e "net.ipv4.neigh.default.gc_stale_time=120
" >> /etc/sysctl.conf
echo "# 路由设定" >> /etc/sysctl.conf
echo -e "net.ipv4.conf.all.rp_filter=0
" >> /etc/sysctl.conf
echo "#启用源路由核查功能" >> /etc/sysctl.conf
echo -e "net.ipv4.conf.default.rp_filter=0
" >> /etc/sysctl.conf
echo "#限制arp 协议要发的要求,2 始终使用最好的解决这一目标" >> /etc/sysctl.conf
echo "net.ipv4.conf.default.arp_announce = 2" >> /etc/sysctl.conf
echo "net.ipv4.conf.lo.arp_announce=2" >> /etc/sysctl.conf
echo -e "net.ipv4.conf.all.arp_announce=2
" >> /etc/sysctl.conf
echo "#timewait的数量,默认是180000" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_max_tw_buckets = 100000
" >> /etc/sysctl.conf
echo "#开启SYN洪水攻击保护" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_syncookies = 1
" >> /etc/sysctl.conf
echo "#记录的那些尚未收到客户端确认信息的连接请求的最大值。对于有128M内存的系统而言,缺省值是1024,小内存的系统则是128" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_max_syn_backlog = 1024
" >> /etc/sysctl.conf
echo "#为了打开对端的连接,内核需要发送一个SYN并附带一个回应前面一个SYN的ACK。也就是所谓三次握手中的第二次握手。这个设置决定了内核放弃连接之前发送SYN+ACK包的数量" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_synack_retries = 2
" >> /etc/sysctl.conf
echo "#禁用ipv6协议" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.conf=
echo "#脏页的老化时间,默认30秒,多久刷盘一次" >> /etc/sysctl.conf
echo "vm.dirty_expire_centisecs = 3000" >> /etc/sysctl.conf
echo "#pdflush多久工作一次" >> /etc/sysctl.conf
echo "vm.dirty_writeback_centisecs = 500" >> /etc/sysctl.conf
echo "#如果脏页到达剩余的10%,kernel 在调节,而不是pdflush" >> /etc/sysctl.conf
echo "vm.dirty_background_ratio = 10" >> /etc/sysctl.conf
echo "#低位内存 30秒一次(到达20%) 小数据文件,随即数较多,可以适当把这个值设置大一些,性能更好一些。" >> /etc/sysctl.conf
echo "vm.dirty_ratio = 30 " >> /etc/sysctl.conf
echo "#到达字节" >> /etc/sysctl.conf
echo "vm.dirty_bytes = 0">> /etc/sysctl.conf
echo "vm.dirty_background_bytes = 0">> /etc/sysctl.conf
sysctl -p