在*nux中,对于每个用户,系统限制其最大进程数、文件数……。为提高性能,可以根据设备资源情况,设置各用户的最大进程数,文件数等等
在mac中,要设置这些系统值,也使用这些命令。

可以用ulimit -a 来显示当前的各种用户进程限制。

$ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited$ ulimit -n 1000$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1000
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited$ 

在服务器类中,可能要对可以使用的socket端口等限制放大,修改其值

$ ulimit -n 1000
$

如果修改太大,并不一定成功。

$ ulimit -n 100000
-bash: ulimit: open files: cannot modify limit: Operation not permitted

这是,需要使用的命令是launchctl和sysctl

  • sysctl 命令:
NAMEsysctl -- get or set kernel stateSYNOPSISsysctl [-bdehiNnoqx] name[=value] ...sysctl [-bdehNnoqx] -aDESCRIPTIONThe sysctl utility retrieves kernel state and allows processes with appropriate privilege to set kernelstate.  The state to be retrieved or set is described using a ``Management Information Base'' (``MIB'')style name, described as a dotted set of components.The following options are available:-A      Equivalent to -o -a (for compatibility).-a      List all the currently available non-opaque values.  This option is ignored if one or more variablenames are specified on the command line.... ...          

可以尝试使用sysctl -a 来列出系统状态值,这是一个超长的列表。

  • launchctl 命令
NAMElaunchctl -- Interfaces with launchdSYNOPSISlaunchctl subcommand [arguments ...]DESCRIPTIONlaunchctl interfaces with launchd to manage and inspect daemons, agents and XPC services.SUBCOMMANDSlaunchctl allows for detailed examination of launchd endpoints. A domain manages the execution policy for acollection of services.  A service may be thought of as a virtual process that is always available to bespawned in response to demand. Each service has a collection of endpoints, and sending a message to one ofthose endpoints will cause the service to launch on demand. Domains advertise these endpoints in a sharednamespace and may be thought of as synonymous with Mach bootstrap subsets.Many subcommands in launchctl take a specifier which indicates the target domain or service for the subcom-mand. This specifier may take one of the following forms:system/[service-name]Targets the system domain or a service within the system domain. The system domain manages the rootMach bootstrap and is considered a privileged execution context. Anyone may read or query the sys-tem domain, but root privileges are required to make modifications.user/<uid>/[service-name]Targets the user domain for the given UID or a service within that domain. A user domain may existindependently of a logged-in user. User domains do not exist on iOS.login/<asid>/[service-name]Targets a user-login domain or service within that domain. A user-login domain is created when theuser logs in at the GUI and is identified by the audit session identifier associated with thatlogin. If a user domain has an associated login domain, the print subcommand will display the ASIDof that login domain. User-login domains do not exist on iOS.gui/<uid>/[service-name]Another form of the login specifier. Rather than specifying a user-login domain by its ASID, thisspecifier targets the domain based on which user it is associated with and is generally more conve-nient.Note: GUI domains and user domains share many resources. For the purposes of the Mach bootstrapname lookups, they are "flat", so they share the same set of registered names. But they still havediscrete sets of services. So when printing the user domain's contents, you may see many Mach boot-strap name registrations from services that exist in the GUI domain for that user, but you will notsee the services themselves in that list.session/<asid>/[service-name]Targets the session domain for the given audit session ID or a service within that domain. For moreinformation about audit sessions, see auditon(2) and libbsm(3)pid/<pid>/[service-name]Targets the domain for the given PID or a service within that domain. Each process on the systemwill have a PID domain associated with it that consists of the XPC services visible to that processwhich can be reached with xpc_connection_create(3).... ... ... ... 
  • 设置打开文件数
$sudo launchctl limit maxfiles 100000 500000
$sudo ulimit -n 100000
  • 设置进程数
$sudo launchctl limit maxproc 100000 100000
$ launchctl limit cpu         unlimited      unlimited      filesize    unlimited      unlimited      data        unlimited      unlimited      stack       8388608        67104768       core        0              unlimited      rss         unlimited      unlimited      memlock     unlimited      unlimited      maxproc     709            1064           maxfiles    100000         100000 $sysctl -a  | grep "files"
kern.maxfiles: 100000
kern.maxfilesperproc: 100000
kern.num_files: 7622

要查看有哪些项是可以修改的,请使用命令man 3 sysctl,其列出了各种类型的配置变量,还有哪些是可以修改,哪些不可以修改。

$sudo ulimit -u 1064
  • 设置端口
$sudo sysctl net.inet.ip.portrange.first=10000

