YARN中公平调度程序的ACL不起作用

时间:2014-09-15 10:56:37

标签: hadoop mapreduce yarn hadoop2

我已在fair-scheduler.xml中使用ACL配置了我的队列。     但是其他用户也可以将作业运行到同一队列中。     我是否需要根据我的队列在其他地方定义ACL。     任何链接或帮助将不胜感激。谢谢

 <queue name="queue1">
            <minResources>10000mb,10vcores</minResources>
            <maxResources>30000mb,30vcores</maxResources>
            <maxRunningApps>10</maxRunningApps>
            <weight>2.0</weight>
            <schedulingMode>fair</schedulingMode>
            <aclAdministerApps>User1</aclAdministerApps>
            <aclSubmitApps>User1</aclSubmitApps>
    </queue> 

4 个答案:

答案 0 :(得分:1)

注意:这是关于容量调度程序。不确定Fair调度程序ACL继承行为是否不同。

通过yarn.scheduler.capacity.<queue-path>.acl_submit_applications配置ACL,请参阅Capacity Scheduler

  

yarn.scheduler.capacity.root.<queue-path>.acl_submit_applications控制谁可以将应用程序提交到给定队列的ACL。如果给定用户/组在给定队列上具有必要的ACL,或者在层次结构中具有一个父队列,则他们可以提交应用程序。如果未指定,则此属性的ACL将从父队列继承。

请注意有关继承父队列ACL的队列的位。由于通常所有队列都从根队列继承而根队列ACL保留为默认capacity-scheduler.xml *

<property>
 <name>yarn.scheduler.capacity.root.default.acl_submit_applications</name>
 <value>*</value>
 <description>
  The ACL of who can submit jobs to the default queue.
 </description>
</property>

通常所有队列都会获得所有用户(*)能够提交的ACL。配置队列时,应确保限制父队列以及所需的队列。

更新

在查看FS队列代码后,我必须得出结论,行为是相同的。访问检查在AllocationConfiguration.hasAccess()

中完成
 public boolean hasAccess(String queueName, QueueACL acl,
      UserGroupInformation user) {
    int lastPeriodIndex = queueName.length();
    while (lastPeriodIndex != -1) {
      String queue = queueName.substring(0, lastPeriodIndex);
      if (getQueueAcl(queue, acl).isUserAllowed(user)) {
        return true;
      }

      lastPeriodIndex = queueName.lastIndexOf('.', lastPeriodIndex - 1);
    }

    return false;
  }

不是代码在队列层次结构上迭代(通过在名称中的每个句点分割广告),直到其中一个父队列授予访问权限。完全像容量调度程序行为。在它到达根队列之前,此时这一小段代码生效:

/**
   * Get the ACLs associated with this queue. If a given ACL is not explicitly
   * configured, include the default value for that ACL.  The default for the
   * root queue is everybody ("*") and the default for all other queues is
   * nobody ("")
   */
  public AccessControlList getQueueAcl(String queue, QueueACL operation) {
    Map<QueueACL, AccessControlList> queueAcls = this.queueAcls.get(queue);
    if (queueAcls != null) {
      AccessControlList operationAcl = queueAcls.get(operation);
      if (operationAcl != null) {
        return operationAcl;
      }
    }
    return (queue.equals("root")) ? EVERYBODY_ACL : NOBODY_ACL;
  }

还要注意如何加载队列,来自AllocationFileLoaderService.reloadAllocations()

// Load queue elements.  A root queue can either be included or omitted.  If
// it's included, all other queues must be inside it.
for (Element element : queueElements) {
  String parent = "root";
  ...
  loadQueue(parent, element, minQueueResources, maxQueueResources,
      queueMaxApps, userMaxApps, queueMaxAMShares, queueWeights,
      queuePolicies, minSharePreemptionTimeouts, queueAcls,
      configuredQueues);
}

/**
* Loads a queue from a queue element in the configuration file
*/
private void loadQueue(String parentName, Element element, ...) 
  throws AllocationConfigurationException {
String queueName = element.getAttribute("name");
if (parentName != null) {
  queueName = parentName + "." + queueName;
}    

注意队列名称实际上是如何与父队列连接的,"root"是所有队列的隐式父级。因此,您的队列名称确实是root.queue1

所以这意味着在FS调度程序中,默认情况下所有队列都可以访问每个人,因为它们都继承了root队列的默认访问权限。您需要显式覆盖配置文件中的root队列ACL。这与CapacityScheduler没有什么不同,但我认为获取默认表单配置的CS行为优于从代码获取默认值的FS行为。

我实际上没有测试过FS行为,但代码可能会在读取时执行。

答案 1 :(得分:1)

在文件中写入“root”队列,这是yarn.scheduler.fair.allocation.file的值。

例如:

在yarn-site.xml中

<property>
  <name>yarn.scheduler.fair.allocation.file</name>
  <value>/etc/hadoop/conf/fair-scheduler.xml</value>
</property>

在fair-scheduler.xml中,应该为根队列定义acl权限。

<?xml version="1.0"?>
 <allocations>
 <queue name="root">
 <aclSubmitApps>user1,user2</aclSubmitApps>
 <aclAdministerApps>user1,user2,user3</aclAdministerApps>
 <minResources>xxxx mb,xxxvcores</minResources>
 <maxResources>xxxx mb,xxxvcores</maxResources>
 <maxRunningApps>30</maxRunningApps>
 <minSharePreemptionTimeout>10</minSharePreemptionTimeout>

 <!--sub queue begin-->
 <queue name="mapreduce">
 <minResources>xxxx mb,xxvcores</minResources>
 <maxResources>xxxx mb,xxvcores</maxResources>

...            

 </queue>
</allocations>

如果用户被授权父队列,则他们被授权进行子队列。 根队列的默认acl策略是&#34; *&#34;因此,所有用户都有权使用所有队列。

答案 2 :(得分:1)

<queue name="root">
<aclSubmitApps> </aclSubmitApps>
<queue name="queue1">
        <minResources>10000mb,10vcores</minResources>
        <maxResources>30000mb,30vcores</maxResources>
        <maxRunningApps>10</maxRunningApps>
        <weight>2.0</weight>
        <schedulingMode>fair</schedulingMode>
        <aclAdministerApps>User1</aclAdministerApps>
        <aclSubmitApps>User1</aclSubmitApps>
</queue> 
</queue>

这对我有用。谢谢所有

答案 3 :(得分:0)

您需要在allocations.xml文件夹中创建/etc/hadoop/。 在allocations.xml

中定义所有这些属性

还在yarn-site.xml

中指定与调度程序相关的更改
<property>
  <name>yarn.resourcemanager.scheduler.class</name>
  <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>
</property>
<property>
  <name>yarn.scheduler.fair.allocation.file</name>
  <value>allocations.xml</value>
</property>