{"id":2339,"date":"2018-12-03T16:16:18","date_gmt":"2018-12-03T08:16:18","guid":{"rendered":"https:\/\/damogame.cn:15443\/wordpress\/?p=2339"},"modified":"2018-12-03T16:16:18","modified_gmt":"2018-12-03T08:16:18","slug":"linux%e7%9a%84ulimit%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/2339","title":{"rendered":"Linux\u7684ulimit\u547d\u4ee4"},"content":{"rendered":"<p>ulimit\u547d\u4ee4\u7528\u6765\u9650\u5236\u7cfb\u7edf\u7528\u6237\u5bf9shell\u8d44\u6e90\u7684\u8bbf\u95ee\u3002<\/p>\n<p><strong>\u8bed\u6cd5:<\/strong><\/p>\n<pre>ulimit [-acdfHlmnpsStv] [size]<\/pre>\n<p><strong>\u9009\u9879\u4ecb\u7ecd:<\/strong><br \/>\n-a \u663e\u793a\u5f53\u524d\u6240\u6709\u7684\u8d44\u6e90\u9650\u5236;<br \/>\n-c size: \u8bbe\u7f6ecore\u6587\u4ef6\u7684\u6700\u5927\u503c\uff0c\u5355\u4f4d:blocks;<br \/>\n-d size: \u8bbe\u7f6e\u6570\u636e\u6bb5\u7684\u6700\u5927\u503c\uff0c\u5355\u4f4d:kbytes;<br \/>\n-f size: \u8bbe\u7f6e\u521b\u5efa\u6587\u4ef6\u7684\u6700\u5927\u503c\uff0c\u5355\u4f4d:blocks;<br \/>\n-H: \u8bbe\u7f6e\u786c\u4ef6\u8d44\u6e90\u9650\u5236;<br \/>\n-l size: \u8bbe\u7f6e\u5728\u5185\u5b58\u4e2d\u9501\u5b9a\u8fdb\u7a0b\u7684\u6700\u5927\u503c\uff0c\u5355\u4f4d:kbytes;<br \/>\n-m size: \u8bbe\u7f6e\u53ef\u4ee5\u4f7f\u7528\u7684\u5e38\u9a7b\u5185\u5b58\u7684\u6700\u5927\u503c\uff0c\u5355\u4f4d:kbytes;<br \/>\n-n size: \u8bbe\u7f6e\u5185\u6838\u53ef\u4ee5\u540c\u65f6\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u6700\u5927\u503c;<br \/>\n-p size: \u8bbe\u7f6e\u7ba1\u9053\u7f13\u51b2\u533a\u7684\u6700\u5927\u503c\uff0c\u5355\u4f4d:kbytes;<br \/>\n-s size: \u8bbe\u7f6e\u5806\u6808\u7684\u6700\u5927\u503c\uff0c\u5355\u4f4d:kbytes;<br \/>\n-S: \u8bbe\u7f6e\u8f6f\u4ef6\u8d44\u6e90\u9650\u5236;<br \/>\n-t size: \u8bbe\u7f6eCPU\u4f7f\u7528\u65f6\u95f4\u7684\u6700\u5927\u4e0a\u9650\uff0c\u5355\u4f4d:seconds;<br \/>\n-v size: \u8bbe\u7f6e\u865a\u62df\u5185\u5b58\u7684\u6700\u5927\u503c.\u5355\u4f4d:kbytes;<\/p>\n<p>\u6ce8\u610f\uff1asize\u7684\u503c\u4e0d\u4e00\u5b9a\u8981\u6c42\u662f\u6570\u5b57\uff0c\u53ef\u4ee5\u662f<strong>unlimited<\/strong>\uff0c\u8868\u793a\u6ca1\u6709\u9650\u5236\u3002<\/p>\n<h5 id=\"\u8868\u683c 1|table\">\u8868 1. ulimit \u53c2\u6570\u8bf4\u660e<\/h5>\n<table class=\"ibm-data-table\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<thead>\n<tr>\n<th>\u9009\u9879 [options]<\/th>\n<th>\u542b\u4e49<\/th>\n<th>\u4f8b\u5b50<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>-H<\/td>\n<td>\u8bbe\u7f6e\u786c\u8d44\u6e90\u9650\u5236\uff0c\u4e00\u65e6\u8bbe\u7f6e\u4e0d\u80fd\u589e\u52a0\u3002<\/td>\n<td>ulimit \u2013 Hs 64\uff1b\u9650\u5236\u786c\u8d44\u6e90\uff0c\u7ebf\u7a0b\u6808\u5927\u5c0f\u4e3a 64K\u3002<\/td>\n<\/tr>\n<tr>\n<td>-S<\/td>\n<td>\u8bbe\u7f6e\u8f6f\u8d44\u6e90\u9650\u5236\uff0c\u8bbe\u7f6e\u540e\u53ef\u4ee5\u589e\u52a0\uff0c\u4f46\u662f\u4e0d\u80fd\u8d85\u8fc7\u786c\u8d44\u6e90\u8bbe\u7f6e\u3002<\/td>\n<td>ulimit \u2013 Sn 32\uff1b\u9650\u5236\u8f6f\u8d44\u6e90\uff0c32 \u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td>-a<\/td>\n<td>\u663e\u793a\u5f53\u524d\u6240\u6709\u7684 limit \u4fe1\u606f\u3002<\/td>\n<td>ulimit \u2013 a\uff1b\u663e\u793a\u5f53\u524d\u6240\u6709\u7684 limit \u4fe1\u606f\u3002<\/td>\n<\/tr>\n<tr>\n<td>-c<\/td>\n<td>\u6700\u5927\u7684 core \u6587\u4ef6\u7684\u5927\u5c0f\uff0c \u4ee5 blocks \u4e3a\u5355\u4f4d\u3002<\/td>\n<td>ulimit \u2013 c unlimited\uff1b \u5bf9\u751f\u6210\u7684 core \u6587\u4ef6\u7684\u5927\u5c0f\u4e0d\u8fdb\u884c\u9650\u5236\u3002<\/td>\n<\/tr>\n<tr>\n<td>-d<\/td>\n<td>\u8fdb\u7a0b\u6700\u5927\u7684\u6570\u636e\u6bb5\u7684\u5927\u5c0f\uff0c\u4ee5 Kbytes \u4e3a\u5355\u4f4d\u3002<\/td>\n<td>ulimit -d unlimited\uff1b\u5bf9\u8fdb\u7a0b\u7684\u6570\u636e\u6bb5\u5927\u5c0f\u4e0d\u8fdb\u884c\u9650\u5236\u3002<\/td>\n<\/tr>\n<tr>\n<td>-f<\/td>\n<td>\u8fdb\u7a0b\u53ef\u4ee5\u521b\u5efa\u6587\u4ef6\u7684\u6700\u5927\u503c\uff0c\u4ee5 blocks \u4e3a\u5355\u4f4d\u3002<\/td>\n<td>ulimit \u2013 f 2048\uff1b\u9650\u5236\u8fdb\u7a0b\u53ef\u4ee5\u521b\u5efa\u7684\u6700\u5927\u6587\u4ef6\u5927\u5c0f\u4e3a 2048 blocks\u3002<\/td>\n<\/tr>\n<tr>\n<td>-l<\/td>\n<td>\u6700\u5927\u53ef\u52a0\u9501\u5185\u5b58\u5927\u5c0f\uff0c\u4ee5 Kbytes \u4e3a\u5355\u4f4d\u3002<\/td>\n<td>ulimit \u2013 l 32\uff1b\u9650\u5236\u6700\u5927\u53ef\u52a0\u9501\u5185\u5b58\u5927\u5c0f\u4e3a 32 Kbytes\u3002<\/td>\n<\/tr>\n<tr>\n<td>-m<\/td>\n<td>\u6700\u5927\u5185\u5b58\u5927\u5c0f\uff0c\u4ee5 Kbytes \u4e3a\u5355\u4f4d\u3002<\/td>\n<td>ulimit \u2013 m unlimited\uff1b\u5bf9\u6700\u5927\u5185\u5b58\u4e0d\u8fdb\u884c\u9650\u5236\u3002<\/td>\n<\/tr>\n<tr>\n<td>-n<\/td>\n<td>\u53ef\u4ee5\u6253\u5f00\u6700\u5927\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u6570\u91cf\u3002<\/td>\n<td>ulimit \u2013 n 128\uff1b\u9650\u5236\u6700\u5927\u53ef\u4ee5\u4f7f\u7528 128 \u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td>-p<\/td>\n<td>\u7ba1\u9053\u7f13\u51b2\u533a\u7684\u5927\u5c0f\uff0c\u4ee5 Kbytes \u4e3a\u5355\u4f4d\u3002<\/td>\n<td>ulimit \u2013 p 512\uff1b\u9650\u5236\u7ba1\u9053\u7f13\u51b2\u533a\u7684\u5927\u5c0f\u4e3a 512 Kbytes\u3002<\/td>\n<\/tr>\n<tr>\n<td>-s<\/td>\n<td>\u7ebf\u7a0b\u6808\u5927\u5c0f\uff0c\u4ee5 Kbytes \u4e3a\u5355\u4f4d\u3002<\/td>\n<td>ulimit \u2013 s 512\uff1b\u9650\u5236\u7ebf\u7a0b\u6808\u7684\u5927\u5c0f\u4e3a 512 Kbytes\u3002<\/td>\n<\/tr>\n<tr>\n<td>-t<\/td>\n<td>\u6700\u5927\u7684 CPU \u5360\u7528\u65f6\u95f4\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\u3002<\/td>\n<td>ulimit \u2013 t unlimited\uff1b\u5bf9\u6700\u5927\u7684 CPU \u5360\u7528\u65f6\u95f4\u4e0d\u8fdb\u884c\u9650\u5236\u3002<\/td>\n<\/tr>\n<tr>\n<td>-u<\/td>\n<td>\u7528\u6237\u6700\u5927\u53ef\u7528\u7684\u8fdb\u7a0b\u6570\u3002<\/td>\n<td>ulimit \u2013 u 64\uff1b\u9650\u5236\u7528\u6237\u6700\u591a\u53ef\u4ee5\u4f7f\u7528 64 \u4e2a\u8fdb\u7a0b\u3002<\/td>\n<\/tr>\n<tr>\n<td>-v<\/td>\n<td>\u8fdb\u7a0b\u6700\u5927\u53ef\u7528\u7684\u865a\u62df\u5185\u5b58\uff0c\u4ee5 Kbytes \u4e3a\u5355\u4f4d\u3002<\/td>\n<td>ulimit \u2013 v 200000\uff1b\u9650\u5236\u6700\u5927\u53ef\u7528\u7684\u865a\u62df\u5185\u5b58\u4e3a 200000 Kbytes\u3002<\/p>\n<p>&nbsp;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u6267\u884c\u8303\u4f8b:<\/strong><br \/>\n\u5f53\u4f60\u6267\u884c\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u53d1\u73b0Can\u2019t open so many files\u7c7b\u4f3c\u7684\u9519\u8bef\uff0c\u5219\u662f\u56e0\u4e3a\u4f60\u7684\u7a0b\u5e8f\u6253\u5f00\u7684\u6587\u4ef6\u6570\u8d85\u8fc7\u7cfb\u7edf\u9ed8\u8ba4\u7684\u6700\u5927\u6587\u4ef6\u6570\u3002\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$ ulimit -n 20000\r\n$ ulimit -a\r\ncore file size          (blocks, -c) unlimited\r\ndata seg size           (kbytes, -d) unlimited\r\nfile size               (blocks, -f) unlimited\r\npending signals                 (-i) 1024\r\nmax locked memory       (kbytes, -l) 32\r\nmax memory size         (kbytes, -m) unlimited\r\nopen files                      (-n) 20000\r\npipe size            (512 bytes, -p) 8\r\nPOSIX message queues     (bytes, -q) 819200\r\nstack size              (kbytes, -s) 10240\r\ncpu time               (seconds, -t) unlimited\r\nmax user processes              (-u) 16381\r\nvirtual memory          (kbytes, -v) unlimited\r\nfile locks                      (-x) unlimited<\/pre>\n<p>&nbsp;<\/p>\n<p>ulimit\u547d\u4ee4\u9650\u5236\u8d44\u6e90\u7684\u4f7f\u7528,\u8bbe\u7f6e\u6587\u4ef6\u5728:<\/p>\n<p>\/etc\/security\/limits.conf<\/p>\n<p>\u6bd4\u5982:<\/p>\n<p>xok_la\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hard\u00a0\u00a0\u00a0 cpu\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1<br \/>\nxok_la\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hard\u00a0\u00a0\u00a0 fsize\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 50000<br \/>\nxok_la\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hard\u00a0\u00a0\u00a0 memlock\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1000<br \/>\nxok_la\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hard\u00a0\u00a0\u00a0 nofile\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 50<br \/>\nxok_la\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hard\u00a0\u00a0\u00a0 nproc\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 50<br \/>\n\u8fd9\u79cd\u65b9\u5f0f\u9650\u5236\u662f\u53ef\u4ee5\u7684,\u4ed6\u662f\u57fa\u4e8e\u7528\u6237\u6765\u9650\u5236\u7684,\u53ef\u4ee5\u9650\u5236\u5185\u5b58,CPU\u5360\u7528\u65f6\u95f4,\u6253\u5f00\u7684\u6587\u4ef6\u6570\u7b49\u7b49.\u524d\u63d0\u662f\u4f60\u8981\u767b\u9646\u5230\u8fd9\u4e2a\u7cfb\u7edf\u4e0a.\u5982\u679c\u53ea\u662f\u4ee5\u8fd9\u4e2a\u7528\u6237\u6765\u5355\u72ec\u8fd0\u884c\u6587\u4ef6\u7684\u8bdd,\u5c31\u4e0d\u884c\u2026\u2026<\/p>\n<p><strong>\u6269\u5c55\u9605\u8bfb:<\/strong><br \/>\nLinux\u4e0b\u8fdb\u7a0b\u6700\u5927\u6587\u4ef6\u6570\u4e3a1024\u3002<br \/>\n\u901a\u5e38\u4e00\u4e2ac,c++\u7684\u53ef\u6267\u884c\u6587\u4ef6\u51fa\u9519\u65f6\uff0c\u901a\u8fc7\u8c03core dump\u4f1a\u5feb\u901f\u5b9a\u4f4d\u5230\u4ee3\u7801\u51fa\u9519\u7684\u4f4d\u7f6e\u3002\u56e0\u6b64\uff0c\u4f60\u9700\u8981\u7528ulimit -c xxx\u8bbe\u7f6ecore\u6587\u4ef6\u6700\u5927\u503c\u3002\u9ed8\u8ba4\u4e3a0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ulimit\u547d\u4ee4\u7528\u6765\u9650\u5236\u7cfb\u7edf\u7528\u6237\u5bf9she<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[117],"class_list":["post-2339","post","type-post","status-publish","format-standard","hentry","tag-01-linux"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/2339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=2339"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/2339\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=2339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=2339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=2339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}