第一种方法:需要注意的是 只有在当前shell下生效(我不懂这个知识点,花了我好几个小时)
ulimit -n 3000 3000个连接数
ulimit -s 256 每个连接占内存
ulimit -a 查看 两个shell都必须设置
第二种方法:修改配置文件
两个文件内容(从网上搜到的试过了,但没起作用)
/etc/sysctl.conf
fs.file-max=65532
/etc/security/limits.conf
* soft nofile 32768
* hard nofile 32768
http://blog.yufeng.info/archives/1380
今天看了一下上面老大的文章 又尝试了一下OK 了
添加上 重启Shell OK
/etc/security/limits.conf
* soft nofile 32768
* hard nofile 32768
----修改相应的端口范围--------------------
vi /etc/sysctl.conf
添加
net.ipv4.ip_local_port_range = 1024 65535
执行sysctl -p 生效
查看
sysctl -a|grep ip_local_port_range
net.ipv4.ip_local_port_range = 32768 61000
-------------freebsd的配置-----------------
首先说明FreeBSD默认Shell是csh没有ulimit命令,但C Shell有limit命令。如果你想使用ulimit命令可以安装Bourne shell,Bash,Zsh
limit,ulimit比较
[neo@freebsd:~] limit cputime unlimited filesize unlimited datasize 32768MB stacksize 512MB coredumpsize unlimited memoryuse unlimited memorylocked unlimited maxproc 5547 descriptors 65536 sockbufsize unlimited vmemorysize unlimited NPTS unlimited SWAP unlimited [neo@freebsd:~] env | grep SHELL SHELL=/usr/local/bin/zsh [neo@freebsd:~] ulimit -a -t: cpu time (seconds) unlimited -f: file size (blocks) unlimited -d: data seg size (kbytes) 33554432 -s: stack size (kbytes) 524288 -c: core file size (blocks) unlimited -m: resident set size (kbytes) unlimited -l: locked-in-memory size (kb) unlimited -u: processes 5547 -n: file descriptors 65536 -N 9: socket buffer size (kb) unlimited -v: virtual memory size (kb) unlimited -N 11: unlimited -N 12: unlimited 在Freebsd上,你能使用sysctl命令:
以 nofile - max number of open files 为例,limit、ulimit、sysctl实现同样的功能。
csh% limit descriptors unlimited 或者 csh% limit descriptors 4096 sh$ ulimit -n unlimited 或者 sh$ ulimit -n 4096 sysctl kern.maxfiles=65536 sysctl kern.maxfilesperproc=65536
写入配置文件 sysctl.conf
[neo@freebsd:~] cat /etc/sysctl.conf # $FreeBSD: src/etc/sysctl.conf,v 1.8.34.1.4.1 2010/06/14 02:09:06 kensmith Exp $ # # This file is read when going to multi-user and its contents piped thru # ``sysctl'' to adjust kernel values. ``man 5 sysctl.conf'' for details. # # Uncomment this to prevent users from seeing information about processes that # are being run under another UID. #security.bsd.see_other_uids=0 #vm.pmap.shpgperproc: 2000 #vm.pmap.pv_entry_max: 13338058 kern.ipc.shm_use_phys=1 kern.maxfiles=65536 #ulimit -n 65536 kern.maxfilesperproc=65536 kern.ipc.somaxconn=2048 [neo@freebsd:~] /etc/rc.d/sysctl reload [neo@freebsd:~] sysctl -a | grep maxfiles kern.maxfiles: 65536 kern.maxfilesperproc: 65536 其他参考http://www.freebsd.org/doc/zh_CN/books/handbook/configtuning-kernel-limits.html
FreeBSD 查看端口号范围,并修改 meda076# sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last net.inet.ip.portrange.first: 10000 net.inet.ip.portrange.last: 65535 meda076# sysctl net.inet.ip.portrange.first=1024 net.inet.ip.portrange.first: 10000 -> 1024 meda076# sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last net.inet.ip.portrange.first: 1024 net.inet.ip.portrange.last: 65535