Capacity Scheduler的隊列屬性介紹

概述
  本文基於 Apache hadoop 3.1.1 版本對Capacity Scheduler隊列屬性進行說明介紹。隊列的部分屬性對應於Yarn web中展示的隊列信息。下表是Yarn web中的隊列信息示例,在後面的隊列屬性介紹中,會指出屬性對應於隊列信息的哪個指標(如果有的話)。

Queue State:    RUNNING
Used Capacity:    <memory:0, vCores:0> (0.0%)
Configured Capacity:    <memory:0, vCores:0>
Configured Max Capacity:    unlimited
Effective Capacity:    <memory:755735, vCores:92> (15.0%)
Effective Max Capacity:    <memory:2519118, vCores:308> (50.0%)
Absolute Used Capacity:    0.0%
Absolute Configured Capacity:    15.0%
Absolute Configured Max Capacity:    50.0%
Used Resources:    <memory:
Configured Max Application Master Limit: 50.0    
Max Application Master Resources:    <memory:1261568, vCores:1>
Used Application Master Resources:    <memory:0, vCores:0>
Max Application Master Resources Per User:    <memory:1261568, vCores:1>
Num Schedulable Applications:    0
Num Non-Schedulable Applications:    0
Num Containers:    0
Max Applications:    20000
Max Applications Per User:    2000
Configured Minimum User Limit Percent:    20%
Configured User Limit Factor:    0.5
Accessible Node Labels:    *
Ordering Policy:    FifoOrderingPolicy
Preemption:    disabled
Intra-queue Preemption:    disabled
Default Node Label Expression:    <DEFAULT_PARTITION>
Default Application Priority:    0
資源分配
yarn.scheduler.capacity.<queue-path>.capacity:隊列資源容量的百分比,用浮點數表示(如12.5)或者是作爲絕對資源隊列的最小容量。在各層級上所有隊列的百分比之和必須等於100。但是,如果配置的是絕對資源值,則子隊列的絕對資源之和可能小於其父隊列的絕對資源容量。在有空閒資源的情況,隊列中的應用程序可能會消耗比隊列容量更多的資源,這樣可以使得隊列具有彈性。這個參數對應 Yarn web頁面中隊列信息的 Absolute Configured Capacity。
yarn.scheduler.capacity.<queue-path>.maximum-capacity:隊列最大資源容量的百分比,用浮點數表示或者是作爲絕對資源隊列的最大容量。限制隊列中應用程序的彈性(由於資源共享,一個隊列使用的資源量可能超過其容量,但最多使用資源量不能超過該資源量)。1) 如果表示百分比,則值介於 0 和 100之間;2)管理員需要確保每個隊列的最大絕對資源容量>=絕對資源容量。此外,將此值設置爲-1表示將最大容量設置爲100%。這個參數對應 Yarn web頁面中隊列信息的 Absolute Configured Max Capacity。
yarn.scheduler.capacity.<queue-path>.minimum-user-limit-percent:對用戶使用隊列的最小資源比例進行限制,或者說是對每個用戶最低使用資源的保障(百分比)。任何時刻,一個隊列中每個用戶可使用的資源量均有一定的限制。 當一個隊列中同時有多個用戶提交應用程序時,每個用戶的使用資源量會在一個最小值和最大值之間浮動,其中,最小值就是該參數指定的值,而最大值取決於提交應用程序的用戶數。比如,假設minimum-user-limit-percent爲25。當兩個用戶向該隊列提交應用程序時,每個用戶可使用資源量不能超過50%,如果三個用戶提交應用程序,則每個用戶可使用資源量不能超多33%,如果四個或者更多用戶提交應用程序,則每個用戶可用資源量不能超過25%。默認值是100,表示的是對用戶使用的最小資源比例不進行限制。這個參數對應 Yarn web頁面中隊列信息的 Configured Minimum User Limit Percent。在實際使用中,一直沒有明白該參數是怎麼發揮作用的,只知道該參數會對Yarn web頁面中隊列信息的 Max Applications Per User 的值產生影響。
yarn.scheduler.capacity.<queue-path>.user-limit-factor: 這個參數配置爲允許單個用戶最多能獲取的隊列資源(即yarn.scheduler.capacity.<queue-path>.capacity的值)的倍數,值是一個浮點值。也就是說如果把這個參數設置爲大於1時,用戶使用的資源可以超過隊列資源。比如,假設該值爲0.5,則任何時刻,單個用戶使用的資源量不能超過該隊列容量的50%;如果該值爲2.0,則單個用戶使用的最多資源量可以是該隊列容量的200%,但無論配置爲多大都不能超過隊列的最大資源(即yarn.scheduler.capacity.<queue-path>.maximum-capacity的值)。默認值爲1,確保單個用戶無論集羣有多空閒,永遠不會佔用超過隊列配置的資源量。這個參數對應 Yarn web頁面中隊列信息的 Configured User Limit Factor 。
yarn.scheduler.capacity.<queue-path>.maximum-allocation-mb: 向ResourceManager請求分配給隊列中container內存資源時的最大值。這個配置覆蓋集羣配置項 yarn.scheduler.maximum-allocation-mb。這個值必須小於等於集羣的最大值。這個配置可以使的不同隊列的container的最大內存值可以不一樣,用戶可以根據生產環境中實際的需求對不同的隊列設置不同的值,可以更進一步提高集羣的資源使用率。
yarn.scheduler.capacity.<queue-path>.maximum-allocation-vcores: 向ResourceManager請求分配給隊列中container vcore資源時的最大值。這個配置覆蓋集羣配置項yarn.scheduler.maximum-allocation-vcores。這個值必須小於等於集羣的最大值。這個配置可以使的不同隊列的container的最大內存值可以不一樣,用戶可以根據生產環境中實際的需求對不同的隊列設置不同的值,可以更進一步提高集羣的資源使用率。
yarn.scheduler.capacity.<queue-path>.user-settings.<user-name>.weight: 此浮點值用於計算隊列中用戶的用戶限制資源值。該值將使每個用戶的權重大於或小於隊列中的其他用戶。例如,如果用戶A在隊列中收到的資源比用戶B和C多50%,則用戶A的此屬性將設置爲1.5。用戶B和C將設置爲默認值1.0。也就說同一隊列中權重越大的用戶獲得的資源將會越多。
使用絕對值配置資源
  從Apache hadoop 3.1.0開始 CapacityScheduler支持配置絕對值格式的資源量。上面的 yarn.scheduler.capacity.<queue-path>.capacity 和 yarn.scheduler.capacity.<queue-path>.max-capacity 配置項,可以指定一個絕對資源量如 [memory=10240,vcores=12]。這表示爲隊列配置10GB的內存和12個Vcore。使用絕對值資源配置時,這2個參數分別對應Yarn web頁面中隊列信息的__Configured Capacity__和__Configured Max Capacity__。

  配置示例如下:

  <property>
    <name>yarn.scheduler.capacity.root.default.capacity</name>
    <value>[memory=16000,vcores=4]</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.default.maximum-capacity</name>
    <value>[memory=48000,vcores=12]</value>
  </property>

  並且不同的隊列同時可以使用不同的資源配置格式,也就是說有些隊列可以使用百分比格式,有些可以使用絕對值格式,而且實際使用時發現在這種混合配置中,各層級上所有隊列的百分比之和必須等於100的約束將不再有效。如下:

 <property>
    <name>yarn.scheduler.capacity.root.queue1.capacity</name>
    <value>[memory=160000,vcores=40]</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.queue1.maximum-capacity</name>
    <value>[memory=480000,vcores=2000]</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.queue2.capacity</name>
    <value>30.0</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.queue2.maximum-capacity</name>
    <value>50.0</value>
  </property>
    <property>
    <name>yarn.scheduler.capacity.root.queue3.capacity</name>
    <value>80.0</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.queue3.maximum-capacity</name>
    <value>-1</value>
  </property>

  上述配置中,queue2和queue3的容量之和爲110已經超出了100,但是依然有效。

