通过YARN Label实现大数据集群资源管理与隔离
大数据集群中如果只配置多队列的机制,容易存在不同应用程序之间的资源争用、多租户资源难以隔离开的问题,而且有时候集群的硬件存在较大差异需要区别分类。这时候使用YARN Label可以将集群划分为不同的逻辑部分,每个部分都有自己的资源池,从而避免资源争用和提供更好的隔离
配置YARN Label实现队列资源隔离的步骤
开启Node Label特性
首先,在yarn-site.xml
中启用Node Label特性,并设置Node Label信息存储在HDFS上的目录(在ResourceManager重启后,标签信息不会丢失)
xmlCopy code<!-- Yarn Node Labels -->
<property>
<name>yarn.node-labels.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.node-labels.fs-store.root-dir</name>
<value>hdfs://your-hdfs-path/yarn/node-labels</value>
<description>标签数据在HDFS上的存储位置</description>
</property>
添加和删除集群标签
使用yarn rmadmin
命令来添加或删除集群标签:
bashCopy code# 添加标签
yarn rmadmin -addToClusterNodeLabels "label1,label2"
# 删除标签
yarn rmadmin -removeFromClusterNodeLabels "label1,label2"
将机器绑定到Label
通过yarn rmadmin
命令,将特定机器绑定到指定的Label:
bashCopy code# 将机器绑定到标签
yarn rmadmin -replaceLabelsOnNode "hostname=label1"
可以一次性为多台机器绑定标签:
bashCopy code# 为多台机器绑定标签
yarn rmadmin -replaceLabelsOnNode "hostname1=label1 hostname2=label2"
4. 队列绑定到Label
在队列配置中,指定队列可以在具有特定Label的机器上运行:
xmlCopy code<!-- 配置队列 -->
<property>
<name>yarn.scheduler.capacity.root.queues</name>
<value>queue1,queue2</value>
</property>
<property>
<name>yarn.scheduler.capacity.root.queue1.accessible-node-labels</name>
<value>label1</value>
</property>
<property>
<name>yarn.scheduler.capacity.root.queue2.accessible-node-labels</name>
<value>label2</value>
</property>
可以重启ResourceManager以使配置生效
5. 刷新队列配置
配置生效后,使用以下命令刷新队列配置:
bashCopy code
yarn rmadmin -refreshQueues