linux某端口号链接数修改

1.vim /etc/sysctl.conf

修改

kernel.msgmnb = 655360

kernel.msgmax = 655360

net.core.somaxconn = 10240

增加以下数据

net.ipv4.ip_conntrack_max = 200000

fs.file-max = 1048576
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_mem = 786432 2097152 3145728
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216

2.增加以下数据

vim  /etc/security/limits.conf

* soft nofile 10240
* hard nofile 10240

3.增加以下数据

vim /etc/rc.local

ulimit -HSn 655360

4.执行命令

ulimit -n 655360

--------------------------------------------------------------

暂时笔记这样记录,因为有时候很蛋疼,这样的记录也不成功。

这个比较是成功后,在里面找出来的不同

后续找到规律再进行修改

 在一次偶然机会,复制了一份之前在其它服务器上配置过的sysctl.conf文件

然后使之生效sysctl.conf -p 就成功了

在sysctl.conf 里尽量把值增大一点,

硬链接这样修改 把值再增大一点

echo 10485760  > /proc/sys/fs/file-max

软连接可以这样修改

ulimit -n 655360         -------------暂且认为是软连接数的意思

先执行sysctl -p  

后再去执行ulimit -n  655360

 -------------------------------------------------

也可以试着ulimt -n 100,ulimit -n 1000,ulimit -n 60000,ulimit -n 600000.,一步一步的增加引诱

发现新大陆

只需要在/etc/security/limit.conf中

添加

*          soft    nofile     900000

*         hard   nofile     900000

ulimit  -n   655360   这个数据只正针对于当前打开的窗口有效,另起窗口,则失效

然后再重新打开一个窗口,查看ulimit -n的值,是否为永久生效

 1 # Kernel sysctl configuration file for Red Hat Linux
 2 #
 3 # For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
 4 # sysctl.conf(5) for more details.
 5 
 6 # Controls IP packet forwarding
 7 net.ipv4.ip_forward = 0
 8 
 9 # Controls source route verification
10 net.ipv4.conf.default.rp_filter = 1
11 #net.ipv4.conf_conntrack_max = 100000
12 
13 #net.ipv4.ip_local_port_range = 1024    65000
14 
15 # Do not accept source routing
16 net.ipv4.conf.default.accept_source_route = 0
17 
18 # Controls the System Request debugging functionality of the kernel
19 kernel.sysrq = 0
20 
21 # Controls whether core dumps will append the PID to the core filename.
22 # Useful for debugging multi-threaded applications.
23 kernel.core_uses_pid = 1
24 
25 # Controls the use of TCP syncookies
26 
27 net.ipv4.conf.default.rp_filter = 1
28 #net.ipv4.conf_conntrack_max = 100000
29 
30 #net.ipv4.ip_local_port_range = 1024    65000
31 
32 # Do not accept source routing
33 net.ipv4.conf.default.accept_source_route = 0
34 
35 # Controls the System Request debugging functionality of the kernel
36 kernel.sysrq = 0
37 
38 # Controls whether core dumps will append the PID to the core filename.
39 # Useful for debugging multi-threaded applications.
40 kernel.core_uses_pid = 1
41 
42 # Controls the use of TCP syncookies
43 net.ipv4.tcp_syncookies = 1
44 
45 # Disable netfilter on bridges.
46 net.bridge.bridge-nf-call-ip6tables = 0
47 net.bridge.bridge-nf-call-iptables = 0
48 net.bridge.bridge-nf-call-arptables = 0
49 
50 # Controls the default maxmimum size of a mesage queue
51 kernel.msgmnb = 655360
52 
53 # Controls the maximum size of a message, in bytes
54 kernel.msgmax = 655360
55 
56 # Controls the maximum shared segment size, in bytes
57 kernel.shmmax = 68719476736
58 
59 # Controls the maximum number of shared memory segments, in pages
60 kernel.shmall = 4294967296
61 net.core.somaxconn = 10240
View Code
原文地址:https://www.cnblogs.com/yecao8888/p/7080823.html