要想支持更高数量的TCP并发连接的通讯处理程序,就必须修改系统对当前用户的进程同时打开的文件数量的软限制(soft limit)和硬限制(hardlimit)。其中软限制是指Linux在当前系统能够承受的告警范围内进一步限制用户同时打开的文件数,超过则会告警;硬限制则是根据系统硬件资源状况(主要是系统内存)计算出来的系统最多可同时打开的文件数量,超过则无法打开了。

查看网络的设置

$ sysctl -a | grep "net.inet.ip"
net.inet.ip.portrange.lowfirst: 1023
net.inet.ip.portrange.lowlast: 600
net.inet.ip.portrange.first: 49152
net.inet.ip.portrange.last: 65535
net.inet.ip.portrange.hifirst: 49152
net.inet.ip.portrange.hilast: 65535
net.inet.ip.forwarding: 0
net.inet.ip.redirect: 1
net.inet.ip.ttl: 64
net.inet.ip.rtexpire: 2400
net.inet.ip.rtminexpire: 10
net.inet.ip.rtmaxcache: 128
net.inet.ip.sourceroute: 0
net.inet.ip.accept_sourceroute: 0
net.inet.ip.gifttl: 30
net.inet.ip.subnets_are_local: 0
net.inet.ip.mcast.maxgrpsrc: 512
net.inet.ip.mcast.maxsocksrc: 128
net.inet.ip.mcast.loop: 1
net.inet.ip.dummynet.hash_size: 64
net.inet.ip.dummynet.curr_time: 0
net.inet.ip.dummynet.ready_heap: 0
net.inet.ip.dummynet.extract_heap: 0
net.inet.ip.dummynet.searches: 0
net.inet.ip.dummynet.search_steps: 0
net.inet.ip.dummynet.expire: 1
net.inet.ip.dummynet.max_chain_len: 16
net.inet.ip.dummynet.red_lookup_depth: 256
net.inet.ip.dummynet.red_avg_pkt_size: 512
net.inet.ip.dummynet.red_max_pkt_size: 1500
net.inet.ip.dummynet.debug: 0
net.inet.ip.fw.enable: 1
net.inet.ip.fw.autoinc_step: 100
net.inet.ip.fw.one_pass: 0
net.inet.ip.fw.debug: 0
net.inet.ip.fw.verbose: 0
net.inet.ip.fw.verbose_limit: 0
net.inet.ip.fw.dyn_buckets: 256
net.inet.ip.fw.curr_dyn_buckets: 256
net.inet.ip.fw.dyn_count: 0
net.inet.ip.fw.dyn_max: 4096
net.inet.ip.fw.static_count: 1
net.inet.ip.fw.dyn_ack_lifetime: 300
net.inet.ip.fw.dyn_syn_lifetime: 20
net.inet.ip.fw.dyn_fin_lifetime: 1
net.inet.ip.fw.dyn_rst_lifetime: 1
net.inet.ip.fw.dyn_udp_lifetime: 10
net.inet.ip.fw.dyn_short_lifetime: 5
net.inet.ip.fw.dyn_keepalive: 1
net.inet.ip.random_id_statistics: 0
net.inet.ip.random_id_collisions: 0
net.inet.ip.random_id_total: 0
net.inet.ip.sendsourcequench: 0
net.inet.ip.maxfragpackets: 2048
net.inet.ip.fragpackets: 0
net.inet.ip.maxfragsperpacket: 128
net.inet.ip.scopedroute: 1
net.inet.ip.adj_clear_hwcksum: 0
net.inet.ip.check_interface: 0
net.inet.ip.rx_chaining: 1
net.inet.ip.rx_chainsz: 6
net.inet.ip.input_perf: 0
net.inet.ip.input_perf_bins: 0
net.inet.ip.linklocal.in.allowbadttl: 1
net.inet.ip.random_id: 1
net.inet.ip.maxchainsent: 11
net.inet.ip.select_srcif_debug: 0
net.inet.ip.output_perf: 0
net.inet.ip.output_perf_bins: 0
net.inet.ipsec.def_policy: 1
net.inet.ipsec.esp_trans_deflev: 1
net.inet.ipsec.esp_net_deflev: 1
net.inet.ipsec.ah_trans_deflev: 1
net.inet.ipsec.ah_net_deflev: 1
net.inet.ipsec.ah_cleartos: 1
net.inet.ipsec.ah_offsetmask: 0
net.inet.ipsec.dfbit: 0
net.inet.ipsec.ecn: 0
net.inet.ipsec.debug: 0
net.inet.ipsec.esp_randpad: -1
net.inet.ipsec.bypass: 1
net.inet.ipsec.esp_port: 4500

