{"id":2221,"date":"2014-08-16T14:42:08","date_gmt":"2014-08-15T22:42:08","guid":{"rendered":"https:\/\/www.csslayer.info\/wordpress\/?p=2221"},"modified":"2014-08-16T14:42:10","modified_gmt":"2014-08-16T06:42:10","slug":"limit-user-memory-usage-with-systemd","status":"publish","type":"post","link":"https:\/\/www.csslayer.info\/wordpress\/diary\/limit-user-memory-usage-with-systemd\/","title":{"rendered":"\u7528 systemd \u9650\u5236\u7528\u6237\u7684\u5185\u5b58\u4f7f\u7528"},"content":{"rendered":"<p><html><head><\/head><body><\/p>\n<p>\u529f\u80fd\u4e0a\u90fd\u662f cgroup \u7684\u529f\u52b3\uff0c\u4f46\u662f systemd \u63d0\u4f9b\u4e86\u4e00\u4e2a\u5bb9\u6613\u4f7f\u7528\u7684\u4ecb\u9762\u3002<\/p>\n<p>\u4f5c\u5927\u6b7b\u628a ext4 \u6362\u6210\u4e86 btrfs\uff0c\u4ee5\u524d\u66fe\u7ecf\u6709\u5f88\u591a\u65ad\u70b9\u4e4b\u540e\u5c31\u518d\u4e5f\u8d77\u4e0d\u6765\u7684\u4e8b\u60c5\u3002<\/p>\n<p>\u7535\u6c60\u6ca1\u7535\u5012\u4e0d\u662f\u7279\u522b\u62c5\u5fc3\uff0c\u56e0\u4e3a\u6211\u7535\u6e90\u7ba1\u7406\u8bbe\u7f6e\u6210\u4e86\u5371\u6025\u7535\u91cf\u5c31\u5173\u673a\u3002<\/p>\n<p>\u62c5\u5fc3\u7684\u4e8b\u60c5\u5c31\u662f\u73b0\u5728\u90fd\u4e0d\u7528 swap \u4e86\uff0c\u4e07\u4e00\u54ea\u5929\u6709\u4e2a\u8fdb\u7a0b\u62bd\u98ce\uff08\u5bf9\u6211\u8bf4\u7684\u5c31\u662f\u4f60\uff0ctelepathy-gabble\uff09\uff0c\u7528\u5149\u5185\u5b58\u5bfc\u81f4\u8981\u5f3a\u5236\u5173\u673a\u600e\u4e48\u529e\u3002<\/p>\n<p>systemd \u63d0\u4f9b\u4e86 user.slice \u548c user-id.slice \u6765\u8bbf\u95ee\u7528\u6237\u7684\u8fdb\u7a0b\uff0c\u4e8e\u662f\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u6765\u9650\u5236\u6240\u6709\u7528\u6237\u8fdb\u7a0b\u4e00\u5171\u53ea\u80fd\u4f7f\u7528 7G \u5185\u5b58\u3002<\/p>\n<p>systemctl set-property user.slice MemoryLimit=7G<\/p>\n<p>\u5185\u5b58\u8d85\u6807\u5c31\u4f1a\u88ab\u7b80\u5355\u7c97\u66b4\u7684\u6740\u6389\uff08\u603b\u6bd4\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u90a3\u5565\u597d\u70b9\u2026\u2026<\/p>\n<p>\u5f53\u7136\u9488\u5bf9\u5176\u4ed6 unit \u4e5f\u53ef\u4ee5\u65b9\u4fbf\u7684\u9650\u5236\u5185\u5b58\u4f7f\u7528\u3002<\/p>\n<p><strike>\u00ac _ \u00ac \u7cfb\u7edf\u8fdb\u7a0b\u4f60\u6700\u597d\u522b\u7ed9\u6211\u4f5c\u6b7b\u3002<\/strike><\/p>\n<p><\/body><\/html><\/p>\n<p>=-=-=-=-=<br \/><i>Powered by <b><a href='http:\/\/blogilo.gnufolks.org\/'>Blogilo<\/a><\/b><\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u529f\u80fd\u4e0a\u90fd\u662f cgroup \u7684\u529f\u52b3\uff0c\u4f46\u662f systemd \u63d0\u4f9b\u4e86\u4e00\u4e2a\u5bb9\u6613\u4f7f\u7528\u7684\u4ecb\u9762\u3002 \u4f5c\u5927\u6b7b\u628a ext4 \u6362\u6210\u4e86 btrfs\uff0c\u4ee5\u524d\u66fe\u7ecf\u6709\u5f88\u591a\u65ad\u70b9\u4e4b\u540e\u5c31\u518d\u4e5f\u8d77\u4e0d\u6765\u7684\u4e8b\u60c5\u3002 \u7535\u6c60\u6ca1\u7535\u5012\u4e0d\u662f\u7279\u522b\u62c5\u5fc3\uff0c\u56e0\u4e3a\u6211\u7535\u6e90\u7ba1\u7406\u8bbe\u7f6e\u6210\u4e86\u5371\u6025\u7535\u91cf\u5c31\u5173\u673a\u3002 \u62c5\u5fc3\u7684\u4e8b\u60c5\u5c31\u662f\u73b0\u5728\u90fd\u4e0d\u7528 swap \u4e86\uff0c\u4e07\u4e00\u54ea\u5929\u6709\u4e2a\u8fdb\u7a0b\u62bd\u98ce\uff08\u5bf9\u6211\u8bf4\u7684\u5c31\u662f\u4f60\uff0ctelepathy-gabble\uff09\uff0c\u7528\u5149\u5185\u5b58\u5bfc\u81f4\u8981\u5f3a\u5236\u5173\u673a\u600e\u4e48\u529e\u3002 systemd \u63d0\u4f9b\u4e86 user.slice \u548c user-id.slice \u6765\u8bbf\u95ee\u7528\u6237\u7684\u8fdb\u7a0b\uff0c\u4e8e\u662f\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u6765\u9650\u5236\u6240\u6709\u7528\u6237\u8fdb\u7a0b\u4e00\u5171\u53ea\u80fd\u4f7f\u7528 7G \u5185\u5b58\u3002 systemctl set-property user.slice MemoryLimit=7G \u5185\u5b58\u8d85\u6807\u5c31\u4f1a\u88ab\u7b80\u5355\u7c97\u66b4\u7684\u6740\u6389\uff08\u603b\u6bd4\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u90a3\u5565\u597d\u70b9\u2026\u2026 \u5f53\u7136\u9488\u5bf9\u5176\u4ed6 unit \u4e5f\u53ef\u4ee5\u65b9\u4fbf\u7684\u9650\u5236\u5185\u5b58\u4f7f\u7528\u3002 \u00ac _ \u00ac \u7cfb\u7edf\u8fdb\u7a0b\u4f60\u6700\u597d\u522b\u7ed9\u6211\u4f5c\u6b7b\u3002 =-=-=-=-=Powered by Blogilo<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-2221","post","type-post","status-publish","format-standard","hentry","category-diary"],"_links":{"self":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/comments?post=2221"}],"version-history":[{"count":1,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2221\/revisions"}],"predecessor-version":[{"id":2222,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2221\/revisions\/2222"}],"wp:attachment":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/media?parent=2221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/categories?post=2221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/tags?post=2221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}