{"id":3519,"date":"2021-03-27T20:50:14","date_gmt":"2021-03-27T12:50:14","guid":{"rendered":"http:\/\/blog.ywdevops.cn\/?p=3519"},"modified":"2021-03-27T20:50:40","modified_gmt":"2021-03-27T12:50:40","slug":"cgroup","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2021\/03\/27\/cgroup\/","title":{"rendered":"linux\u7cfb\u7edfcgroup\u7b80\u4ecb"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">cgroups\u662fLinux\u4e0b\u63a7\u5236\u4e00\u4e2a\uff08\u6216\u4e00\u7ec4\uff09\u8fdb\u7a0b\u7684\u8d44\u6e90\u9650\u5236\u673a\u5236\uff0c\u5168\u79f0\u662fcontrol groups\uff0c \u53ef\u4ee5\u5bf9cpu\u3001\u5185\u5b58\u7b49\u8d44\u6e90\u505a\u7cbe\u7ec6\u5316\u63a7\u5236\uff0c\u6bd4\u5982\u76ee\u524d\u5f88\u591a\u7684Docker\u5728Linux\u4e0b\u5c31\u662f\u57fa\u4e8ecgroups\u63d0\u4f9b\u7684\u8d44\u6e90\u9650\u5236\u673a\u5236\u6765\u5b9e\u73b0\u8d44\u6e90\u63a7\u5236\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9664\u6b64\u4e4b\u5916\uff0c\u5f00\u53d1\u8005\u4e5f\u53ef\u4ee5\u6307\u76f4\u63a5\u57fa\u4e8ecgroups\u6765\u8fdb\u884c\u8fdb\u7a0b\u8d44\u6e90\u63a7\u5236\uff0c\u6bd4\u59828\u6838\u7684\u673a\u5668\u4e0a\u90e8\u7f72\u4e86\u4e00\u4e2aweb\u670d\u52a1\u548c\u4e00\u4e2a\u8ba1\u7b97\u670d\u52a1\uff0c\u53ef\u4ee5\u8ba9web\u670d\u52a1\u4ec5\u53ef\u4f7f\u7528\u5176\u4e2d6\u4e2a\u6838\uff0c\u628a\u5269\u4e0b\u7684\u4e24\u4e2a\u6838\u7559\u7ed9\u8ba1\u7b97\u670d\u52a1\u3002cgroups cpu\u9650\u5236\u9664\u4e86\u53ef\u4ee5\u9650\u5236\u4f7f\u7528\u591a\u5c11\/\u54ea\u51e0\u4e2a\u6838\u5fc3\u4e4b\u5916\uff0c\u8fd8\u53ef\u4ee5\u8bbe\u7f6ecpu\u5360\u7528\u6bd4\uff08\u6ce8\u610f\u5360\u7528\u6bd4\u662f\u5404\u81ea\u90fd\u8dd1\u6ee1\u60c5\u51b5\u4e0b\u7684\u4f7f\u7528\u6bd4\u4f8b\uff0c\u5982\u679c\u4e00\u4e2acgroup\u7a7a\u95f2\u800c\u53e6\u4e00\u4e2a\u7e41\u5fd9\uff0c\u90a3\u4e48\u7e41\u5fd9\u7684cgroup\u662f\u6709\u53ef\u80fd\u5360\u6ee1\u6574\u4e2acpu\u6838\u5fc3\u7684\uff09\u3002 <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1\u3001cgroups\u6982\u5ff5<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece\u5b9e\u73b0\u89d2\u5ea6\u6765\u770b\uff0ccgroups\u5b9e\u73b0\u4e86\u4e00\u4e2a\u901a\u7528\u7684\u8fdb\u7a0b\u5206\u7ec4\u6846\u67b6\uff0c\u4e0d\u540c\u8d44\u6e90\u7684\u5177\u4f53\u7ba1\u7406\u5de5\u4f5c\u7531\u5404cgroup\u5b50\u7cfb\u7edf\u6765\u5b9e\u73b0\uff0c\u5f53\u9700\u8981\u591a\u4e2a\u9650\u5236\u7b56\u7565\u6bd4\u5982\u540c\u65f6\u9488\u5bf9cpu\u548c\u5185\u5b58\u8fdb\u884c\u9650\u5236\uff0c\u5219\u540c\u65f6\u5173\u8054\u591a\u4e2acgroup\u5b50\u7cfb\u7edf\u5373\u53ef\u3002 <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2\u3001cgroups\u5b50\u7cfb\u7edf<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">cgroups\u4e3a\u6bcf\u79cd\u8d44\u6e90\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5b50\u7cfb\u7edf\uff0c\u5178\u578b\u7684\u5b50\u7cfb\u7edf\u5982\u4e0b\uff1a <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>cpu \u5b50\u7cfb\u7edf<\/strong>\uff0c\u4e3b\u8981\u9650\u5236\u8fdb\u7a0b\u7684 cpu \u4f7f\u7528\u7387\u3002 <\/li><li><strong>cpuacct \u5b50\u7cfb\u7edf<\/strong>\uff0c\u53ef\u4ee5\u7edf\u8ba1 cgroups \u4e2d\u7684\u8fdb\u7a0b\u7684 cpu \u4f7f\u7528\u62a5\u544a\u3002 <\/li><li><strong>cpuset \u5b50\u7cfb\u7edf<\/strong>\uff0c\u53ef\u4ee5\u4e3a cgroups \u4e2d\u7684\u8fdb\u7a0b\u5206\u914d\u5355\u72ec\u7684 cpu \u8282\u70b9\u6216\u8005\u5185\u5b58\u8282\u70b9\u3002 <\/li><li><strong>memory \u5b50\u7cfb\u7edf<\/strong>\uff0c\u53ef\u4ee5\u9650\u5236\u8fdb\u7a0b\u7684 memory \u4f7f\u7528\u91cf\u3002 <\/li><li><strong>blkio \u5b50\u7cfb\u7edf<\/strong>\uff0c\u53ef\u4ee5\u9650\u5236\u8fdb\u7a0b\u7684\u5757\u8bbe\u5907 io\u3002 <\/li><li><strong>devices \u5b50\u7cfb\u7edf<\/strong>\uff0c\u53ef\u4ee5\u63a7\u5236\u8fdb\u7a0b\u80fd\u591f\u8bbf\u95ee\u67d0\u4e9b\u8bbe\u5907\u3002 <\/li><li><strong>net_cls \u5b50\u7cfb\u7edf<\/strong>\uff0c\u53ef\u4ee5\u6807\u8bb0 cgroups \u4e2d\u8fdb\u7a0b\u7684\u7f51\u7edc\u6570\u636e\u5305\uff0c\u7136\u540e\u53ef\u4ee5\u4f7f\u7528 tc \u6a21\u5757\uff08traffic control\uff09\u5bf9\u6570\u636e\u5305\u8fdb\u884c\u63a7\u5236\u3002 <\/li><li><strong>freezer \u5b50\u7cfb\u7edf<\/strong>\uff0c\u53ef\u4ee5\u6302\u8d77\u6216\u8005\u6062\u590d cgroups \u4e2d\u7684\u8fdb\u7a0b\u3002 <\/li><li><strong>ns \u5b50\u7cfb\u7edf<\/strong>\uff0c\u53ef\u4ee5\u4f7f\u4e0d\u540c cgroups \u4e0b\u9762\u7684\u8fdb\u7a0b\u4f7f\u7528\u4e0d\u540c\u7684 namespace\u3002 <\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bcf\u4e2a\u5b50\u7cfb\u7edf\u90fd\u662f\u5b9a\u4e49\u4e86\u4e00\u5957\u9650\u5236\u7b56\u7565\uff0c\u5b83\u4eec\u9700\u8981\u4e0e\u5185\u6838\u7684\u5176\u4ed6\u6a21\u5757\u914d\u5408\u6765\u5b8c\u6210\u8d44\u6e90\u9650\u5236\u529f\u80fd\uff0c\u6bd4\u5982\u5bf9 cpu \u8d44\u6e90\u7684\u9650\u5236\u662f\u901a\u8fc7\u8fdb\u7a0b\u8c03\u5ea6\u6a21\u5757\u6839\u636e cpu \u5b50\u7cfb\u7edf\u7684\u914d\u7f6e\u6765\u5b8c\u6210\u7684\uff1b\u5bf9\u5185\u5b58\u8d44\u6e90\u7684\u9650\u5236\u5219\u662f\u5185\u5b58\u6a21\u5757\u6839\u636e memory \u5b50\u7cfb\u7edf\u7684\u914d\u7f6e\u6765\u5b8c\u6210\u7684\uff0c\u800c\u5bf9\u7f51\u7edc\u6570\u636e\u5305\u7684\u63a7\u5236\u5219\u9700\u8981 Traffic Control \u5b50\u7cfb\u7edf\u6765\u914d\u5408\u5b8c\u6210\u3002 <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001<strong>cgroups\u6587\u4ef6\u7cfb\u7edf<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Linux \u4f7f\u7528\u4e86\u591a\u79cd\u6570\u636e\u7ed3\u6784\u5728\u5185\u6838\u4e2d\u5b9e\u73b0\u4e86 cgroups \u7684\u914d\u7f6e\uff0c\u5173\u8054\u4e86\u8fdb\u7a0b\u548c cgroups \u8282\u70b9\uff0c\u90a3\u4e48 Linux \u53c8\u662f\u5982\u4f55\u8ba9\u7528\u6237\u6001\u7684\u8fdb\u7a0b\u4f7f\u7528\u5230 cgroups \u7684\u529f\u80fd\u5462\uff1fLinux\u5185\u6838\u6709\u4e00\u4e2a\u5f88\u5f3a\u5927\u7684\u6a21\u5757\u53eb VFS (Virtual File System)\u3002VFS \u80fd\u591f\u628a\u5177\u4f53\u6587\u4ef6\u7cfb\u7edf\u7684\u7ec6\u8282\u9690\u85cf\u8d77\u6765\uff0c\u7ed9\u7528\u6237\u6001\u8fdb\u7a0b\u63d0\u4f9b\u4e00\u4e2a\u7edf\u4e00\u7684\u6587\u4ef6\u7cfb\u7edf API \u63a5\u53e3\u3002cgroups \u4e5f\u662f\u901a\u8fc7 VFS \u628a\u529f\u80fd\u66b4\u9732\u7ed9\u7528\u6237\u6001\u7684\uff0ccgroups \u4e0e VFS \u4e4b\u95f4\u7684\u8854\u63a5\u90e8\u5206\u79f0\u4e4b\u4e3a cgroups \u6587\u4ef6\u7cfb\u7edf\u3002\u901a\u8fc7cgroups\u9002\u914dVFS\uff0c\u7528\u6237\u53ef\u4ee5\u4f7f\u7528VFS\u63a5\u53e3\u6765\u64cd\u4f5ccgroup\u529f\u80fd\u3002 <\/p>\n\n\n\n<p class=\"has-background has-luminous-vivid-amber-background-color wp-block-paragraph\">VFS \u662f\u4e00\u4e2a\u5185\u6838\u62bd\u8c61\u5c42\uff08\u901a\u7528\u6587\u4ef6\u6a21\u578b\uff09\uff0c\u80fd\u591f\u9690\u85cf\u5177\u4f53\u6587\u4ef6\u7cfb\u7edf\u7684\u5b9e\u73b0\u7ec6\u8282\uff0c\u4ece\u800c\u7ed9\u7528\u6237\u6001\u8fdb\u7a0b\u63d0\u4f9b\u4e00\u5957\u7edf\u4e00\u7684 API \u63a5\u53e3\u3002VFS \u4f7f\u7528\u4e86\u4e00\u79cd\u901a\u7528\u6587\u4ef6\u7cfb\u7edf\u7684\u8bbe\u8ba1\uff0c\u5177\u4f53\u7684\u6587\u4ef6\u7cfb\u7edf\u53ea\u8981\u5b9e\u73b0\u4e86 VFS \u7684\u8bbe\u8ba1\u63a5\u53e3\uff0c\u5c31\u80fd\u591f\u6ce8\u518c\u5230 VFS \u4e2d\uff0c\u4ece\u800c\u4f7f\u5185\u6838\u53ef\u4ee5\u8bfb\u5199\u8fd9\u79cd\u6587\u4ef6\u7cfb\u7edf\u3002\u8fd9\u5f88\u50cf\u9762\u5411\u5bf9\u8c61\u8bbe\u8ba1\u4e2d\u7684\u62bd\u8c61\u7c7b\u4e0e\u5b50\u7c7b\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u62bd\u8c61\u7c7b\u8d1f\u8d23\u5bf9\u5916\u63a5\u53e3\u7684\u8bbe\u8ba1\uff0c\u5b50\u7c7b\u8d1f\u8d23\u5177\u4f53\u7684\u5b9e\u73b0\u3002\u5176\u5b9e\uff0cVFS\u672c\u8eab\u5c31\u662f\u7528 c \u8bed\u8a00\u5b9e\u73b0\u7684\u4e00\u5957\u9762\u5411\u5bf9\u8c61\u7684\u63a5\u53e3\u3002 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>cgroups\u662fLinux\u4e0b\u63a7\u5236\u4e00\u4e2a\uff08\u6216\u4e00\u7ec4\uff09\u8fdb\u7a0b\u7684\u8d44\u6e90\u9650\u5236\u673a\u5236\uff0c\u5168\u79f0\u662fcontrol groups\uff0c \u53ef\u4ee5\u5bf9 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":3520,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,22],"tags":[125],"class_list":["post-3519","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-server","tag-cgroup"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/3519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=3519"}],"version-history":[{"count":1,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/3519\/revisions"}],"predecessor-version":[{"id":3521,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/3519\/revisions\/3521"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/3520"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=3519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=3519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=3519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}