Configure node labels

You can configure node labels on a cluster by making configuration changes on the YARN ResourceManager host.

Enable Node Labels

To enable Node Labels on a cluster, make the following configuration changes on the YARN ResourceManager host.

  1. Create a Label Directory in HDFS

    Use the following commands to create a "node-labels" directory in which to store the Node Labels in HDFS.

    sudo su hdfs
    hadoop fs -mkdir -p /yarn/node-labels
    hadoop fs -chown -R yarn:yarn /yarn
    hadoop fs -chmod -R 700 /yarn

    -chmod -R 700 specifies that only the yarn user can access the "node-labels" directory.

    You can then use the following command to confirm that the directory was created in HDFS.

    hadoop fs -ls /yarn

    The new node label directory should appear in the list returned by the following command. The owner should be yarn, and the permission should be drwx.

    Found 1 items
    drwx------ - yarn yarn 0 2014-11-24 13:09 /yarn/node-labels

    Use the following commands to create a /user/<user_name> directory that is required by the distributed shell.

    hadoop fs -mkdir -p /user/<user_name>
    hadoop fs -chown -R yarn:yarn /user/<user_name>
    hadoop fs -chmod -R 700 /user/<user_name>
  2. In Cloudera Manager, select the YARN service.
  3. Click the Configuration tab.
  4. Search for YARN Service Advanced Configuration.
  5. In YARN Service Advanced Configuration Snippet (Safety Valve) for yarn-site.xml add the following:
    • Set the following property to enable Node Labels:
      Name: yarn.node-labels.enabled
      Value: true
    • Set the following property to reference the HDFS node label directory
      Name: yarn.node-labels.fs-store.root-dir
      Value: hdfs://:/

      For example,

      Name: yarn.node-labels.fs-store.root-dir
      Value: hdfs://node-1.example.com:8020/yarn/node-labels/ 
  6. Start or Restart the YARN ResourceManager.

Add Node Labels

Use the following command format to add Node Labels. You should run these commands as the yarn user. Node labels must be added before they can be assigned to nodes and associated with queues.

sudo su yarn
yarn rmadmin -addToClusterNodeLabels "<label1>(exclusive=<true|false>),<label2>(exclusive=<true|false>)"

For example, the following commands add the node label "x" as exclusive, and "y" as shareable (non-exclusive).

sudo su yarn
yarn rmadmin -addToClusterNodeLabels "x(exclusive=true),y(exclusive=false)"

You can use the yarn cluster --list-node-labels command to confirm that Node Labels have been added:

[root@node-1 /]# yarn cluster --list-node-labels
15/07/11 13:55:43 INFO impl.TimelineClientImpl: Timeline service address: http://node-1.example.com:8188/ws/v1/timeline/
15/07/11 13:55:43 INFO client.RMProxy: Connecting to ResourceManager at node-1.example.com/240.0.0.10:8032
Node Labels: <x:exclusivity=true>,<y:exclusivity=false>
You can use the following command format to remove Node Labels:
yarn rmadmin -removeFromClusterNodeLabels "<label1>,<label2>"

Confirm Node Label Assignments

You can use the following commands to view information about node labels.

  • List all running nodes in the cluster: yarn node -list

    Example:

    [root@node-1 /]# yarn node -list
    14/11/21 12:14:06 INFO impl.TimelineClientImpl: Timeline service address: http://node-1.example.com:8188/ws/v1/timeline/
    14/11/21 12:14:07 INFO client.RMProxy: Connecting to ResourceManager at node-1.example.com/240.0.0.10:8032
    Total Nodes:3
     Node-Id Node-State Node-Http-Address Number-of-Running-Containers
    node-3.example.com:45454 RUNNING node-3.example.com:50060 0
    node-1.example.com:45454 RUNNING node-1.example.com:50060 0
    node-2.example.com:45454 RUNNING node-2.example.com:50060 0
  • List all node labels in the cluster: yarn cluster --list-node-labels

    Example:

    [root@node-1 /]# yarn cluster --list-node-labels
    15/07/11 13:55:43 INFO impl.TimelineClientImpl: Timeline service address: http://node-1.example.com:8188/ws/v1/timeline/
    15/07/11 13:55:43 INFO client.RMProxy: Connecting to ResourceManager at node-1.example.com/240.0.0.10:8032
    Node Labels: <x:exclusivity=true>,<y:exclusivity=false>
  • List the status of a node (includes node labels): yarn node -status <Node_ID>

    Example:

    [root@node-1 /]# yarn node -status node-1.example.com:45454
    14/11/21 06:32:35 INFO impl.TimelineClientImpl: Timeline service address: http://node-1.example.com:8188/ws/v1/timeline/
    14/11/21 06:32:35 INFO client.RMProxy: Connecting to ResourceManager at node-1.example.com/240.0.0.10:8032
    Node Report : 
     Node-Id : node-1.example.com:45454
     Rack : /default-rack
     Node-State : RUNNING
     Node-Http-Address : node-1.example.com:50060
     Last-Health-Update : Fri 21/Nov/14 06:32:09:473PST
     Health-Report : 
     Containers : 0
     Memory-Used : 0MB
     Memory-Capacity : 1408MB
     CPU-Used : 0 vcores
     CPU-Capacity : 8 vcores
     Node-Labels : x

Node labels are also displayed in the ResourceManager UI on the Nodes and Scheduler pages.