Enabling CGroups
CGroups is a Linux kernel feature. CGroups is supported on the following Linux operating systems:
CentOS 6.9, 7.3
RHEL 6.9, 7.3
SUSE 12
Ubuntu 16
At this time there is no CGroups equivalent for Windows. CGroups are not enabled by default on HDP. CGroups require that the HDP cluster be Kerberos enabled.
Important | |
---|---|
The |
Enable CGroups
The following commands must be run on every reboot of the
NodeManager hosts to set up the CGroup hierarchy. Note that operating systems use different
mount points for the CGroup interface. Replace /sys/fs/cgroup
with your operating
system equivalent.
mkdir -p /sys/fs/cgroup/cpu/yarn chown -R yarn /sys/fs/cgroup/cpu/yarn mkdir -p /sys/fs/cgroup/memory/yarn chown -R yarn /sys/fs/cgroup/memory/yarn mkdir -p /sys/fs/cgroup/blkio/yarn chown -R yarn /sys/fs/cgroup/blkio/yarn mkdir -p /sys/fs/cgroup/net_cls/yarn chown -R yarn /sys/fs/cgroup/net_cls/yarn
To enable CGroups on an Ambari cluster, select YARN > Configs, then click CPU Isolation under CPU. As noted previously, CGroups should be enabled along with CPU Scheduling.
On a non-Ambari cluster, set the following properties in the
/etc/hadoop/conf/yarn-site.xml
file on the ResourceManager and
NodeManager hosts.
Property:
yarn.nodemanager.container-executor.class
Value:
org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor
Example:
<property> <name>yarn.nodemanager.container-executor.class</name> <value>org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor</value> </property>
Property:
yarn.nodemanager.linux-container-executor.group
Value:
hadoop
Example:
<property> <name>yarn.nodemanager.linux-container-executor.group</name> <value>hadoop</value> </property>
Property:
yarn.nodemanager.linux-container-executor.resources-handler.class
Value:
org.apache.hadoop.yarn.server.nodemanager.util.CgroupsLCEResourcesHandler
Example:
<property> <name>yarn.nodemanager.linux-container-executor.resources-handler.class</name> <value>org.apache.hadoop.yarn.server.nodemanager.util.CgroupsLCEResourcesHandler</value> </property>
Property:
yarn.nodemanager.linux-container-executor.cgroups.hierarchy
Value:
/yarn
Example:
<property> <name>yarn.nodemanager.linux-container-executor.cgroups.hierarchy</name> <value>/yarn</value> </property>
Property:
yarn.nodemanager.linux-container-executor.cgroups.mount
Value:
false
Example:
<property> <name>yarn.nodemanager.linux-container-executor.cgroups.mount</name> <value>false</value> </property>
Property:
yarn.nodemanager.linux-container-executor.cgroups.mount-path
Value:
/sys/fs/cgroup
Example:
<property> <name>yarn.nodemanager.linux-container-executor.cgroups.mount-path</name> <value>/sys/fs/cgroup</value> </property>
Set the Percentage of CPU used by YARN
Set the percentage of CPU that can be allocated for YARN containers. In most cases, the default value of 100% should be used. If you have another process that needs to run on a node that also requires CPU resources, you can lower the percentage of CPU allocated to YARN to free up resources for the other process.
Property:
yarn.nodemanager.resource.percentage-physical-cpu-limit
Value:
100
Example:
<property> <name>yarn.nodemanager.resource.percentage-physical-cpu-limit</name> <value>100</value> </property>
Set Flexible or Strict CPU limits
CPU jobs are constrained with CPU scheduling and CGroups enabled, but by default these are flexible limits. If spare CPU cycles are available, containers are allowed to exceed the CPU limits set for them. With flexible limits, the amount of CPU resources available for containers to use can vary based on cluster usage -- the amount of CPU available in the cluster at any given time.
You can use CGroups to set strict limits on CPU usage. When strict limits are enabled, each process receives only the amount of CPU resources it requests. With strict limits, a CPU process will receive the same amount of cluster resources every time it runs.
Strict limits are not enabled (set to false
) by default. To enable
strict CPU limits, set the following property to true
.
Property:
yarn.nodemanager.linux-container-executor.cgroups.strict-resource-usage
Value:
true
Example:
<property> <name>yarn.nodemanager.linux-container-executor.cgroups.strict-resource-usage</name> <value>true</value> </property>
Note | |
---|---|
Irrespective of whether this property is |