{"id":61396,"date":"2025-04-29T09:40:45","date_gmt":"2025-04-29T01:40:45","guid":{"rendered":"https:\/\/fwq.ai\/blog\/61396\/"},"modified":"2025-04-29T09:40:45","modified_gmt":"2025-04-29T01:40:45","slug":"%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%aecentos%e7%b3%bb%e7%bb%9f%e4%bb%a5%e9%99%90%e5%88%b6%e8%bf%9b%e7%a8%8b%e8%b5%84%e6%ba%90%e4%bd%bf%e7%94%a8%e7%9a%84%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/61396\/","title":{"rendered":"\u5982\u4f55\u914d\u7f6eCentOS\u7cfb\u7edf\u4ee5\u9650\u5236\u8fdb\u7a0b\u8d44\u6e90\u4f7f\u7528\u7684\u5b89\u5168\u7b56\u7565"},"content":{"rendered":"<p>\u5982\u4f55\u914d\u7f6e\u7cfb\u7edf\u4ee5\u9650\u5236\u8fdb\u7a0b\u8d44\u6e90\u4f7f\u7528\u7684\u5b89\u5168\u7b56\u7565<\/p>\n<p>\u5f15\u8a00:<br \/>\u5728\u4e00\u4e2a\u591a\u8fdb\u7a0b\u7684\u7cfb\u7edf\u4e2d\uff0c\u5408\u7406\u914d\u7f6e\u548c\u9650\u5236\u8fdb\u7a0b\u7684\u8d44\u6e90\u4f7f\u7528\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u5b83\u53ef\u4ee5\u4fdd\u8bc1\u7cfb\u7edf\u7684\u7a33\u5b9a\u6027\u548c\u5b89\u5168\u6027\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528CentOS\u7cfb\u7edf\u63d0\u4f9b\u7684\u5de5\u5177\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u6765\u9650\u5236\u8fdb\u7a0b\u7684\u8d44\u6e90\u4f7f\u7528\uff0c\u5e76\u63d0\u4f9b\u4e00\u4e9b\u5b9e\u7528\u7684\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<p>\u7b2c\u4e00\u90e8\u5206\uff1a\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>CentOS\u7cfb\u7edf\u63d0\u4f9b\u4e86\u4e00\u4e9b\u7528\u4e8e\u914d\u7f6e\u7cfb\u7edf\u8d44\u6e90\u9650\u5236\u7684\u6587\u4ef6\uff0c\u5b83\u4eec\u5206\u522b\u662f\uff1a\/etc\/security\/limits.conf\u548c\/etc\/sysctl.conf\u3002<\/p>\n<ol>\n<li>\/etc\/security\/limits.conf\u6587\u4ef6:<br \/>limits.conf\u6587\u4ef6\u7528\u4e8e\u914d\u7f6e\u7528\u6237\u6216\u7528\u6237\u7ec4\u7684\u8d44\u6e90\u9650\u5236\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91\u8fd9\u4e2a\u6587\u4ef6\u6765\u9650\u5236\u8fdb\u7a0b\u7684\u8d44\u6e90\u4f7f\u7528\u3002<\/li>\n<\/ol>\n<p>\u6253\u5f00\/etc\/security\/limits.conf\u6587\u4ef6\uff0c\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u793a\u4f8b\u5185\u5bb9\uff1a<\/p>\n<pre>#&lt;domain&gt;&lt;type&gt;&lt;item&gt;&lt;value&gt;\n#\n\n*               soft    core            0\n*               hard    rss             10000\n*               hard    nofile          10000\n*               soft    nofile          10000\n*               hard    stack           10000\n*               soft    stack           10000&lt;\/value&gt;&lt;\/item&gt;&lt;\/type&gt;&lt;\/domain&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff0c \u53ef\u4ee5\u662f\u7528\u6237\u6216\u7528\u6237\u7ec4\u7684\u540d\u79f0\uff0c\u4e5f\u53ef\u4ee5\u662f\u901a\u914d\u7b26*\uff1b \u662f\u8d44\u6e90\u9650\u5236\u7684\u7c7b\u578b\uff1b \u662f\u8d44\u6e90\u7684\u540d\u79f0\uff1b \u662f\u8d44\u6e90\u7684\u9650\u5236\u503c\u3002 <\/p>\n<p>\u4ee5\u9650\u5236\u8fdb\u7a0b\u7684\u6253\u5f00\u6587\u4ef6\u6570\u4e3a\u4f8b\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre>*               soft    nofile          400\n*               hard    nofile          600<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u6837\u914d\u7f6e\u540e\uff0c\u6240\u6709\u7528\u6237\u7684\u8fdb\u7a0b\u90fd\u4e0d\u5f97\u8d85\u8fc7400\u4e2a\u6253\u5f00\u6587\u4ef6\uff0c\u5e76\u4e14\u8d85\u8fc7600\u4e2a\u6253\u5f00\u6587\u4ef6\u7684\u8bf7\u6c42\u5c06\u88ab\u62d2\u7edd\u3002<\/p>\n<ol>\n<li>\/etc\/sysctl.conf\u6587\u4ef6:<br \/>sysctl.conf\u6587\u4ef6\u7528\u4e8e\u914d\u7f6e\u5185\u6838\u53c2\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91\u8fd9\u4e2a\u6587\u4ef6\u6765\u8c03\u6574\u7cfb\u7edf\u7684\u8d44\u6e90\u9650\u5236\u3002<\/li>\n<\/ol>\n<p>\u6253\u5f00\/etc\/sysctl.conf\u6587\u4ef6\uff0c\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u793a\u4f8b\u5185\u5bb9\uff1a<\/p>\n<pre># Kernel sysctl configuration file for Red Hat Linux\n\n# Disable source routing and redirects\nnet.ipv4.conf.all.accept_source_route = 0\nnet.ipv4.conf.all.send_redirects = 0\n\n# Disable ICMP redirects\nnet.ipv4.conf.all.accept_redirects = 0\nnet.ipv4.conf.all.secure_redirects = 0\n\n# Disable IP forwarding\nnet.ipv4.ip_forward = 0<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u8c03\u6574\u7cfb\u7edf\u7684\u5185\u5b58\u9650\u5236\u4e3a\u4f8b\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre># Adjust memory allocation\nvm.overcommit_memory = 2\nvm.swappiness = 10<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u6837\u914d\u7f6e\u540e\uff0c\u7cfb\u7edf\u5c06\u66f4\u52a0\u5408\u7406\u5730\u5206\u914d\u5185\u5b58\u8d44\u6e90\u3002<\/p>\n<p>\u7b2c\u4e8c\u90e8\u5206\uff1a\u5de5\u5177\u548c\u547d\u4ee4<\/p>\n<p>\u9664\u4e86\u914d\u7f6e\u6587\u4ef6\u4e4b\u5916\uff0cCentOS\u7cfb\u7edf\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5de5\u5177\u548c\u547d\u4ee4\uff0c\u7528\u4e8e\u52a8\u6001\u5730\u9650\u5236\u8fdb\u7a0b\u7684\u8d44\u6e90\u4f7f\u7528\u3002<\/p>\n<ol>\n<li>ulimit\u547d\u4ee4:<br \/>ulimit\u547d\u4ee4\u7528\u4e8e\u663e\u793a\u548c\u8bbe\u7f6e\u7528\u6237\u8fdb\u7a0b\u7684\u8d44\u6e90\u9650\u5236\u3002<\/li>\n<\/ol>\n<p>\u793a\u4f8b1: \u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u7684\u8d44\u6e90\u9650\u5236<\/p>\n<pre>ulimit -a<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u793a\u4f8b2: \u8bbe\u7f6e\u8fdb\u7a0b\u7684\u6253\u5f00\u6587\u4ef6\u6570\u9650\u5236\u4e3a1000<\/p>\n<pre>ulimit -n 1000<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>sysctl\u547d\u4ee4:<br \/>sysctl\u547d\u4ee4\u7528\u4e8e\u663e\u793a\u548c\u8bbe\u7f6e\u5185\u6838\u53c2\u6570\u3002<\/li>\n<\/ol>\n<p>\u793a\u4f8b1: \u67e5\u770b\u5f53\u524d\u5185\u6838\u53c2\u6570<\/p>\n<pre>sysctl -a<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u793a\u4f8b2: \u8bbe\u7f6e\u5185\u6838\u53c2\u6570vm.swappiness\u4e3a10<\/p>\n<pre>sysctl -w vm.swappiness=10<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7b2c\u4e09\u90e8\u5206\uff1a\u5b9e\u7528\u7684\u4ee3\u7801\u793a\u4f8b<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5728CentOS\u7cfb\u7edf\u4e0a\u9650\u5236\u8fdb\u7a0b\u8d44\u6e90\u4f7f\u7528\u7684\u5b9e\u7528\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<ol>\n<li>\n<p>\u9650\u5236\u8fdb\u7a0b\u7684\u6253\u5f00\u6587\u4ef6\u6570<\/p>\n<\/li>\n<li>soft nofile 400<\/li>\n<li>\n<p>hard nofile 600<\/p>\n<h1>\u82e5\u5df2\u7ecf\u767b\u5f55\u7684\u7528\u6237\u9700\u8981\u7acb\u5373\u83b7\u5f97\u65b0\u7684\u914d\u7f6e\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4<\/h1>\n<p>ulimit -n 400<\/p>\n<\/li>\n<li>\n<p>\u9650\u5236\u8fdb\u7a0b\u7684\u5185\u5b58\u4f7f\u7528<\/p>\n<pre># \u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u5230\/etc\/sysctl.conf\u6587\u4ef6\u672b\u5c3e\n# Adjust memory allocation\nvm.overcommit_memory = 2\nvm.swappiness = 10\n\n# \u82e5\u9700\u8981\u7acb\u5373\u751f\u6548\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\nsysctl -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p>\u7ed3\u8bba\uff1a<br \/>\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u548c\u547d\u4ee4\u6765\u9650\u5236CentOS\u7cfb\u7edf\u4e2d\u8fdb\u7a0b\u7684\u8d44\u6e90\u4f7f\u7528\uff0c\u6709\u52a9\u4e8e\u63d0\u9ad8\u7cfb\u7edf\u7684\u7a33\u5b9a\u6027\u548c\u5b89\u5168\u6027\u3002\u540c\u65f6\uff0c\u6211\u4eec\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5b9e\u7528\u7684\u4ee3\u7801\u793a\u4f8b\u4f5c\u4e3a\u53c2\u8003\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\uff0c\u795d\u60a8\u7684\u7cfb\u7edf\u8fd0\u884c\u987a\u5229\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u914d\u7f6eCentOS\u7cfb\u7edf\u4ee5\u9650\u5236\u8fdb\u7a0b\u8d44\u6e90\u4f7f\u7528\u7684\u5b89\u5168\u7b56\u7565\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u914d\u7f6e\u7cfb\u7edf\u4ee5\u9650\u5236\u8fdb\u7a0b\u8d44\u6e90\u4f7f\u7528\u7684\u5b89\u5168\u7b56\u7565 \u5f15\u8a00:\u5728\u4e00\u4e2a\u591a\u8fdb\u7a0b\u7684\u7cfb\u7edf\u4e2d\uff0c\u5408\u7406\u914d\u7f6e\u548c\u9650\u5236\u8fdb\u7a0b\u7684\u8d44\u6e90\u4f7f\u7528\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u5b83\u53ef\u4ee5\u4fdd\u8bc1\u7cfb\u7edf\u7684\u7a33\u5b9a\u6027\u548c\u5b89\u5168\u6027\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528CentOS\u7cfb\u7edf\u63d0\u4f9b\u7684\u5de5\u5177\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u6765\u9650\u5236\u8fdb\u7a0b\u7684\u8d44\u6e90\u4f7f\u7528\uff0c\u5e76\u63d0\u4f9b\u4e00\u4e9b\u5b9e\u7528\u7684\u4ee3\u7801\u793a\u4f8b\u3002 \u7b2c\u4e00\u90e8\u5206\uff1a\u914d\u7f6e\u6587\u4ef6 CentOS\u7cfb\u7edf\u63d0\u4f9b\u4e86\u4e00\u4e9b\u7528\u4e8e\u914d\u7f6e\u7cfb\u7edf\u8d44\u6e90\u9650\u5236\u7684\u6587\u4ef6\uff0c\u5b83\u4eec\u5206\u522b\u662f\uff1a\/etc\/security\/limits.conf\u548c\/etc\/sysctl.conf\u3002 \/etc\/security\/limits.conf\u6587\u4ef6:limits.conf\u6587\u4ef6\u7528\u4e8e\u914d\u7f6e\u7528\u6237\u6216\u7528\u6237\u7ec4\u7684\u8d44\u6e90\u9650\u5236\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91\u8fd9\u4e2a\u6587\u4ef6\u6765\u9650\u5236\u8fdb\u7a0b\u7684\u8d44\u6e90\u4f7f\u7528\u3002 \u6253\u5f00\/etc\/security\/limits.conf\u6587\u4ef6\uff0c\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u793a\u4f8b\u5185\u5bb9\uff1a #&lt;domain&gt;&lt;type&gt;&lt;item&gt;&lt;value&gt; # * soft core 0 * hard rss 10000 * hard nofile 10000 * soft nofile 10000 * hard stack 10000 * soft stack 10000&lt;\/value&gt;&lt;\/item&gt;&lt;\/type&gt;&lt;\/domain&gt; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0c \u53ef\u4ee5\u662f\u7528\u6237\u6216\u7528\u6237\u7ec4\u7684\u540d\u79f0\uff0c\u4e5f\u53ef\u4ee5\u662f\u901a\u914d\u7b26*\uff1b \u662f\u8d44\u6e90\u9650\u5236\u7684\u7c7b\u578b\uff1b \u662f\u8d44\u6e90\u7684\u540d\u79f0\uff1b \u662f\u8d44\u6e90\u7684\u9650\u5236\u503c\u3002 \u4ee5\u9650\u5236\u8fdb\u7a0b\u7684\u6253\u5f00\u6587\u4ef6\u6570\u4e3a\u4f8b\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\uff1a * soft nofile 400 * hard nofile 600 \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u6837\u914d\u7f6e\u540e\uff0c\u6240\u6709\u7528\u6237\u7684\u8fdb\u7a0b\u90fd\u4e0d\u5f97\u8d85\u8fc7400\u4e2a\u6253\u5f00\u6587\u4ef6\uff0c\u5e76\u4e14\u8d85\u8fc7600\u4e2a\u6253\u5f00\u6587\u4ef6\u7684\u8bf7\u6c42\u5c06\u88ab\u62d2\u7edd\u3002 \/etc\/sysctl.conf\u6587\u4ef6:sysctl.conf\u6587\u4ef6\u7528\u4e8e\u914d\u7f6e\u5185\u6838\u53c2\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91\u8fd9\u4e2a\u6587\u4ef6\u6765\u8c03\u6574\u7cfb\u7edf\u7684\u8d44\u6e90\u9650\u5236\u3002 \u6253\u5f00\/etc\/sysctl.conf\u6587\u4ef6\uff0c\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u793a\u4f8b\u5185\u5bb9\uff1a # Kernel sysctl configuration [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-61396","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=61396"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61396\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=61396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=61396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=61396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}