acl不起作用

nr9pn0ug  于 2021-05-30  发布在  Hadoop
关注(0)|答案(4)|浏览(494)

我已使用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>
juzqafwq

juzqafwq1#

你需要创造 allocations.xml/etc/hadoop/ 文件夹。在中定义所有这些属性 allocations.xml 还指定中与计划程序相关的更改 yarn-site.xml ```

yarn.resourcemanager.scheduler.class
org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler


yarn.scheduler.fair.allocation.file
allocations.xml

8yparm6h

8yparm6h2#

<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>

对我有用。谢谢大家

e5nszbig

e5nszbig3#

注意:这是关于容量调度器的。不确定公平调度程序acl继承行为是否不同。
ACL通过配置 yarn.scheduler.capacity.<queue-path>.acl_submit_applications ,请参阅容量调度器: yarn.scheduler.capacity.root.<queue-path>.acl_submit_applications 控制谁可以向给定队列提交应用程序的acl。如果给定用户/组在给定队列或层次结构中的某个父队列上有必要的ACL,则可以提交应用程序。如果未指定,则此属性的ACL将从父队列继承。
请注意有关队列继承父队列ACL的部分。因为通常所有队列都从根队列继承,根队列acl保留在default 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;
  }

并不是说代码在队列层次结构上迭代(通过在名称中的每个句点分割ad),直到父队列之一授予访问权。就像容量调度器的行为一样。直到它到达根队列,这时这段代码就会生效:

/**
   * 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行为,但代码可能在读取时执行。

dsekswqp

dsekswqp4#

在文件中写入“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策略是“*”,因此,所有用户都有权访问所有队列。

相关问题