{"id":131202,"date":"2019-01-11T08:00:44","date_gmt":"2019-01-11T00:00:44","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=131202"},"modified":"2019-01-03T08:52:06","modified_gmt":"2019-01-03T00:52:06","slug":"ulimit-system-performance","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ulimit-system-performance.html","title":{"rendered":"Linux\u901a\u8fc7ulimit\u6539\u5584\u7cfb\u7edf\u6027\u80fd"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u7cfb\u7edf\u6027\u80fd\u4e00\u76f4\u662f\u4e00\u4e2a\u53d7\u5173\u6ce8\u7684\u8bdd\u9898\uff0c\u5982\u4f55\u901a\u8fc7\u6700\u7b80\u5355\u7684\u8bbe\u7f6e\u6765\u5b9e\u73b0\u6700\u6709\u6548\u7684\u6027\u80fd\u8c03\u4f18\uff0c\u5982\u4f55\u5728\u6709\u9650\u8d44\u6e90\u7684\u6761\u4ef6\u4e0b\u4fdd\u8bc1\u7a0b\u5e8f\u7684\u8fd0\u4f5c\uff0culimit \u662f\u6211\u4eec\u5728\u5904\u7406\u8fd9\u4e9b\u95ee\u9898\u65f6\uff0c\u7ecf\u5e38\u4f7f\u7528\u7684\u4e00\u79cd\u7b80\u5355\u624b\u6bb5\u3002ulimit \u662f\u4e00\u79cd linux \u7cfb\u7edf\u7684\u5185\u952e\u529f\u80fd\uff0c\u5b83\u5177\u6709\u4e00\u5957\u53c2\u6570\u96c6\uff0c\u7528\u4e8e\u4e3a\u7531\u5b83\u751f\u6210\u7684 shell \u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u7684\u8d44\u6e90\u4f7f\u7528\u8bbe\u7f6e\u9650\u5236\u3002\u672c\u6587\u5c06\u5728\u540e\u9762\u7684\u7ae0\u8282\u4e2d\u8be6\u7ec6\u8bf4\u660e ulimit \u7684\u529f\u80fd\uff0c\u4f7f\u7528\u4ee5\u53ca\u5b83\u7684\u5f71\u54cd\uff0c\u5e76\u4ee5\u5177\u4f53\u7684\u4f8b\u5b50\u6765\u8be6\u7ec6\u5730\u9610\u8ff0\u5b83\u5728\u9650\u5236\u8d44\u6e90\u4f7f\u7528\u65b9\u9762\u7684\u5f71\u54cd\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n ulimit\u7684\u529f\u80fd\u548c\u7528\u6cd5<\/strong><\/div>\n ulimit\u529f\u80fd\u7b80\u8ff0<\/strong><\/span><\/div>\n \u5047\u8bbe\u6709\u8fd9\u6837\u4e00\u79cd\u60c5\u51b5\uff0c\u5f53\u4e00\u53f0 Linux \u4e3b\u673a\u4e0a\u540c\u65f6\u767b\u9646\u4e86 10 \u4e2a\u4eba\uff0c\u5728\u7cfb\u7edf\u8d44\u6e90\u65e0\u9650\u5236\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd9 10 \u4e2a\u7528\u6237\u540c\u65f6\u6253\u5f00\u4e86 500 \u4e2a\u6587\u6863\uff0c\u800c\u5047\u8bbe\u6bcf\u4e2a\u6587\u6863\u7684\u5927\u5c0f\u6709 10M\uff0c\u8fd9\u65f6\u7cfb\u7edf\u7684\u5185\u5b58\u8d44\u6e90\u5c31\u4f1a\u53d7\u5230\u5de8\u5927\u7684\u6311\u6218\u3002\u800c\u5b9e\u9645\u5e94\u7528\u7684\u73af\u5883\u8981\u6bd4\u8fd9\u79cd\u5047\u8bbe\u590d\u6742\u7684\u591a\uff0c\u4f8b\u5982\u5728\u4e00\u4e2a\u5d4c\u5165\u5f0f\u5f00\u53d1\u73af\u5883\u4e2d\uff0c\u5404\u65b9\u9762\u7684\u8d44\u6e90\u90fd\u662f\u975e\u5e38\u7d27\u7f3a\u7684\uff0c\u5bf9\u4e8e\u5f00\u542f\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u6570\u91cf\uff0c\u5206\u914d\u5806\u6808\u7684\u5927\u5c0f\uff0cCPU \u65f6\u95f4\uff0c\u865a\u62df\u5185\u5b58\u5927\u5c0f\uff0c\u7b49\u7b49\uff0c\u90fd\u6709\u975e\u5e38\u4e25\u683c\u7684\u8981\u6c42\u3002\u8d44\u6e90\u7684\u5408\u7406\u9650\u5236\u548c\u5206\u914d\u3002<\/p>\n \u4e0d\u4ec5\u4ec5\u662f\u4fdd\u8bc1\u7cfb\u7edf\u53ef\u7528\u6027\u7684\u5fc5\u8981\u6761\u4ef6\uff0c\u4e5f\u4e0e\u7cfb\u7edf\u4e0a\u8f6f\u4ef6\u8fd0\u884c\u7684\u6027\u80fd\u6709\u7740\u5bc6\u4e0d\u53ef\u5206\u7684\u8054\u7cfb\u3002\u8fd9\u65f6\uff0culimit\u53ef\u4ee5\u8d77\u5230\u5f88\u5927\u7684\u4f5c\u7528\uff0c\u5b83\u662f\u4e00\u79cd\u7b80\u5355\u5e76\u4e14\u6709\u6548\u7684\u5b9e\u73b0\u8d44\u6e90\u9650\u5236\u7684\u65b9\u5f0f\u3002ulimit\u7528\u4e8e\u9650\u5236shell\u542f\u52a8\u8fdb\u7a0b\u6240\u5360\u7528\u7684\u8d44\u6e90\uff0c\u652f\u6301\u4ee5\u4e0b\u5404\u79cd\u7c7b\u578b\u7684\u9650\u5236\uff1a\u6240\u521b\u5efa\u7684\u5185\u6838\u6587\u4ef6\u7684\u5927\u5c0f\u3001\u8fdb\u7a0b\u6570\u636e\u5757\u7684\u5927\u5c0f\u3001Shell\u8fdb\u7a0b\u521b\u5efa\u6587\u4ef6\u7684\u5927\u5c0f\u3001\u5185\u5b58\u9501\u4f4f\u7684\u5927\u5c0f\u3001\u5e38\u9a7b\u5185\u5b58\u96c6\u7684\u5927\u5c0f\u3001\u6253\u5f00\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u6570\u91cf\u3001\u5206\u914d\u5806\u6808\u7684\u6700\u5927\u5927\u5c0f\u3001CPU \u65f6\u95f4\u3001\u5355\u4e2a\u7528\u6237\u7684\u6700\u5927\u7ebf\u7a0b\u6570\u3001Shell \u8fdb\u7a0b\u6240\u80fd\u4f7f\u7528\u7684\u6700\u5927\u865a\u62df\u5185\u5b58\u3002\u540c\u65f6\uff0c\u5b83\u652f\u6301\u786c\u8d44\u6e90\u548c\u8f6f\u8d44\u6e90\u7684\u9650\u5236\u3002<\/p>\n \u4f5c\u4e3a\u4e34\u65f6\u9650\u5236\uff0culimit \u53ef\u4ee5\u4f5c\u7528\u4e8e\u901a\u8fc7\u4f7f\u7528\u5176\u547d\u4ee4\u767b\u5f55\u7684 shell \u4f1a\u8bdd\uff0c\u5728\u4f1a\u8bdd\u7ec8\u6b62\u65f6\u4fbf\u7ed3\u675f\u9650\u5236\uff0c\u5e76\u4e0d\u5f71\u54cd\u4e8e\u5176\u4ed6 shell \u4f1a\u8bdd\u3002\u800c\u5bf9\u4e8e\u957f\u671f\u7684\u56fa\u5b9a\u9650\u5236\uff0culimit \u547d\u4ee4\u8bed\u53e5\u53c8\u53ef\u4ee5\u88ab\u6dfb\u52a0\u5230\u7531\u767b\u5f55 shell \u8bfb\u53d6\u7684\u6587\u4ef6\u4e2d\uff0c\u4f5c\u7528\u4e8e\u7279\u5b9a\u7684 shell \u7528\u6237\u3002<\/p>\n \u5982\u4f55\u4f7f\u7528ulimit<\/strong><\/span><\/div>\n ulimit\u901a\u8fc7\u4e00\u4e9b\u53c2\u6570\u9009\u9879\u6765\u7ba1\u7406\u4e0d\u540c\u79cd\u7c7b\u7684\u7cfb\u7edf\u8d44\u6e90\u3002\u5728\u672c\u8282\uff0c\u6211\u4eec\u5c06\u8bb2\u89e3\u8fd9\u4e9b\u53c2\u6570\u7684\u4f7f\u7528\u3002<\/p>\n ulimit\u547d\u4ee4\u7684\u683c\u5f0f\u4e3a\uff1a<\/p>\n \r\n$ ulimit [options] [limit]\r\n[options]\r\n\r\n-H: \u8bbe\u7f6e\u786c\u8d44\u6e90\u9650\u5236\uff0c\u4e00\u65e6\u8bbe\u7f6e\u4e0d\u80fd\u589e\u52a0\u3002\u5982\uff0culimit -Hs 64\uff1b\u9650\u5236\u786c\u8d44\u6e90\uff0c\u7ebf\u7a0b\u6808\u5927\u5c0f\u4e3a64K\u3002\r\n\r\n-S: \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\u5982\uff0culimit -Sn 32\uff1b\u9650\u5236\u8f6f\u8d44\u6e90\uff0c32\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002\r\n\r\n-a: \u663e\u793a\u5f53\u524d\u6240\u6709\u7684limit\u4fe1\u606f\u3002\u5982\uff0culimit -a\uff1b\u663e\u793a\u5f53\u524d\u6240\u6709\u7684limit\u4fe1\u606f\u3002\r\n\r\n-c: \u6700\u5927\u7684core\u6587\u4ef6\u7684\u5927\u5c0f\uff0c \u4ee5blocks\u4e3a\u5355\u4f4d\u3002\u5982\uff0culimit -c unlimited\uff1b\u5bf9\u751f\u6210\u7684core\u6587\u4ef6\u7684\u5927\u5c0f\u4e0d\u8fdb\u884c\u9650\u5236\u3002\r\n\r\n-d: \u8fdb\u7a0b\u6700\u5927\u7684\u6570\u636e\u6bb5\u7684\u5927\u5c0f\uff0c\u4ee5Kbytes\u4e3a\u5355\u4f4d\u3002\u5982\uff0culimit -d unlimited\uff1b\u5bf9\u8fdb\u7a0b\u7684\u6570\u636e\u6bb5\u5927\u5c0f\u4e0d\u8fdb\u884c\u9650\u5236\u3002\r\n\r\n-f: \u8fdb\u7a0b\u53ef\u4ee5\u521b\u5efa\u6587\u4ef6\u7684\u6700\u5927\u503c\uff0c\u4ee5 blocks \u4e3a\u5355\u4f4d\u3002\u5982\uff0culimit -f 2048\uff1b\u9650\u5236\u8fdb\u7a0b\u53ef\u4ee5\u521b\u5efa\u7684\u6700\u5927\u6587\u4ef6\u5927\u5c0f\u4e3a2048 blocks\u3002\r\n\r\n-l: \u6700\u5927\u53ef\u52a0\u9501\u5185\u5b58\u5927\u5c0f\uff0c\u4ee5Kbytes\u4e3a\u5355\u4f4d\u3002\u5982\uff0culimit -l 32\uff1b\u9650\u5236\u6700\u5927\u53ef\u52a0\u9501\u5185\u5b58\u5927\u5c0f\u4e3a32Kbytes\u3002\r\n\r\n-m: \u6700\u5927\u5185\u5b58\u5927\u5c0f\uff0c\u4ee5Kbytes\u4e3a\u5355\u4f4d\u3002\u5982\uff0culimit -m unlimited\uff1b\u5bf9\u6700\u5927\u5185\u5b58\u4e0d\u8fdb\u884c\u9650\u5236\u3002\r\n\r\n-n: \u53ef\u4ee5\u6253\u5f00\u6700\u5927\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u6570\u91cf\u3002\u5982\uff0culimit -n 128\uff1b\u9650\u5236\u6700\u5927\u53ef\u4ee5\u4f7f\u7528128\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002\r\n\r\n-p: \u7ba1\u9053\u7f13\u51b2\u533a\u7684\u5927\u5c0f\uff0c\u4ee5Kbytes\u4e3a\u5355\u4f4d\u3002\u5982\uff0culimit -p 512\uff1b\u9650\u5236\u7ba1\u9053\u7f13\u51b2\u533a\u7684\u5927\u5c0f\u4e3a512Kbytes\u3002\r\n\r\n-s: \u7ebf\u7a0b\u6808\u5927\u5c0f\uff0c\u4ee5Kbytes\u4e3a\u5355\u4f4d\u3002\u5982\uff0c\u5982\uff0culimit -s 512\uff1b\u9650\u5236\u7ebf\u7a0b\u6808\u7684\u5927\u5c0f\u4e3a512Kbytes\u3002\r\n\r\n-t: \u6700\u5927\u7684CPU\u5360\u7528\u65f6\u95f4\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\u3002 \u5982\uff0culimit -t unlimited\uff1b\u5bf9\u6700\u5927\u7684CPU\u5360\u7528\u65f6\u95f4\u4e0d\u8fdb\u884c\u9650\u5236\u3002\r\n\r\n-u: \u7528\u6237\u6700\u5927\u53ef\u7528\u7684\u8fdb\u7a0b\u6570\u3002\u5982\uff0culimit -u 64\uff1b\u9650\u5236\u7528\u6237\u6700\u591a\u53ef\u4ee5\u4f7f\u752864\u4e2a\u8fdb\u7a0b\u3002\r\n\r\n-v: \u8fdb\u7a0b\u6700\u5927\u53ef\u7528\u7684\u865a\u62df\u5185\u5b58\uff0c\u5982\uff0c\u4ee5Kbytes\u4e3a\u5355\u4f4d\u3002\u5982\uff0culimit -v 200000\uff1b\u9650\u5236\u6700\u5927\u53ef\u7528\u7684\u865a\u62df\u5185\u5b58\u4e3a200000Kbytes\u3002\r\n<\/pre>\n |