應用程序數目限制
yarn.scheduler.capacity.maximum-applications / yarn.scheduler.capacity.<queue-path>.maximum-applications :集羣或者隊列中同時處於running和pending狀態的應用程序數目上限,這是一個強限制,一旦集羣中應用程序數目超過該上限,後續提交的應用程序將被拒絕,默認值爲10000。整個root隊列的數目上限可通過參數yarn.scheduler.capacity.maximum-applications設置(可看做默認值),單個隊列可通過參數 yarn.scheduler.capacity.<queue-path>.maximum-applications 單獨設置自己的值。如果不單獨設置,那麼對應隊列的maximum-applications會按照資源佔比計算。如某個隊列的資源佔比是15%,那麼它的maximum-applications就是10000 * 15 % = 1500。在實際使用中發現,如果隊列使用了絕對資源格式配置,則單獨指定的方式不會生效,只會根據隊列資源佔比來計算。這個參數對應 Yarn web頁面中隊列信息的__Max Applications__。

yarn.scheduler.capacity.maximum-am-resource-percent / yarn.scheduler.capacity.<queue-path>.maximum-am-resource-percent:集羣中用於運行應用程序ApplicationMaster的資源比例上限,該參數通常用於限制處於活動狀態的應用程序數目。該參數類型爲浮點型,默認是0.1,表示10%。所有隊列的ApplicationMaster資源比例上限可通過參數yarn.scheduler.capacity. maximum-am-resource-percent設置(可看做默認值),單個隊列可通過參數__yarn.scheduler.capacity.<queue-path>. maximum-am-resource-percent__ 單獨設置自己的值。如果不單獨設置,那麼就使用 yarn.scheduler.capacity.maximum-am-resource-percent 的值。這個參數對應 Yarn web頁面中隊列信息的__Configured Max Application Master Limit__。

