Show Table of Contents
3.3. 创建控制群组
在您自己创建的层级中,您可以使用
cgcreate 指令来创建临时 cgroup。cgcreate 的句法是:
cgcreate-tuid:gid-auid:gid-gcontrollers:path
其中:
-t(可选)—— 指定一个用户(通过用户 ID:uid)和群组(通过群组 ID:gid)来拥有此 cgroup 的tasks伪文件。此用户可在该 cgroup 中添加任务。注意
请注意,从 cgroup 中移除进程的唯一方法是将进程移至另一个 cgroup。如想要移除进程,用户必须拥有 “目标” cgroup 的写入权限;但是源 cgroup 的写入权限并不重要。-a(可选)—— 指定一个用户(通过用户 ID:uid)和群组(通过群组 ID:gid)来拥有此 cgroup 的全部伪文件而不是tasks。此用户可以修改 cgroup 中任务存取系统资源的权限。-g—— 指定 cgroup 应该被建于其中的层级,类似于“管控器”和这些层级的列表(以逗号分隔)。管控器的此项列表之后是一个冒号以及相对层级的子群组“路径”。请不要将层级挂载点包含于路径中。
同一层级中的所有 cgroup 有同一个管控器,所以子群组与其父群组的管控器也相同。
或者,您可以使用
mkdir 指令直接给此 cgroup 创建一个子 cgroup:
~]# mkdir /sys/fs/cgroup/controller/name/child_name
例如:
~]# mkdir /sys/fs/cgroup/net_prio/lab1/group1
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.