{"id":7621,"date":"2022-11-11T11:15:59","date_gmt":"2022-11-11T03:15:59","guid":{"rendered":"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621"},"modified":"2024-05-09T16:08:20","modified_gmt":"2024-05-09T08:08:20","slug":"cgroup%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621","title":{"rendered":"cgroup\u4ecb\u7ecd"},"content":{"rendered":"<p><a href=\"https:\/\/www.lxlinux.net\/6929.html\">https:\/\/www.lxlinux.net\/6929.html<\/a> \uff08**\uff09<\/p>\n<p><a href=\"https:\/\/blog.csdn.net\/sanhewuyang\/article\/details\/120735766\">https:\/\/blog.csdn.net\/sanhewuyang\/article\/details\/120735766<\/a> \uff08\u8be6\u7ec6\u4ecb\u7ecd\u4e86cgroup\u4e0esystemd\uff09<\/p>\n<p><a href=\"https:\/\/blog.csdn.net\/weixin_42788640\/article\/details\/115492506\">https:\/\/blog.csdn.net\/weixin_42788640\/article\/details\/115492506<\/a> (**\u4ecb\u7ecd\u6bd4\u8f83\u5168\u9762)<\/p>\n<p><a href=\"https:\/\/article.itxueyuan.com\/dXW9dg\">https:\/\/article.itxueyuan.com\/dXW9dg<\/a><\/p>\n<p><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/538496131\">https:\/\/zhuanlan.zhihu.com\/p\/538496131<\/a><\/p>\n<p><a href=\"https:\/\/blog.csdn.net\/GaoChuang_\/article\/details\/121710719\">https:\/\/blog.csdn.net\/GaoChuang_\/article\/details\/121710719<\/a><br \/>\n<a href=\"https:\/\/www.ctyun.cn\/developer\/article\/423015204548677\">https:\/\/www.ctyun.cn\/developer\/article\/423015204548677<\/a><\/p>\n<p><a href=\"https:\/\/mp.weixin.qq.com\/s\/3DiwzAGHsRR2lE1_vNDdvA\">https:\/\/mp.weixin.qq.com\/s\/3DiwzAGHsRR2lE1_vNDdvA<\/a><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_16 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#%E4%B8%80%E3%80%81%E4%BB%80%E4%B9%88%E6%98%AFcgroup\" title=\"\u4e00\u3001\u4ec0\u4e48\u662fcgroup\">\u4e00\u3001\u4ec0\u4e48\u662fcgroup<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#%E4%BA%8C%E3%80%81cgroup%E7%9A%84%E5%8A%9F%E8%83%BD\" title=\"\u4e8c\u3001cgroup\u7684\u529f\u80fd\">\u4e8c\u3001cgroup\u7684\u529f\u80fd<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#%E4%B8%89%E3%80%81cgroup%E7%9B%B8%E5%85%B3%E6%A6%82%E5%BF%B5\" title=\"\u4e09\u3001cgroup\u76f8\u5173\u6982\u5ff5\">\u4e09\u3001cgroup\u76f8\u5173\u6982\u5ff5<\/a><ul class=\"ez-toc-list-level-4\"><li class=\"ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#1subsystem\" title=\"1.subsystem\">1.subsystem<\/a><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#2cgroup%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E6%8E%A5%E5%8F%A3\" title=\"2.cgroup\u6587\u4ef6\u7cfb\u7edf\u63a5\u53e3\">2.cgroup\u6587\u4ef6\u7cfb\u7edf\u63a5\u53e3<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#3Hierarchy\" title=\"3.Hierarchy\">3.Hierarchy<\/a><\/li><\/ul><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-7\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#%E5%9B%9B%E3%80%81cgroup%E7%9B%B8%E5%85%B3%E8%A7%84%E5%88%99\" title=\"\u56db\u3001cgroup\u76f8\u5173\u89c4\u5219\">\u56db\u3001cgroup\u76f8\u5173\u89c4\u5219<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-8\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#%E4%BA%94%E3%80%81cgroup%E6%A8%A1%E5%BC%8F\" title=\"\u4e94\u3001cgroup\u6a21\u5f0f\">\u4e94\u3001cgroup\u6a21\u5f0f<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-9\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#%E5%85%AD%E3%80%81cgroup%E4%B8%8Ecgroup2\" title=\"\u516d\u3001cgroup\u4e0ecgroup2\">\u516d\u3001cgroup\u4e0ecgroup2<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-10\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#%E4%B8%83%E3%80%81cgroup%E4%B8%8Esystemd\" title=\"\u4e03\u3001cgroup\u4e0esystemd\">\u4e03\u3001cgroup\u4e0esystemd<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-11\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#%E5%85%AB%E3%80%81cgroup%E7%A4%BA%E4%BE%8B\" title=\"\u516b\u3001cgroup\u793a\u4f8b\">\u516b\u3001cgroup\u793a\u4f8b<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-12\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7621\/#%E4%B9%9D%E3%80%81cgroup%E6%BA%90%E7%A0%81%E5%8E%9F%E7%90%86%E6%B7%B1%E5%BA%A6%E8%A7%A3%E6%9E%90\" title=\"\u4e5d\u3001cgroup\u6e90\u7801\u539f\u7406\u6df1\u5ea6\u89e3\u6790\">\u4e5d\u3001cgroup\u6e90\u7801\u539f\u7406\u6df1\u5ea6\u89e3\u6790<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"%E4%B8%80%E3%80%81%E4%BB%80%E4%B9%88%E6%98%AFcgroup\"><\/span>\u4e00\u3001\u4ec0\u4e48\u662fcgroup<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/www.cnblogs.com\/architectforest\/p\/13126905.html\">https:\/\/www.cnblogs.com\/architectforest\/p\/13126905.html<\/a><br \/>\n\u63a7\u5236\u7fa4\u7ec4(control group) \u662fLinux kernel(Linux\u5185\u6838)\u7684\u4e00\u9879\u529f\u80fd:<\/p>\n<p>\u5728\u4e00\u4e2a\u7cfb\u7edf\u4e2d\u8fd0\u884c\u7684\u5c42\u7ea7\u5236\u8fdb\u7a0b\u7ec4,\u60a8\u53ef\u5bf9\u5176\u8fdb\u884c<strong>\u8d44\u6e90\u5206\u914d<\/strong>(\u5982CPU\u65f6\u95f4\u3001\u7cfb\u7edf\u5185\u5b58\u3001\u7f51\u7edc\u5e26\u5bbd\u6216\u8005\u8fd9\u4e9b\u8d44\u6e90\u7684\u7ec4\u5408)\u3002<\/p>\n<p>\u901a\u8fc7\u4f7f\u7528cgroup ,\u7cfb\u7edf\u7ba1\u7406\u5458\u5728\u5206\u914d\u3001\u6392\u5e8f\u3001\u62d2\u7edd\u3001\u7ba1\u7406\u548c\u76d1\u63a7\u7cfb\u7edf\u8d44\u6e90\u7b49\u65b9\u9762,\u53ef\u4ee5\u8fdb\u884c\u7cbe\u7ec6\u5316\u63a7\u5236\u3002\u786c\u4ef6\u8d44\u6e90\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u548c\u7528\u6237\u95f4\u667a\u80fd\u5206\u914d,\u4ece\u800c\u589e\u52a0\u6574\u4f53\u6548\u7387\u3002<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E4%BA%8C%E3%80%81cgroup%E7%9A%84%E5%8A%9F%E8%83%BD\"><\/span>\u4e8c\u3001cgroup\u7684\u529f\u80fd<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>cgroup\u662f\u5c06\u4efb\u610f\u8fdb\u7a0b\u8fdb\u884c\u5206\u7ec4\u5316\u7ba1\u7406\u7684Linux\u5185\u6838\u529f\u80fd\u3002cgroup\u672c\u8eab\u63d0\u4f9b\u5c06\u8fdb\u7a0b\u8fdb\u884c\u5206\u7ec4\u5316\u7ba1\u7406\u7684\u529f\u80fd\u548c\u63a5\u53e3\u7684\u57fa\u7840\u7ed3\u6784\u3002\u5b9e\u73b0 cgroups \u7684\u4e3b\u8981\u76ee\u7684\u662f\u4e3a\u4e0d\u540c\u7528\u6237\u5c42\u9762\u7684\u8d44\u6e90\u7ba1\u7406\u63d0\u4f9b\u4e00\u4e2a\u7edf\u4e00\u5316\u7684\u63a5\u53e3\u3002\u4ece\u5355\u4e2a\u4efb\u52a1\u7684\u8d44\u6e90\u63a7\u5236\u5230\u64cd\u4f5c\u7cfb\u7edf\u5c42\u9762\u7684\u865a\u62df\u5316\uff0ccgroups \u63d0\u4f9b\u4e86\u4e94\u5927\u529f\u80fd\uff1a<\/p>\n<p><strong>\u8d44\u6e90\u9650\u5236<\/strong>\uff08Resource limiting \uff09\uff1a\u6bd4\u5982memory\u5b50\u7cfb\u7edf\u53ef\u4ee5\u4e3a\u8fdb\u7a0b\u7ec4\u8bbe\u5b9a\u4e00\u4e2amemory\u4f7f\u7528\u4e0a\u9650\uff0c\u8fdb\u7a0b\u7ec4\u4f7f\u7528\u7684\u5185\u5b58\u8fbe\u5230\u9650\u989d\u518d\u7533\u8bf7\u5185\u5b58\uff0c\u5c31\u4f1a\u51fa\u53d1OOM\uff08out of memory\uff09<br \/>\n<strong>\u4f18\u5148\u7ea7\u63a7\u5236<\/strong>\uff08Prioritization\uff09\uff1a\u6bd4\u5982\u53ef\u4ee5\u4f7f\u7528cpu\u5b50\u7cfb\u7edf\u4e3a\u67d0\u4e2a\u8fdb\u7a0b\u7ec4\u5206\u914dcpu share<br \/>\n<strong>\u8d44\u6e90\u7edf\u8ba1<\/strong>\uff08Accounting \uff09\uff1a\u6bd4\u5982\u4f7f\u7528cpuacct\u5b50\u7cfb\u7edf\u8bb0\u5f55\u67d0\u4e2a\u8fdb\u7a0b\u7ec4\u4f7f\u7528\u7684cpu\u65f6\u95f4<br \/>\n<strong>\u8fdb\u7a0b\u7ec4\u9694\u79bb<\/strong>\uff08Isolation\uff09\uff1a\u6bd4\u5982\u4f7f\u7528ns\u5b50\u7cfb\u7edf\u53ef\u4ee5\u4f7f\u4e0d\u540c\u7684\u8fdb\u7a0b\u7ec4\u4f7f\u7528\u4e0d\u540c\u7684namespace\uff0c\u4ee5\u8fbe\u5230\u9694\u79bb\u7684\u76ee\u7684\uff0c\u4e0d\u540c\u7684\u8fdb\u7a0b\u7ec4\u6709\u5404\u81ea\u7684\u8fdb\u7a0b\u3001\u7f51\u7edc\u3001\u6587\u4ef6\u7cfb\u7edf\u6302\u8f7d\u7a7a\u95f4<br \/>\n<strong>\u8fdb\u7a0b\u7ec4\u63a7\u5236<\/strong>\uff08Control\uff09\uff1a\u6bd4\u5982\u4f7f\u7528freezer\u5b50\u7cfb\u7edf\u53ef\u4ee5\u5c06\u8fdb\u7a0b\u7ec4\u6302\u8d77\u548c\u6062\u590d<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E4%B8%89%E3%80%81cgroup%E7%9B%B8%E5%85%B3%E6%A6%82%E5%BF%B5\"><\/span>\u4e09\u3001cgroup\u76f8\u5173\u6982\u5ff5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>Task<\/strong>\uff08\u4efb\u52a1\uff09\uff1a task\u5c31\u662f\u8868\u793a\u7cfb\u7edf\u7684\u4e00\u4e2a\u8fdb\u7a0b\u3002<br \/>\n<strong>Cgroup<\/strong>\uff08\u63a7\u5236\u7ec4\uff09\uff1a \u8d44\u6e90\u63a7\u5236\u7684\u5355\u4f4d\uff0c\u8868\u793a\u4e00\u6574\u4e2a\u4efb\u52a1\u7ec4\uff0c\u6bcf\u4e2a\u4efb\u52a1\u7ec4\u88ab\u5212\u5206\u76f8\u5e94\u7684\u8d44\u6e90\uff0c\u5305\u542b\u4e86\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u5b50\u7cfb\u7edf\u3002\u4e00\u4e2a\u4efb\u52a1\u65e2\u53ef\u4ee5\u52a0\u5165\u5230\u8fd9\u4e2a cgroup \u4e2d\uff0c\u4e5f\u53ef\u4ee5\u8fc1\u79fb\u5230\u53e6\u5916\u4e00\u4e2a cgroup \u4e2d\u53bb\u3002<br \/>\n<strong>Subsystem<\/strong>\uff08\u5b50\u7cfb\u7edf\uff09\uff1a \u4e00\u4e2a\u8d44\u6e90\u8c03\u5ea6\u5668\uff08Resource Controller\uff0c\u63a7\u5236\u7740CPU\uff0c\u5185\u5b58\uff0c\u8bbf\u95ee\uff0c\u8f93\u5165\u8f93\u51fa\u7b49\u8d44\u6e90\u548c\u6743\u9650\u3002<br \/>\n<strong>Hierarchy<\/strong>\uff08\u5c42\u7ea7\u6811\uff09\uff1a\u4e00\u79cd\u64cd\u4f5c\u7cfb\u7edf\u7684\u7ec4\u7ec7\u7ed3\u6784\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a\u662f\u4e00\u4e2a cgroup \u6811\uff0c\u5c06 cgroup \u4e32\u6210\u6811\u72b6\u7ed3\u6784\uff0c\u901a\u8fc7\u865a\u62df\u7aef\u53e3\u66b4\u9732\u7ed9\u7528\u6237\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"1subsystem\"><\/span>1.subsystem<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>cgroup\u5404\u5927\u5b50\u7cfb\u7edf\u8bf4\u660e<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/KubeExplorer\/p\/17960509\">https:\/\/www.cnblogs.com\/KubeExplorer\/p\/17960509<\/a><\/p>\n<p>\u5728\/proc\/cgroups\u67e5\u770b\u6240\u6709\u652f\u6301\u7684subsystem,\u6216\u8005\u901a\u8fc7lssubsys\u547d\u4ee4\u3002<\/p>\n<h5><span class=\"ez-toc-section\" id=\"2cgroup%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E6%8E%A5%E5%8F%A3\"><\/span>2.cgroup\u6587\u4ef6\u7cfb\u7edf\u63a5\u53e3<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>cgroup\u4ee5\u6587\u4ef6\u7684\u65b9\u5f0f\u63d0\u4f9b\u5e94\u7528\u63a5\u53e3\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 mount \u547d\u4ee4\u6765\u67e5\u770b cgroups \u9ed8\u8ba4\u7684\u6302\u8f7d\u70b9\u3002\u7cfb\u7edf\u9ed8\u8ba4\u4f1a\u6302\u8f7dcgroup\uff0c\u8def\u5f84\u4e3a\/sys\/fs\/cgroup\uff0c\u67e5\u770b\u5f53\u524d\u7cfb\u7edf\u6302\u8f7d\u7684cgroup\uff0c\u53ef\u4ee5\u770b\u5230\u5728\u9ed8\u8ba4\u8def\u5f84\u4e0b\u6302\u8f7d\u4e86\u6240\u6709\u7684\u5b50\u7cfb\u7edf\u3002\u540e\u7eed\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u4e0b\u8ff0hierarchy\u4f5c\u4e3a\u7236hierarchy\u3002\u8fdb\u7a0b\u7684cgroup\u53ef\u4ee5\u5728\/proc\/$pid\/cgroup\u6587\u4ef6\u4e2d\u67e5\u770b\u3002<\/p>\n<pre><code class=\"language-bash\">#mount|grep cgroup\ntmpfs on \/sys\/fs\/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755)\ncgroup on \/sys\/fs\/cgroup\/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,xattr,release_agent=\/usr\/lib\/systemd\/systemd-cgroups-agent,name=systemd)\ncgroup on \/sys\/fs\/cgroup\/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,perf_event)\ncgroup on \/sys\/fs\/cgroup\/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,hugetlb)\ncgroup on \/sys\/fs\/cgroup\/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,rdma)\ncgroup on \/sys\/fs\/cgroup\/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,cpu,cpuacct)\ncgroup on \/sys\/fs\/cgroup\/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,net_cls,net_prio)\ncgroup on \/sys\/fs\/cgroup\/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,cpuset)\ncgroup on \/sys\/fs\/cgroup\/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,blkio)\ncgroup on \/sys\/fs\/cgroup\/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,freezer)\ncgroup on \/sys\/fs\/cgroup\/memory type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,memory)\ncgroup on \/sys\/fs\/cgroup\/pids type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,pids)\ncgroup on \/sys\/fs\/cgroup\/devices type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,devices)\n<\/code><\/pre>\n<ul>\n<li>\u67e5\u770b\u8fdb\u7a0b\u6240\u5c5e\u7684 cgroup<br \/>\n\u53ef\u4ee5\u901a\u8fc7 \/proc\/[pid]\/cgroup \u6765\u67e5\u770b\u6307\u5b9a\u8fdb\u7a0b\u5c5e\u4e8e\u54ea\u4e9b cgroup\uff1a<br \/>\n\u6bcf\u4e00\u884c\u5305\u542b\u7528\u5192\u53f7\u9694\u5f00\u7684\u4e09\u5217\uff0c\u4ed6\u4eec\u7684\u542b\u4e49\u5206\u522b\u662f\uff1a<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">1.cgroup \u6811\u7684 ID\uff0c \u548c \/proc\/cgroups \u6587\u4ef6\u4e2d\u7684 ID \u4e00\u4e00\u5bf9\u5e94\u3002\n2.\u548c cgroup \u6811\u7ed1\u5b9a\u7684\u6240\u6709 subsystem\uff0c\u591a\u4e2a subsystem \u4e4b\u95f4\u7528\u9017\u53f7\u9694\u5f00\u3002\u8fd9\u91cc name=systemd \u8868\u793a\u6ca1\u6709\u548c\u4efb\u4f55 subsystem \u7ed1\u5b9a\uff0c\u53ea\u662f\u7ed9\u4ed6\u8d77\u4e86\u4e2a\u540d\u5b57\u53eb systemd\u3002\n3.\u8fdb\u7a0b\u5728 cgroup \u6811\u4e2d\u7684\u8def\u5f84\uff0c\u5373\u8fdb\u7a0b\u6240\u5c5e\u7684 cgroup\uff0c\u8fd9\u4e2a\u8def\u5f84\u662f\u76f8\u5bf9\u4e8e\u6302\u8f7d\u70b9\u7684\u76f8\u5bf9\u8def\u5f84\u3002<\/code><\/pre>\n<p>\u53ef\u4ee5\u4f7f\u7528cgroup-bin\u5de5\u5177\u5305\u4e2d\u7684cgexec\u6765\u5b9e\u73b0\u9650\u5236\u8fdb\u7a0b\u53ef\u4ee5\u4f7f\u7528\u7684\u8d44\u6e90\u3002<\/p>\n<h5><span class=\"ez-toc-section\" id=\"3Hierarchy\"><\/span>3.Hierarchy<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/74299886\">https:\/\/zhuanlan.zhihu.com\/p\/74299886<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E5%9B%9B%E3%80%81cgroup%E7%9B%B8%E5%85%B3%E8%A7%84%E5%88%99\"><\/span>\u56db\u3001cgroup\u76f8\u5173\u89c4\u5219<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h3><span class=\"ez-toc-section\" id=\"%E4%BA%94%E3%80%81cgroup%E6%A8%A1%E5%BC%8F\"><\/span>\u4e94\u3001cgroup\u6a21\u5f0f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u76ee\u524d\uff0ccgroups \u6709\u4e24\u4e2a\u7248\u672c\uff0ccgroup V1 \u548c cgroup V2\u3002V1 \u529f\u80fd\u76f8\u5bf9\u96f6\u6563\uff0c\u4e0d\u65b9\u4fbf\u7ef4\u62a4\uff0cV2 \u662f\u672a\u6765\u7684\u6f14\u8fdb\u65b9\u5411\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8282\u70b9\u5b58\u5728\u4ee5\u4e0b\u9762 3 \u79cd cgroups \u6a21\u5f0f\uff1a<\/p>\n<p>legacy\uff1a\u53ea\u652f\u6301 cgroup V1<br \/>\nhybrid\uff1a\u540c\u65f6\u652f\u6301 cgroup V1 \u548c cgroup V2<br \/>\nunified\uff1a\u53ea\u652f\u6301 cgroup V2<br \/>\n\u5728 containerd \u4e2d\uff0c\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u5224\u65ad\u5904\u4e8e\u54ea\u79cd\u6a21\u5f0f\uff1a<\/p>\n<pre><code class=\"language-go\">const unifiedMountpoint = &quot;\/sys\/fs\/cgroup&quot;\n\n\/\/ Mode returns the cgroups mode running on the host\nfunc Mode() CGMode {\n    checkMode.Do(func() {\n        var st unix.Statfs_t\n        \/\/ \u6ca1\u6302\u8f7d \/sys\/fs\/cgroup\n        if err := unix.Statfs(unifiedMountpoint, &amp;st); err != nil {\n            cgMode = Unavailable\n            return\n        }\n        switch st.Type {\n        case unix.CGROUP2_SUPER_MAGIC:\n            \/\/ \/sys\/fs\/cgroup \u6302\u8f7d\u4e3a cgroup2 \u6587\u4ef6\u7cfb\u7edf\u683c\u5f0f\n            cgMode = Unified\n        default:\n            cgMode = Legacy\n            if err := unix.Statfs(filepath.Join(unifiedMountpoint, &quot;unified&quot;), &amp;st); err != nil {\n                return\n            }\n            \/\/ \/sys\/fs\/cgroup\/unified \u6302\u8f7d\u4e3a cgroup2 \u6587\u4ef6\u7cfb\u7edf\u683c\u5f0f\n            if st.Type == unix.CGROUP2_SUPER_MAGIC {\n                cgMode = Hybrid\n            }\n        }\n    })\n    return cgMode\n}<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E5%85%AD%E3%80%81cgroup%E4%B8%8Ecgroup2\"><\/span>\u516d\u3001cgroup\u4e0ecgroup2<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/developer.aliyun.com\/article\/1205050\">https:\/\/developer.aliyun.com\/article\/1205050<\/a><\/p>\n<ul>\n<li>\n<p>v2\u4e0ev1\u7684\u4e3b\u8981\u533a\u522b<br \/>\nv2 \u7248\u672c\u4e0ev1\u76f8\u6bd4,\u5728\u76ee\u5f55\u7ec4\u7ec7\u4e0a\u66f4\u6e05\u6670\uff0c\u7ba1\u7406\u66f4\u65b9\u4fbf\uff0c\u5728 cgroup v2 \u4e2d\uff0c\u53bb\u6389\u4e86\u5c42\u7ea7\uff08hierarchy\uff09\u7684\u6982\u5ff5\uff0c\u53ea\u6709\u4e00\u4e2a\u5c42\u7ea7\uff0c\u6240\u6709 cgroup \u5728\u8be5\u5c42\u7ea7\u4e2d\u4ee5\u6811\u5f62\u7684\u65b9\u5f0f\u7ec4\u7ec7\uff0c\u6bcf\u4e2a cgroup \u53ef\u4ee5\u7ba1\u7406\u591a\u79cd\u8d44\u6e90\u3002<br \/>\n<a href=\"https:\/\/www.51cto.com\/article\/599391.html\">https:\/\/www.51cto.com\/article\/599391.html<\/a><\/p>\n<\/li>\n<li>\n<p>\u5982\u4f55\u68c0\u67e5\u5f53\u524d\u5185\u6838\u7248\u672c\u662f\u5426\u652f\u6301cgroup v2?<br \/>\n\u65b9\u6cd5\u662f:\u67e5\u770b\u6587\u4ef6\u7cfb\u7edf\u662f\u5426\u652f\u6301cgroup2<\/p>\n<pre><code class=\"language-bash\">[root@node1 ~]# grep cgroup \/proc\/filesystems\nnodev   cgroup\nnodev   cgroup2<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"%E4%B8%83%E3%80%81cgroup%E4%B8%8Esystemd\"><\/span>\u4e03\u3001cgroup\u4e0esystemd<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"http:\/\/wjhsh.net\/sparkdev-p-9523194.html\">http:\/\/wjhsh.net\/sparkdev-p-9523194.html<\/a><br \/>\n1\uff09Systemd \u4f9d\u8d56 cgroups<br \/>\nsystemd \u4e5f\u662f\u5bf9\u4e8e Cgroup \u63a5\u53e3\u7684\u4e00\u4e2a\u5c01\u88c5<br \/>\n2\uff09Systemd \u9ed8\u8ba4\u6302\u8f7d\u7684 cgroups \u7cfb\u7edf<br \/>\n\u5728\u7cfb\u7edf\u7684\u5f00\u673a\u9636\u6bb5\uff0csystemd \u4f1a\u628a\u652f\u6301\u7684 controllers (subsystem \u5b50\u7cfb\u7edf)\u6302\u8f7d\u5230\u9ed8\u8ba4\u7684 \/sys\/fs\/cgroup\/ \u76ee\u5f55\u4e0b\u9762\u3002<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E5%85%AB%E3%80%81cgroup%E7%A4%BA%E4%BE%8B\"><\/span>\u516b\u3001cgroup\u793a\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/cloud.tencent.com\/developer\/article\/2118809\">https:\/\/cloud.tencent.com\/developer\/article\/2118809<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E4%B9%9D%E3%80%81cgroup%E6%BA%90%E7%A0%81%E5%8E%9F%E7%90%86%E6%B7%B1%E5%BA%A6%E8%A7%A3%E6%9E%90\"><\/span>\u4e5d\u3001cgroup\u6e90\u7801\u539f\u7406\u6df1\u5ea6\u89e3\u6790<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/blog.csdn.net\/hu1610552336\/article\/details\/118642410\">https:\/\/blog.csdn.net\/hu1610552336\/article\/details\/118642410<\/a> \uff08\u5305\u542b\u793a\u4f8b\uff09<\/p>\n<button class=\"simplefavorite-button\" data-postid=\"7621\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.lxlinux.net\/6929.html \uff08**\uff09 https:\/\/blo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[562],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/7621"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7621"}],"version-history":[{"count":30,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/7621\/revisions"}],"predecessor-version":[{"id":13273,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/7621\/revisions\/13273"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7621"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}