linux服务器高并发修改

1. 新增Linux句柄上限

a)将ulimit 值添加到/etc/profile文件中:
     在文件profle中添加 :
         
 ulimit -n 65535

      设置生效:
        $: source /etc/profle
        $:ulimit -n              #显示65535,修改完毕! 

            
b)修改linux的软硬件限制文件/etc/security/limits.conf
  在文件尾部添加如下代码:
             $: soft nofile 65535
             $: hard nofile 65535 

                         

2. Tcp内核参数优化

在文件profile中添加如下配置:
$:net.ipv4.tcp_tw_reuse = 1  

#表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭; 

$:net.ipv4.tcp_tw_recycle = 1

#recyse是加速TIME-WAIT sockets回收

$:net.ipv4.tcp_fin_timeout = 30

#fin_wait1状态是在发起端主动要求关闭tcp连接,并且主动发送fin以后,等待接收端回复ack时候的状态

$:net.ipv4.tcp_keepalive_time = 1200 

$:net.ipv4.tcp_keepalive_probes = 3 

$:net.ipv4.tcp_keepalive_intvl = 15

 


设置生效: source /etc/profle

猜你喜欢

转载自wujie2008.iteye.com/blog/1224098