本文共 20951 字,大约阅读时间需要 69 分钟。
Control Groups provide a mechanism for aggregating/partitioning sets oftasks, and all their future children, into hierarchical groups withspecialized behaviour.Definitions:A *cgroup* associates a set of tasks(PID) with a set of parameters for oneor more subsystems.A *subsystem* is a module that makes use of the task groupingfacilities provided by cgroups to treat groups of tasks inparticular ways. A subsystem is typically a "resource controller" thatschedules a resource or applies per-cgroup limits, but it may beanything that wants to act on a group of processes, e.g. avirtualization subsystem.A *hierarchy* is a set of cgroups arranged in a tree, such thatevery task in the system is in exactly one of the cgroups in thehierarchy, and a set of subsystems; each subsystem has system-specificstate attached to each cgroup in the hierarchy. Each hierarchy hasan instance of the cgroup virtual filesystem associated with it.At any one time there may be multiple active hierarchies of taskcgroups. Each hierarchy is a partition of all tasks in the system.
As an example of a scenario (originally proposed by vatsa@in.ibm.com)that can benefit from multiple hierarchies, consider a largeuniversity server with various users - students, professors, systemtasks etc. The resource planning for this server could be along thefollowing lines: CPU : "Top cpuset" / \ CPUSet1 CPUSet2 | | (Professors) (Students) In addition (system tasks) are attached to topcpuset (so that they can run anywhere) with a limit of 20% Memory : Professors (50%), Students (30%), system (20%) Disk : Professors (50%), Students (30%), system (20%) Network : WWW browsing (20%), Network File System (60%), others (20%) / \ Professors (15%) students (5%)
[root@150 cgroup]# cat /proc/mounts tmpfs /sys/fs/cgroup tmpfs rw,nosuid,nodev,noexec,mode=755 0 0cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpuacct,cpu 0 0cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0cgroup /sys/fs/cgroup/net_cls cgroup rw,nosuid,nodev,noexec,relatime,net_cls 0 0cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0cgroup /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0自定义继承资源组, 建议使用这种做法.
For example, the following sequence of commands will setup a cgroupnamed "Charlie", containing just CPUs 2 and 3, and Memory Node 1,and then start a subshell 'sh' in that cgroup:# 如果没有挂载的话, 需要先挂载一次 mount -t tmpfs cgroup_root /sys/fs/cgroup 创建自定义资源组(cpuset组已经存在, 所以不需要创建) mkdir /sys/fs/cgroup/cpuset挂载资源组(cpuset组已经存在, 所以不需要挂载) mount -t cgroup cpuset -o cpuset /sys/fs/cgroup/cpuset在cpuset组下面创建一个自定义组 cd /sys/fs/cgroup/cpuset mkdir Charlie cd Charlie在自定义组中配置CPU和内存资源控制, 如CPU核亲和 /bin/echo 2-3 > cpuset.cpus /bin/echo 1 > cpuset.mems将当前进程号放到这个组中. $$返回当前进程号 /bin/echo $$ > tasks sh # The subshell 'sh' is now running in cgroup Charlie # The next line should display '/Charlie' cat /proc/self/cgroup
[root@150 ~]# cd /sys/fs/cgroup/[root@150 cgroup]# lltotal 0drwxr-xr-x 2 root root 40 Nov 27 19:03 blkiolrwxrwxrwx 1 root root 11 Nov 27 19:03 cpu -> cpu,cpuacctlrwxrwxrwx 1 root root 11 Nov 27 19:03 cpuacct -> cpu,cpuacctdrwxr-xr-x 2 root root 40 Nov 27 19:03 cpu,cpuacctdrwxr-xr-x 2 root root 40 Nov 27 19:03 cpusetdrwxr-xr-x 2 root root 40 Nov 27 19:03 devicesdrwxr-xr-x 2 root root 40 Nov 27 19:03 freezerdrwxr-xr-x 2 root root 40 Nov 27 19:03 hugetlbdrwxr-xr-x 2 root root 40 Nov 27 19:03 memorydrwxr-xr-x 2 root root 40 Nov 27 19:03 net_clsdrwxr-xr-x 2 root root 40 Nov 27 19:03 perf_eventdrwxr-xr-x 2 root root 40 Dec 3 23:25 rg1drwxr-xr-x 4 root root 0 Nov 27 19:03 systemd[root@150 ~]# mountcgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)如果没有自动挂载的话, 我们也可以手工挂载 :
As explained in section `1.2 Why are cgroups needed?' you should createdifferent hierarchies of cgroups for each single resource or group ofresources you want to control. Therefore, you should mount a tmpfs on/sys/fs/cgroup and create directories for each cgroup resource or resourcegroup.# mount -t tmpfs cgroup_root /sys/fs/cgroup# mkdir /sys/fs/cgroup/rg1To mount a cgroup hierarchy with just the cpuset and memorysubsystems, type:# 必须在没有初始化挂载时挂载, 如果系统已经挂载了这些组, 那么不建议重复挂载. (-o中指定的cpuset, memory如果已经挂载, 则不必重复挂载)# mount -t cgroup -o cpuset,memory hier1 /sys/fs/cgroup/rg1While remounting cgroups is currently supported, it is not recommendto use it. Remounting allows changing bound subsystems andrelease_agent. Rebinding is hardly useful as it only works when thehierarchy is empty and release_agent itself should be replaced withconventional fsnotify. The support for remounting will be removed inthe future.
[root@150 cgroup]# cd /sys/fs/cgroup/[root@150 cgroup]# lltotal 0drwxr-xr-x 4 root root 0 Nov 27 19:25 blkiolrwxrwxrwx 1 root root 11 Nov 27 19:03 cpu -> cpu,cpuacctlrwxrwxrwx 1 root root 11 Nov 27 19:03 cpuacct -> cpu,cpuacctdrwxr-xr-x 4 root root 0 Nov 27 19:25 cpu,cpuacctdrwxr-xr-x 2 root root 0 Nov 27 19:03 cpusetdrwxr-xr-x 2 root root 0 Nov 28 22:20 devicesdrwxr-xr-x 3 root root 0 Nov 27 19:03 freezerdrwxr-xr-x 2 root root 0 Nov 27 19:03 hugetlbdrwxr-xr-x 3 root root 0 Nov 27 19:25 memorydrwxr-xr-x 2 root root 0 Nov 27 19:03 net_clsdrwxr-xr-x 2 root root 0 Nov 27 19:03 perf_eventdrwxr-xr-x 4 root root 0 Nov 27 19:03 systemd
[root@150 cgroup]# cat cpuset/cpuset.cpus0-7[root@150 cgroup]# ll cpuset/total 0-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.clone_children--w--w--w- 1 root root 0 Nov 27 19:03 cgroup.event_control-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.procs-r--r--r-- 1 root root 0 Nov 27 19:03 cgroup.sane_behavior-rw-r--r-- 1 root root 0 Nov 27 19:03 cpuset.cpu_exclusive-rw-r--r-- 1 root root 0 Nov 27 19:03 cpuset.cpus-rw-r--r-- 1 root root 0 Nov 27 19:03 cpuset.mem_exclusive-rw-r--r-- 1 root root 0 Nov 27 19:03 cpuset.mem_hardwall-rw-r--r-- 1 root root 0 Nov 27 19:03 cpuset.memory_migrate-r--r--r-- 1 root root 0 Nov 27 19:03 cpuset.memory_pressure-rw-r--r-- 1 root root 0 Nov 27 19:03 cpuset.memory_pressure_enabled-rw-r--r-- 1 root root 0 Nov 27 19:03 cpuset.memory_spread_page-rw-r--r-- 1 root root 0 Nov 27 19:03 cpuset.memory_spread_slab-rw-r--r-- 1 root root 0 Nov 27 19:03 cpuset.mems-rw-r--r-- 1 root root 0 Nov 27 19:03 cpuset.sched_load_balance-rw-r--r-- 1 root root 0 Nov 27 19:03 cpuset.sched_relax_domain_level-rw-r--r-- 1 root root 0 Nov 27 19:03 notify_on_release-rw-r--r-- 1 root root 0 Nov 27 19:03 release_agent-rw-r--r-- 1 root root 0 Nov 27 19:03 tasks例如memory可以控制哪些资源呢?
[root@150 cgroup]# ll memory/total 0-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.clone_children--w--w--w- 1 root root 0 Nov 27 19:03 cgroup.event_control-rw-r--r-- 1 root root 0 Dec 3 23:30 cgroup.procs-r--r--r-- 1 root root 0 Nov 27 19:03 cgroup.sane_behavior-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.failcnt--w------- 1 root root 0 Nov 27 19:03 memory.force_empty-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.failcnt-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.limit_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.max_usage_in_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.slabinfo-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.tcp.failcnt-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.tcp.limit_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.tcp.max_usage_in_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.tcp.usage_in_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.usage_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.limit_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.max_usage_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.memsw.failcnt-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.memsw.limit_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.memsw.max_usage_in_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 memory.memsw.usage_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.move_charge_at_immigrate-r--r--r-- 1 root root 0 Nov 27 19:03 memory.numa_stat-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.oom_control---------- 1 root root 0 Nov 27 19:03 memory.pressure_level-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.soft_limit_in_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 memory.stat-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.swappiness-r--r--r-- 1 root root 0 Nov 27 19:03 memory.usage_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.use_hierarchy-rw-r--r-- 1 root root 0 Nov 27 19:03 notify_on_release-rw-r--r-- 1 root root 0 Nov 27 19:03 release_agentdrwxr-xr-x 10 root root 0 Nov 28 18:33 system.slice-rw-r--r-- 1 root root 0 Nov 27 19:03 tasks例如devices可以控制哪些资源呢?
[root@150 cgroup]# ll devices/total 0-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.clone_children--w--w--w- 1 root root 0 Nov 27 19:03 cgroup.event_control-rw-r--r-- 1 root root 0 Dec 3 23:30 cgroup.procs-r--r--r-- 1 root root 0 Nov 27 19:03 cgroup.sane_behavior--w------- 1 root root 0 Nov 27 19:03 devices.allow--w------- 1 root root 0 Nov 27 19:03 devices.deny-r--r--r-- 1 root root 0 Nov 27 19:03 devices.list-rw-r--r-- 1 root root 0 Nov 27 19:03 notify_on_release-rw-r--r-- 1 root root 0 Nov 27 19:03 release_agent-rw-r--r-- 1 root root 0 Nov 27 19:03 tasks其他资源控制 :
[root@150 cgroup]# ll net_cls/total 0-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.clone_children--w--w--w- 1 root root 0 Nov 27 19:03 cgroup.event_control-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.procs-r--r--r-- 1 root root 0 Nov 27 19:03 cgroup.sane_behavior-rw-r--r-- 1 root root 0 Nov 27 19:03 net_cls.classid-rw-r--r-- 1 root root 0 Nov 27 19:03 notify_on_release-rw-r--r-- 1 root root 0 Nov 27 19:03 release_agent-rw-r--r-- 1 root root 0 Nov 27 19:03 tasks[root@150 cgroup]# ll systemd/total 0-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.clone_children--w--w--w- 1 root root 0 Nov 27 19:03 cgroup.event_control-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.procs-r--r--r-- 1 root root 0 Nov 27 19:03 cgroup.sane_behavior-rw-r--r-- 1 root root 0 Nov 27 19:03 notify_on_release-rw-r--r-- 1 root root 0 Nov 27 19:03 release_agentdrwxr-xr-x 85 root root 0 Dec 3 22:10 system.slice-rw-r--r-- 1 root root 0 Nov 27 19:03 tasksdrwxr-xr-x 3 root root 0 Nov 27 19:03 user.slice[root@150 cgroup]# ll freezer/total 0-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.clone_children--w--w--w- 1 root root 0 Nov 27 19:03 cgroup.event_control-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.procs-r--r--r-- 1 root root 0 Nov 27 19:03 cgroup.sane_behavior-rw-r--r-- 1 root root 0 Nov 27 19:03 notify_on_release-rw-r--r-- 1 root root 0 Nov 27 19:03 release_agentdrwxr-xr-x 10 root root 0 Nov 28 18:33 system.slice-rw-r--r-- 1 root root 0 Nov 27 19:03 tasks[root@150 cgroup]# ll hugetlb/total 0-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.clone_children--w--w--w- 1 root root 0 Nov 27 19:03 cgroup.event_control-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.procs-r--r--r-- 1 root root 0 Nov 27 19:03 cgroup.sane_behavior-rw-r--r-- 1 root root 0 Nov 27 19:03 hugetlb.2MB.failcnt-rw-r--r-- 1 root root 0 Nov 27 19:03 hugetlb.2MB.limit_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 hugetlb.2MB.max_usage_in_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 hugetlb.2MB.usage_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 notify_on_release-rw-r--r-- 1 root root 0 Nov 27 19:03 release_agent-rw-r--r-- 1 root root 0 Nov 27 19:03 tasks[root@150 cgroup]# ll blkio/total 0-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_merged-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_merged_recursive-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_queued-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_queued_recursive-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_service_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_service_bytes_recursive-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_serviced-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_serviced_recursive-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_service_time-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_service_time_recursive-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_wait_time-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.io_wait_time_recursive-rw-r--r-- 1 root root 0 Nov 27 19:03 blkio.leaf_weight-rw-r--r-- 1 root root 0 Nov 27 19:03 blkio.leaf_weight_device--w------- 1 root root 0 Nov 27 19:03 blkio.reset_stats-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.sectors-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.sectors_recursive-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.throttle.io_service_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.throttle.io_serviced-rw-r--r-- 1 root root 0 Nov 27 19:03 blkio.throttle.read_bps_device-rw-r--r-- 1 root root 0 Nov 27 19:03 blkio.throttle.read_iops_device-rw-r--r-- 1 root root 0 Nov 27 19:03 blkio.throttle.write_bps_device-rw-r--r-- 1 root root 0 Nov 27 19:03 blkio.throttle.write_iops_device-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.time-r--r--r-- 1 root root 0 Nov 27 19:03 blkio.time_recursive-rw-r--r-- 1 root root 0 Nov 27 19:03 blkio.weight-rw-r--r-- 1 root root 0 Nov 27 19:03 blkio.weight_device-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.clone_children--w--w--w- 1 root root 0 Nov 27 19:03 cgroup.event_control-rw-r--r-- 1 root root 0 Dec 3 22:30 cgroup.procs-r--r--r-- 1 root root 0 Nov 27 19:03 cgroup.sane_behavior-rw-r--r-- 1 root root 0 Nov 27 19:03 notify_on_release-rw-r--r-- 1 root root 0 Nov 27 19:03 release_agentdrwxr-xr-x 77 root root 0 Dec 3 22:10 system.slice-rw-r--r-- 1 root root 0 Nov 27 19:03 tasksdrwxr-xr-x 2 root root 0 Nov 27 19:25 user.slice不建议重复挂载, 在没有自动挂载的情况下, 可以这么来挂载 :
[root@150 cgroup]# mount -t cgroup -o cpuset cgroup /sys/fs/cgroup/cpuset[root@150 cgroup]# mount -t cgroup -o memory cgroup /sys/fs/cgroup/memory[root@150 cgroup]# mount -t cgroup -o blkio cgroup /sys/fs/cgroup/blkiocgroup on /sys/fs/cgroup/cpuset type cgroup (rw,relatime,cpuset)cgroup on /sys/fs/cgroup/memory type cgroup (rw,relatime,memory)cgroup on /sys/fs/cgroup/blkio type cgroup (rw,relatime,blkio)将一个资源组放进去是可以的
# 资源加入CGROUP.[root@150 cgroup]# cd /sys/fs/cgroup/cpuset[root@150 rg1]# lltotal 0-rw-r--r-- 1 root root 0 Nov 27 19:03 cgroup.clone_children--w--w--w- 1 root root 0 Nov 27 19:03 cgroup.event_control-rw-r--r-- 1 root root 0 Dec 3 23:20 cgroup.procs-r--r--r-- 1 root root 0 Nov 27 19:03 cgroup.sane_behavior-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.failcnt--w------- 1 root root 0 Nov 27 19:03 memory.force_empty-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.failcnt-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.limit_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.max_usage_in_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.slabinfo-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.tcp.failcnt-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.tcp.limit_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.tcp.max_usage_in_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.tcp.usage_in_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 memory.kmem.usage_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.limit_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.max_usage_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.memsw.failcnt-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.memsw.limit_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.memsw.max_usage_in_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 memory.memsw.usage_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.move_charge_at_immigrate-r--r--r-- 1 root root 0 Nov 27 19:03 memory.numa_stat-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.oom_control---------- 1 root root 0 Nov 27 19:03 memory.pressure_level-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.soft_limit_in_bytes-r--r--r-- 1 root root 0 Nov 27 19:03 memory.stat-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.swappiness-r--r--r-- 1 root root 0 Nov 27 19:03 memory.usage_in_bytes-rw-r--r-- 1 root root 0 Nov 27 19:03 memory.use_hierarchy-rw-r--r-- 1 root root 0 Nov 27 19:03 notify_on_release-rw-r--r-- 1 root root 0 Nov 27 19:03 release_agentdrwxr-xr-x 10 root root 0 Nov 28 18:33 system.slice-rw-r--r-- 1 root root 0 Nov 27 19:03 tasks将进程放到对应的资源组, 只需要将进程号添加到tasks文件即可.
[root@150 cgroup]# cd /sys/fs/cgroup/cpuset/[root@150 cpuset]# less tasks 12357891011......卸载资源组, 因为挂载了多次, 所以需要卸载多次.
[root@150 cgroup]# umount cgroup[root@150 cgroup]# umount cgroup[root@150 cgroup]# umount cgroup[root@150 cgroup]# umount cgroupumount: /sys/fs/cgroup/systemd: target is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))查看进程所在的资源组 :
[root@150 cpuset]# cat /proc/1/cgroup 10:hugetlb:/9:perf_event:/8:blkio:/7:net_cls:/6:freezer:/5:devices:/4:memory:/3:cpuacct,cpu:/2:cpuset:/1:name=systemd:/例如docker进程 :
[root@150 cpuset]# ps -efw|grep dockerroot 4661 1 0 Nov27 ? 00:02:45 /usr/bin/docker -d --selinux-enabled=false -g /data01/dockerroot 22830 20836 0 23:55 pts/1 00:00:00 grep --color=auto docker[root@150 cpuset]# ps -efw|grep 4661root 4661 1 0 Nov27 ? 00:02:45 /usr/bin/docker -d --selinux-enabled=false -g /data01/dockerroot 17299 4661 0 Nov28 ? 00:00:00 /usr/sbin/sshd -Droot 17325 4661 0 Nov28 ? 00:00:00 /usr/sbin/sshd -Droot 17351 4661 0 Nov28 ? 00:00:00 /usr/sbin/sshd -Droot 17377 4661 0 Nov28 ? 00:00:00 /usr/sbin/sshd -Droot 17403 4661 0 Nov28 ? 00:00:00 /usr/sbin/sshd -Droot 17429 4661 0 Nov28 ? 00:00:00 /usr/sbin/sshd -Droot 17456 4661 0 Nov28 ? 00:00:00 /usr/sbin/sshd -Droot 17485 4661 0 Nov28 ? 00:00:00 /usr/sbin/sshd -Droot 22832 20836 0 23:55 pts/1 00:00:00 grep --color=auto 4661[root@150 cpuset]# cat /proc/17299/cgroup 10:hugetlb:/9:perf_event:/8:blkio:/system.slice7:net_cls:/6:freezer:/system.slice/docker-59c41fc9560eb52b549de45d8996a34da2ea00f7711b40b757b0e035169ccd92.scope5:devices:/4:memory:/system.slice3:cpuacct,cpu:/system.slice2:cpuset:/1:name=systemd:/system.slice/docker-59c41fc9560eb52b549de45d8996a34da2ea00f7711b40b757b0e035169ccd92.scope
Index of /doc/Documentation/cgroupsName Last modified Size Parent Directory - 00-INDEX 01-Dec-2014 01:00 918 blkio-controller.txt 01-Dec-2014 01:00 16K cgroups.txt 01-Dec-2014 01:00 26K cpuacct.txt 01-Dec-2014 01:00 1.9K cpusets.txt 01-Dec-2014 01:00 36K devices.txt 01-Dec-2014 01:00 4.3K freezer-subsystem.txt 01-Dec-2014 01:00 4.8K hugetlb.txt 01-Dec-2014 01:00 1.7K memcg_test.txt 01-Dec-2014 01:00 8.3K memory.txt 01-Dec-2014 01:00 36K net_cls.txt 01-Dec-2014 01:00 1.2K net_prio.txt 01-Dec-2014 01:00 2.5K resource_counter.txt 01-Dec-2014 01:00 6.1K unified-hierarchy.txt 01-Dec-2014 01:00 16K
转载地址:http://bjesa.baihongyu.com/