隊列權限管理
yarn.scheduler.capacity.<queue-path>.state :隊列狀態可以爲STOPPED或者RUNNING,如果一個隊列處於STOPPED狀態,用戶不可以將應用程序提交到該隊列或者它的子隊列中,類似的,如果ROOT隊列處於STOPPED狀態,用戶不可以向集羣中提交應用程序,但正在運行的應用程序仍可以正常運行結束,以便隊列可以優雅地退出。這個參數對應 Yarn web頁面中隊列信息的 Queue State。
yarn.scheduler.capacity.root.<queue-path>.acl_submit_applications:限定哪些Linux用戶/用戶組可向給定隊列中提交應用程序。需要注意的是,該屬性具有繼承性,即如果一個用戶可以向某個隊列中提交應用程序,則它可以向它的所有子隊列中提交應用程序。配置該屬性時,用戶之間或組之間用“,”分割,用戶和用戶組之間用空格分割,比如“user1,user2 group1,group2”。
yarn.scheduler.capacity.root.<queue-path>.acl_administer_queue:爲隊列指定一個管理員,該管理員可控制該隊列的所有應用程序,比如殺死任意一個應用程序等。如果該屬性的ACL未指定則從其父隊列繼承。
基於用戶或組的隊列映射
  多租戶場景下,不同的用戶需要使用不同的隊列,通過隊列映射特性可以使的不同用戶提交的作業運作到指定的隊列中。

yarn.scheduler.capacity.queue-mappings:該配置可以將用戶或組映射到指定的隊列。用戶可以映射一個單獨的用戶或者一個用戶列表到隊列。語法爲:[u or g]:[name]:[queue_name][,next_mapping]*。這裏,u或者g表是映射是針對用戶還是組。u表示用戶,g表示組。name 表示用戶名或者組名。要指定提交應用程序的用戶,可以用%user表示。queue_name表示應用程序映射的隊列名稱。如果要指定隊列名稱與用戶名稱相同,可以用%user表示。如果要指定隊列名稱與用戶所屬的primary組名相同,可以用%primary_group表示。
yarn.scheduler.capacity.queue-mappings-override.enable:指定用戶指定的隊列是否可以被覆蓋。布爾值,默認爲false。
  示例:

<property>
   <name>yarn.scheduler.capacity.queue-mappings</name>
   <value>u:user1:queue1,g:group1:queue2,u:%user:%user,u:user2:%primary_group</value>
 </property>

  上述配置中,用戶user1映射到隊列queue1,組group1映射到隊列queue2,u:%user:%user,是將用戶映射到與用戶名同名的隊列中,user2映射到與其primary group同名的隊列中。映射是從左到右進行匹配的,第一個匹配的映射將會被使用。

應用程序的生存期(lifetime)
  從Apache hadoop2.9.0開始, Capacity Scheduler新增支持應用程序的生存期管理特性。

