Cent OS 7 应用到生产环境要做到的配置


转自:http://linux.it.net.cn/CentOS/operation/2015/0117/12081.html?


1. 开发最大文件数 IT网.cn,http://www.it.net.cn

修改/etc/security/limits.conf文件,在文件中加入

<span style="font-size:18px;">* soft nofile 65536  
* hard nofile 65536 </span>
  IT网

开放最大文件数到65536

 

2.调优内核网络配置

修改/etc/sysctl.conf,在文件中加入

 

<span style="font-size:18px;">kernel.shmall = 268435456  
net.ipv4.tcp_syncookies = 1  
net.ipv4.tcp_tw_reuse = 1  
net.ipv4.tcp_tw_recycle = 1  
net.ipv4.tcp_fin_timeout = 30  
net.ipv4.tcp_keepalive_time = 1200  
net.ipv4.ip_local_port_range = 1024 65000  
net.ipv4.tcp_max_tw_buckets = 5000  
net.ipv4.tcp_max_tw_buckets = 5000  
net.ipv4.tcp_fin_timeout = 30  
net.ipv4.tcp_keepalive_time = 300  
net.ipv4.tcp_syncookies = 1  
net.ipv4.tcp_tw_reuse = 1  
net.ipv4.tcp_tw_recycle = 1  
net.ipv4.ip_local_port_range = 5000 65000  
net.ipv4.tcp_mem = 786432 1048576 1572864  
net.core.wmem_max = 873200  
net.core.rmem_max = 873200  
net.ipv4.tcp_wmem = 8192 436600 873200  
net.ipv4.tcp_rmem = 32768 436600 873200  
net.core.somaxconn = 256  
net.core.netdev_max_backlog = 1000  
net.ipv4.tcp_max_syn_backlog = 2048  
net.ipv4.tcp_retries2 = 5  
net.ipv4.tcp_keepalive_time = 500  
net.ipv4.tcp_keepalive_intvl = 30  
net.ipv4.tcp_keepalive_probes = 3  
net.ipv4.conf.lo.arp_ignore = 0  
net.ipv4.conf.lo.arp_announce = 0  
net.ipv4.conf.all.arp_ignore = 0  
net.ipv4.conf.all.arp_announce = 0 </span>

优化网络连接等网络参数,主要参数解释如下
[html] view plaincopy 在CODE上查看代码片 派生到我的代码片
 
  1. net.ipv4.tcp_syncookies = 1  
  2. #表示开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭;  
  3. net.ipv4.tcp_tw_reuse = 1  
  4. #表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭;  
  5. net.ipv4.tcp_tw_recycle = 1  
  6. #表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭。  
  7. net.ipv4.tcp_fin_timeout = 30  
  8. #表示如果套接字由本端要求关闭,这个参数决定了它保持在FIN-WAIT-2状态的时间。  
  9. net.ipv4.tcp_keepalive_time = 1200   
  10. #表示当keepalive起用的时候,TCP发送keepalive消息的频度。缺省是2小时,改为20分钟。  
  11. net.ipv4.ip_local_port_range = 1024    65000   
  12. #表示用于向外连接的端口范围。缺省情况下很小:32768到61000,改为1024到65000。  
  13. net.ipv4.tcp_max_tw_buckets = 5000  
  14. #表示系统同时保持TIME_WAIT套接字的最大数量,如果超过这个数字,  
  15. #TIME_WAIT套接字将立刻被清除并打印警告信息。默认为180000,改为5000。  
  16. #对于Apache、Nginx等服务器,上几行的参数可以很好地减少TIME_WAIT套接字数量,  
  17. #但是对于Squid,效果却不大。此项参数可以控制TIME_WAIT套接字的最大数量,避免Squid服务器被大量的TIME_WAIT套接字拖死。  
  修改完之后运行sudo sysctl -p使系统立即生效。

 

3.删掉MariaDB的配置文件 Linux学

系统默认会在/etc目录存放一个my.cnf文件

  Linux学习,http:// l

4.开放80端口

 


 
  1. sudo firewall-cmd --permanent --add-service=http # open up the firewall for HTTP and SSH requests  
  2. sudo systemctl reload firewalld
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值