All Products
Search
Document Center

E-MapReduce:Use node labels

Last Updated:Jun 21, 2026

This topic describes YARN node labels, their usage, and common issues.

Background

YARN node labels partition YARN NodeManager nodes. Because a node can be assigned to only one node label, you can use node labels to divide a YARN cluster into disjoint sets of nodes. By default, nodes belong to the DEFAULT partition (partition="", an empty string).

Partitions can be configured as one of two types:

  • exclusive partition: Only containers that request this partition can be scheduled to its nodes.

  • non-exclusive partition: Containers requesting this partition, the DEFAULT partition, or no partition can be scheduled to its nodes if idle resources are available.

The Capacity Scheduler is the only scheduler that supports partition-based scheduling with node labels. You can configure the scheduler or use a compute engine's node-label-expression parameter to assign a queue's containers to accessible partitions.

For more information about node labels, see YARN Node Labels.

Limitations

  • This topic applies to EMR versions earlier than EMR-5.11.1 and EMR-3.45.1, provided that the yarn.node-labels.configuration-type parameter in your yarn-site.xml file is set to centralized.

  • EMR versions 5.11.1 and later and 3.45.1 and later support managing YARN partitions in the EMR console. For more information, see Manage YARN partitions in the EMR console.

Procedure

Enable node labels in the console

In the EMR console, go to the YARN service configuration page. On the yarn-site.xml tab, add the following properties. Then, save the configuration and restart the ResourceManager to apply the changes.

Key

Value

Description

yarn.node-labels.enabled

true

Enables the node labels feature.

yarn.node-labels.fs-store.root-dir

/tmp/node-labels

In centralized configuration mode, this property specifies the storage path for node label information. You can customize this path.

Note
  • This topic covers the centralized mode to explain the working principles of node label mapping. EMR versions 5.11.1 and later and 3.45.1 and later use yarn.node-labels.configuration-type=distributed by default. In these versions, you can manage YARN partitions in the EMR console without using the manual commands described in this topic. For more information, see Manage YARN partitions in the EMR console. For other requirements, refer to the official Hadoop community documentation.

  • If you set the yarn.node-labels.fs-store.root-dir property to a path without a scheme (instead of a full URL), YARN uses the default file system specified by fs.defaultFS. The configuration is then equivalent to ${fs.defaultFS}/tmp/node-labels. In EMR, the default file system is typically HDFS.

Add node labels and map nodes using commands

To automatically assign partitions to NodeManager nodes in an elastic node group during scale-out, add the replaceLabelsOnNode command to a bootstrap script for that node group after you create the partitions. The script runs after the node components start.

Example commands:

# Run commands as the default YARN administrator: hadoop
sudo su - hadoop
# Add partitions
yarn rmadmin -addToClusterNodeLabels "DEMO"
yarn rmadmin -addToClusterNodeLabels "CORE"
# List the YARN nodes
yarn node -list
# Map specific nodes to a partition
yarn rmadmin -replaceLabelsOnNode "core-1-1.c-XXX.cn-hangzhou.emr.aliyuncs.com=DEMO"
yarn rmadmin -replaceLabelsOnNode "core-1-2.c-XXX.cn-hangzhou.emr.aliyuncs.com=DEMO"

After the commands succeed, verify the results in the ResourceManager web UI.

  • On the ResourceManager Nodes page, the Node Labels column for the two core nodes (core-1-1 and core-1-2) shows DEMO, and the Node State is RUNNING. This indicates the node-to-label mapping is active.

  • On the Node Labels page, the table shows three added node labels: <DEFAULT_PARTITION>, CORE, and DEMO. Their Label Type is Exclusive Partition.

  • On the ResourceManager Nodes page, the Node Labels column for the two core nodes (core-1-1 and core-1-2) shows DEMO, and the Node State is RUNNING. This indicates the node-to-label mapping is active.

  • On the Node Labels page, the table shows three added node labels: <DEFAULT_PARTITION>, CORE, and DEMO. Their Label Type is Exclusive Partition.

  • On the ResourceManager Nodes page, the Node Labels column for the two core nodes (core-1-1 and core-1-2) shows DEMO, and the Node State is RUNNING. This indicates the node-to-label mapping is active.

  • On the Node Labels page, the table shows three added node labels: <DEFAULT_PARTITION>, CORE, and DEMO. Their Label Type is Exclusive Partition.

Configure queue partitions

To use the Capacity Scheduler, ensure that the yarn.resourcemanager.scheduler.class property in the yarn-site.xml file is set to org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler.

In the capacity-scheduler.xml file, use the following properties to configure a queue's accessible partitions and capacity. Replace <queue-path> with the queue path and <label> with the partition name. For the DEFAULT partition, you can use the regular capacity or maximum-capacity properties.

Parameter

Value

Description

yarn.scheduler.capacity.<queue-path>.accessible-node-labels

A comma-separated list of partitions.

Specifies the list of accessible partitions for the queue.

yarn.scheduler.capacity.<queue-path>.accessible-node-labels.<label>.capacity

For value rules, see yarn.scheduler.capacity.<queue-path>.capacity.

Specifies the resource capacity for the queue in the specified accessible partition.

Important

To take effect, you must also configure the capacity for all ancestor queues.

yarn.scheduler.capacity.<queue-path>.accessible-node-labels.<label>.maximum-capacity

For value rules, see yarn.scheduler.capacity.<queue-path>.maximum-capacity. The default value is 100.