yarn.scheduler.capacity.<queue-path>.maximum-application-lifetime:隊列中應用程序的最大生存期(單位爲秒)。任何設置爲小於等於0的值,表示不啓用此功能。該配置是一個硬限制,當應用程序的運行時間超出該時間後將會被kill掉,用戶也可以在提交應用程序的context中指定該值,但是如果用戶設置的值超出此處設置的值,那麼用戶指定的值將會被覆蓋。 該特性只適用於葉子隊列。
yarn.scheduler.capacity.root.<queue-path>.default-application-lifetime:隊列中應用程序的默認生存期(單位爲秒)。任何設置爲小於等於0的值,表示不啓用此功能。當用戶提交作業時不指定生存期的時候會使用該默認值,該配置不能大於最大生存期。 該特性只適用於葉子隊列。
一個完整的配置示例
  下面的示例中同時使用了對值資源配置和百分比配置,從目前測試以及使用來看可能還存在不完善的地方。生產環境中目前還是建議統一使用百分比配置或是絕對值資源配置,不要混合配置使用,這樣方便對集羣資源進行管理。

<configuration>
  <property>
    <name>yarn.scheduler.capacity.maximum-applications</name>
    <value>50000</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.maximum-am-resource-percent</name>
    <value>0.1</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.queues</name>
    <value>default,queue1</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.default.capacity</name>
    <value>10</value>
  </property>
    <property>
    <name>yarn.scheduler.capacity.root.default.maximum-capacity</name>
    <value>20</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.default.user-limit-factor</name>
    <value>1</value>
  </property>
    <property>
    <name>yarn.scheduler.capacity.root.default.minimum-user-limit-percent</name>
    <value>100</value>
    <description></description>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.default.user-settings.userA.weight</name>
    <value>2</value>
    <description>userA的權重爲2,相比其他用戶可以獲得更多的資源</description>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.default.state</name>
    <value>RUNNING</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.default.acl_submit_applications</name>
    <value>*</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.default.acl_administer_queue</name>
    <value>hadoop</value>
  </property>
    <property>
    <name>yarn.scheduler.capacity.root.default.default-application-lifetime</name>
    <value>14400</value>
    <description>隊列的默認應用程序生存期,4小時</description>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.default.maximum-application-lifetime</name>
    <value>28800</value>
    <description>隊列的最大應用程序生存期,8小時</description>
  </property>
    <property>
    <name>yarn.scheduler.capacity.root.queue1.capacity</name>
    <value>[memory=160000,vcores=40]</value>
  </property>
    <property>
    <name>yarn.scheduler.capacity.root.queue1.maximum-capacity</name>
    <value>[memory=9000000,vcores=2000]</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.queue1.user-limit-factor</name>
    <value>5</value>
  </property>
    <property>
    <name>yarn.scheduler.capacity.root.queue1.minimum-user-limit-percent</name>
    <value>100</value>
    <description></description>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.queue1.state</name>
    <value>RUNNING</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.queue1.acl_submit_applications</name>
    <value>user1</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.queue1.acl_administer_queue</name>
    <value>hadoop</value>
  </property>
    <property>
    <name>yarn.scheduler.capacity.root.queue1.default-application-lifetime</name>
    <value>3600</value>
    <description>隊列的默認應用程序生存期,1小時</description>
  </property>
  <property>
    <name>yarn.scheduler.capacity.root.queue1.maximum-application-lifetime</name>
    <value>7200</value>
    <description>隊列的最大應用程序生存期,2小時</description>
  </property>
  <property>
    <name>yarn.scheduler.capacity.queue-mappings</name>
    <value>u:hadoop:default,u:user1:queue1,u:%user:%user</value>
  </property>
  <property>
    <name>yarn.scheduler.capacity.resource-calculator</name>
    <value>org.apache.hadoop.yarn.util.resource.DominantResourceCalculator</value>
    <description>使用的資源計算器是DominantResourceCalculator</description>
  </property>
  <property>
    <name>yarn.scheduler.capacity.queue-mappings-override.enable</name>
    <value>false</value>
  </property>
</configuration>

參考:https://hadoop.apache.org/docs/r3.1.1/hadoop-yarn/hadoop-yarn-site/CapacityScheduler.html#Queue_Properties

 

發佈了127 篇原創文章 · 獲贊 76 · 訪問量 45萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章