mac中修改系统限制量--ulimit和sysctl相关推荐

  1. 怎样使用mac终端修改系统时间

    如何使用mac终端修改系统时间啊?别急,小编给大家带来了使用mac终端修改系统时间,感兴趣的快来跟小编看看吧! 具体操作步骤如下: 一.首先通过做好的Mac系统u盘启动,等待加载过去后,选择" ...

  2. qt中修改系统或用户环境变量

    要修改系统的环境变量只能是修改注册表. 1.修改或增加系统的环境变量,vista以上的系统需要uac权限 <1>注册表地址:HKEY_LOCAL_MACHINE\SYSTEM\Contro ...

  3. android 系统中修改系统的版本号

    最近在做android 9.0的项目,发现在setting==>About==>status==>Version 中显示的Android 系统的版本号为9,看着很别扭.于是想要修改为 ...

  4. mac中修改文件需要管理员权限

    最近在做项目时,修改个别文件出现以下提示"权限不足,以管理员身份重试",每次修改都需要输入电脑密码.如下图: 后发现是文件设置了权限,通过右击文件查看简介 发现权限中,并不包含管理 ...

  5. 在MAC 中修改虚拟机配置文件

    我们很多时候需要修改Vmware 配置,比如要修改网卡的类型 ,要修改配置文件(.vmx文件),但是一个虚拟机就一个 vmwarevm 文件, 从哪里去寻找这个vmx配置文件呢? 本文提供一个简单易用 ...

  6. MAC中修改word默认字体

    1,打开Word,在顶栏的"格式"菜单上单击"字体",然后单击"字体"选项卡.(快捷键⌘+D) 2,设置想要设置的字体和大小,然后在左下角中 ...

  7. 在Linux中修改系统的IP地址

    1.root用户登陆进linux su - root cd root 2.查看IP ifconfig 3.更改IP网址: vi /etc/sysconfig/network-scripts/ifcfg ...

  8. 查看SQL Server Resource Database以及修改系统表

    参考文献: SQL 2005修改系统表 SQL Server 2005中修改系统表的方法 如何登入DAC(SQL Server 2005) ResourceDB Location Changes Re ...

  9. 转-SQL 2005修改系统表

    FROM:http://blog.csdn.net/liangCK/archive/2008/10/07/3029315.aspx 在 SQL Server 2000 中修改系统表的方法大部分人都知道 ...

最新文章

  1. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(32)-swfupload多文件上传[附源码]...
  2. 什么电线适合在面包板上布线?
  3. 华为p4支持鸿蒙功能吗_华为鸿蒙系统可以用了,支持这四款手机,看看有你的吗?...
  4. mysql数据库运行远程用户访问不了_MySQL数据库远程访问权限如何打开(两种方法)...
  5. boost::gil::bit_aligned_pixel_reference用法的测试程序
  6. 计算机教育日志,信息技术日志1
  7. 使用 Visual Studio 对源代码文件进行哈希处理以确保文件完整性
  8. c 语言输出指针的值,C 语言指针
  9. 前端学习(2625):vs安装
  10. 复习Java的精华总结
  11. jsp中el表达式创建一个list
  12. oracle中job的retry次数,有大佬帮忙看下我安装过程中到底出啥问题了么..
  13. 【答辩问题】计算机专业本科毕业设计答辩的一般程序3
  14. python软件下载3版本-Python3.9下载
  15. sublime text3 智能提示和自动补全
  16. Ubuntu系统lamp环境下安装wordpress、zencert和mangento程序网站
  17. 怎么看python帮助手册常见问题商家认证_问题:使用help命令可以查看python模块的帮助文档。...
  18. #FFMPEG4.3.1#命令行实现视频码率转换、缩放、剪切、填充、旋转操作(3)
  19. Nuvoton I91200 SDS- AudioPlayback
  20. 安卓手机软件性能测试,手机性能评测软件

热门文章

  1. selenium对富文本的操作
  2. Python String 方法详解
  3. 微软公司部署小型数据中心网络连接产品
  4. Oracle索引或这类索引的分区处于不可用状态 查询
  5. c语言五子棋代码_基于控制台的C语言贪吃蛇
  6. 机械制图符号_《机械制图》试卷
  7. 使用eclipse生成文档(javadoc)
  8. murmur3 php,MySQL5.7 切不要乱射 --transaction-write-set-extraction=MURMUR32
  9. for循环批量写文件 shell_shell之for循环的3个简单脚本
  10. 在哪里查看计算机配置的网络协议簇,tcp/ip协议簇