Specifies the maximum resource capacity that the queue can use in the specified accessible partition.

yarn.scheduler.capacity.<queue-path>.default-node-label-expression

A partition name. The default is an empty string, which represents the DEFAULT partition.

Specifies the default partition for container requests in jobs that are submitted to this queue without a specified partition.

  • For a specified queue to have an actual resource capacity greater than 0, you must configure the capacity for the same partition on all of its ancestor queues. This is because the default value of the yarn.scheduler.capacity.<queue-path>.accessible-node-labels.<label>.capacity parameter is 0. Therefore, you must configure yarn.scheduler.capacity.root.accessible-node-labels.<label>.capacity=100 so that its child queues can have a non-zero capacity on the partition. (Theoretically, any value greater than 0 is sufficient, but configuring a value less than 100 reduces the calculated actual capacity for child queues and serves little purpose). If the capacity configuration for an ancestor queue is missing and defaults to 0, the calculated actual capacity for the target queue on this partition will also be 0.

  • After yarn.scheduler.capacity.root.accessible-node-labels.<label>.capacity is set to a value greater than 0, the same rule applies as for the regular yarn.scheduler.capacity.<queue-path>.capacity property: the sum of the capacity values for the same partition across all direct child queues must be 100.

    Example configuration:

    <configuration>
      <!-- Add node label properties in XML -->
      <property>
        <!-- Allow the default queue to access the DEMO partition (required) -->
        <name>yarn.scheduler.capacity.root.default.accessible-node-labels</name>
        <value>DEMO</value>
      </property>
      <property>
        <!-- Set the DEMO partition capacity on all ancestor queues of the default queue (required) -->
        <name>yarn.scheduler.capacity.root.accessible-node-labels.DEMO.capacity</name>
        <value>100</value>
      </property>
      <property>
        <!-- Set the DEMO partition capacity for the default queue (required) -->
        <name>yarn.scheduler.capacity.root.default.accessible-node-labels.DEMO.capacity</name>
        <value>100</value>
      </property>
      <property>
        <!-- Optional: set the maximum capacity for the default queue in the DEMO partition. The default is 100. -->
        <name>yarn.scheduler.capacity.root.default.accessible-node-labels.DEMO.maximum-capacity</name>
        <value>100</value>
      </property>
      <property>
        <!-- Optional: set the default partition for container requests of jobs submitted to the default queue. The default is the DEFAULT partition "" -->
        <name>yarn.scheduler.capacity.root.default.default-node-label-expression</name>
        <value>DEMO</value>
      </property>
    <configuration>
                            

After editing and saving the configuration, use the ResourceManager refreshQueues operation on the Status tab of the YARN service page to hot-update the scheduler configuration. Then, verify that the job runs as expected. After the job succeeds, verify the result in the ResourceManager web UI. After the configuration takes effect, on the ResourceManager Scheduler page, you can see that Partition: DEMO has allocated resources (memory:26214, vCores:16). The queue structure is Queue: root > Queue: default. This indicates that the DEMO partition and its queue capacity settings are applied.

Most compute engines (except Tez) also support node labels through job submission parameters, which are not covered in this topic.

Engine

Parameter

Description

MapReduce

mapreduce.job.node-label-expression

The default partition used by all containers in the job.

mapreduce.job.am.node-label-expression

The partition used by the ApplicationMaster.

mapreduce.map.node-label-expression

The partition used by map tasks.

mapreduce.reduce.node-label-expression

The partition used by reduce tasks.

Spark

spark.yarn.am.nodeLabelExpression

The partition used by the ApplicationMaster.

spark.yarn.executor.nodeLabelExpression

The partition used by the Executor.

Flink

yarn.application.node-label

The default partition used by all containers in the job.

yarn.taskmanager.node-label

The partition used by the TaskManager. Supported in Flink 1.15.0 and later, which corresponds to EMR-3.44.0 (3.x) and EMR-5.10.0 (5.x).

FAQ

Node label data storage in HA clusters

Yes. In a high availability (HA) cluster, ResourceManager is deployed on multiple nodes. By default, open-source Hadoop stores node label data in a local directory, such as file:///tmp/hadoop-yarn-${user}/node-labels/. After a failover, the new active ResourceManager cannot read the previous node's locally stored node label data. Therefore, you must set yarn.node-labels.fs-store.root-dir to a distributed storage path, such as /tmp/node-labels or ${fs.defaultFS}/tmp/node-labels. In EMR, the default file system is HDFS. For details, see Procedure.

Important

For a custom distributed path, make sure the file system service is healthy and that the hadoop user has read and write access. Otherwise, ResourceManager fails to start.

Specifying the NodeManager port

In an EMR cluster, each node runs at most one NodeManager process, so specifying a port is unnecessary. If you specify an incorrect or random port, the replaceLabelsOnNode command will fail to map the node to the partition. You can run yarn node -list -showDetails to view the current partition of a node.

Use cases for node labels

In most cases, node labels are unnecessary in an EMR cluster. Many metrics in open-source Hadoop YARN do not account for partitions and only report status for the DEFAULT partition, which increases operational complexity. Partition-based scheduling may also reduce overall resource utilization and lead to wasted resources. Typical use cases include isolating batch jobs and streaming jobs by partition, pinning critical jobs to non-elastic nodes, and accommodating different instance types on separate partitions to prevent resource imbalance.

Related documentation

To manage cluster nodes by partition, see Use node labels to partition nodes.