登錄組態

Hadoop 服務登錄建立在 Apache Zookeeper 之上。它透過 Hadoop Configuration 類別進行組態:用於建立服務的執行個體會控制用戶端行為。

本文件列出控制登錄用戶端的組態參數。

所有這些設定的預設值都定義在 core-default.xml 中。此檔案中的值可能與本文件中列出的值不符。如果是這樣,core-default.xml 中的值必須被視為規範。

變更組態值

應在 core-site.xml 中變更組態值。這將確保用戶端和非 YARN 應用程式會選取這些值,讓它們能夠從登錄中讀取並可能寫入登錄。

核心設定

設定 Zookeeper 法定人數:hadoop.registry.zk.quorum

這是一個必要的設定:它識別 zookeeper 主機清單和 ZK 服務正在監聽的埠。

  <property>
    <description>
      A comma separated list of hostname:port pairs defining the
      zookeeper quorum binding for the registry
    </description>
    <name>hadoop.registry.zk.quorum</name>
    <value>localhost:2181</value>
  </property>

它採用逗號分隔清單,例如 zk1:2181 ,zk2:2181, zk3:2181

設定 Zookeeper 登錄基本路徑:hadoop.registry.zk.root

此路徑設定登錄的基礎 zookeeper 節點

  <property>
    <description>
      The root zookeeper node for the registry
    </description>
    <name>hadoop.registry.zk.root</name>
    <value>/registry</value>
  </property>

/registry 的預設值通常就夠了。由於安全原因或 /registry 路徑正在使用中,可能需要不同的值。

根值會加到所有登錄路徑前面,以建立絕對路徑。例如

  • / 對應到 /registry
  • /services 對應到 /registry/services
  • /users/yarn 對應到 /registry/users/yarn

hadoop.registry.zk.root 的不同值會導致對應到絕對 zookeeper 路徑的不同。

安全性選項

當屬性 hadoop.registry.secure 設為 true 時,會啟用登錄安全性。設定後,會建立具有權限的節點,因此只有特定使用者和已設定叢集的「超級使用者」帳戶才能在他們的 home 路徑 ${hadoop.registry.zk.root}/users 下寫入。只有超級使用者帳戶才能操作根路徑,包括 ${hadoop.registry.zk.root}/services${hadoop.registry.zk.root}/users

登錄上的所有寫入操作(包括刪除項目和路徑)都必須經過驗證。未驗證的呼叫者仍然可以進行讀取操作。

安全登錄支援的主要設定為

  • 啟用安全模式:hadoop.registry.secure
  • 列出超級使用者 zookeeper ACL:hadoop.registry.system.acls
  • 列出主體的 Kerberos 領域:hadoop.registry.kerberos.realm
  • 識別 JAAS 設定中定義使用者的 JAAS 內容:hadoop.registry.jaas.context

啟用安全性

  <property>
    <description>
      Key to set if the registry is secure. Turning it on
      changes the permissions policy from "open access"
      to restrictions on kerberos with the option of
      a user adding one or more auth key pairs down their
      own tree.
    </description>
    <name>hadoop.registry.secure</name>
    <value>false</value>
  </property>

識別用戶端 JAAS 內容

登錄用戶端必須識別他們用來驗證登錄的 JAAS 內容。

  <property>
    <description>
      Key to define the JAAS context. Used in secure mode
    </description>
    <name>hadoop.registry.jaas.context</name>
    <value>Client</value>
  </property>

注意由於資源管理員只是登錄的另一個用戶端,因此它也必須定義這個內容。

識別系統帳戶 hadoop.registry.system.acls

這些帳戶會獲得登錄基底的完全存取權。資源管理員需要這個選項來建立根路徑。

寫入登錄的用戶端應用程式存取它建立的節點。

  1. 屬性 hadoop.registry.system.acls 會採用 zookeeper ACL 的逗號分隔清單,這些 ACL 會獲得對建立節點的完全存取權;權限為 READ | WRITE | CREATE | DELETE | ADMIN
  2. 任何 zookeeper ACL 架構都可以新增到這個清單中,例如 digest: 架構。
  3. SASL 架構 sasl: 用於識別由 sasl 識別且擁有完整存取權的呼叫者。這些是超級使用者帳戶。
  4. 它們可以透過 sasl:yarn@REALM.COM 等元素來識別。
  5. 為了協助 SASL 設定的可攜性,特別是預設值,任何沒有領域值(即任何以 @ 符號結尾的項目)的 sasl: 項目都會附加目前的領域。
  6. 此領域設定為目前使用者的領域。
  7. 它可以被 hadoop.registry.kerberos.realm 屬性覆寫。
  <property>
    <description>
      A comma separated list of Zookeeper ACL identifiers with
      system access to the registry in a secure cluster.
      These are given full access to all entries.
      If there is an "@" at the end of a SASL entry it
      instructs the registry client to append the default kerberos domain.
    </description>
    <name>hadoop.registry.system.acls</name>
    <value>sasl:yarn@, sasl:mapred@, sasl:mapred@, sasl:hdfs@</value>
  </property>

  <property>
    <description>
      The kerberos realm: used to set the realm of
      system principals which do not declare their realm,
      and any other accounts that need the value.
      If empty, the default realm of the running process
      is used.
      If neither are known and the realm is needed, then the registry
      service/client will fail.
    </description>
    <name>hadoop.registry.kerberos.realm</name>
    <value></value>
  </property>

範例:在領域為 EXAMPLE.COM 的 YARN 集群中,hadoop.registry.system.acls 項目 sasl:yarn@, sasl:admin@EXAMPLE.COM, sasl:system@REALM2 會將下列管理員帳戶新增至每個節點

  • sasl:yarn@EXAMPLE.COM
  • sasl:admin@EXAMPLE.COM
  • sasl:system@REALM2

建立登錄項目之用戶端應用程式的識別碼會自動包含在所有建立項目的權限中。例如,如果建立項目的帳戶是 hbase,則會建立另一個項目

  • sasl:hbase@EXAMPLE.COM

重要提示:設定系統 ACL 時,包含 YARN 資源管理員的識別碼至關重要

RM 需要能夠建立根目錄和使用者路徑,並在應用程式和容器清理期間刪除服務記錄。

Zookeeper 連線管理選項

一些低階選項管理 ZK 連線,更具體地說,是其故障處理。

Zookeeper 登錄客戶端使用 Apache Curator 連線到 Zookeeper,此程式庫會偵測逾時並嘗試重新連線到組成 zookeeper 法定人數的其中一個伺服器。只有在偵測到逾時後才會觸發重試。

  <property>
    <description>
      Zookeeper session timeout in milliseconds
    </description>
    <name>hadoop.registry.zk.session.timeout.ms</name>
    <value>60000</value>
  </property>

  <property>
    <description>
      Zookeeper connection timeout in milliseconds
    </description>
    <name>hadoop.registry.zk.connection.timeout.ms</name>
    <value>15000</value>
  </property>

  <property>
    <description>
      Zookeeper connection retry count before failing
    </description>
    <name>hadoop.registry.zk.retry.times</name>
    <value>5</value>
  </property>

  <property>
    <description>
    </description>
    <name>hadoop.registry.zk.retry.interval.ms</name>
    <value>1000</value>
  </property>

  <property>
    <description>
      Zookeeper retry limit in milliseconds, during
      exponential backoff.
      This places a limit even
      if the retry times and interval limit, combined
      with the backoff policy, result in a long retry
      period
    </description>
    <name>hadoop.registry.zk.retry.ceiling.ms</name>
    <value>60000</value>
  </property>

登錄客戶端中使用的重試策略是 BoundedExponentialBackoffRetry:在最終得出法定人數無法連線並失敗之前,此策略會在連線失敗時呈指數遞增地退避。

完整的設定選項

  <!-- YARN registry -->

  <property>
    <description>
      A comma separated list of hostname:port pairs defining the
      zookeeper quorum binding for the registry
    </description>
    <name>hadoop.registry.zk.quorum</name>
    <value>localhost:2181</value>
  </property>

  <property>
    <description>
      The root zookeeper node for the registry
    </description>
    <name>hadoop.registry.zk.root</name>
    <value>/registry</value>
  </property>

  <property>
    <description>
      Key to set if the registry is secure. Turning it on
      changes the permissions policy from "open access"
      to restrictions on kerberos with the option of
      a user adding one or more auth key pairs down their
      own tree.
    </description>
    <name>hadoop.registry.secure</name>
    <value>false</value>
  </property>

  <property>
    <description>
      A comma separated list of Zookeeper ACL identifiers with
      system access to the registry in a secure cluster.

      These are given full access to all entries.

      If there is an "@" at the end of a SASL entry it
      instructs the registry client to append the default kerberos domain.
    </description>
    <name>hadoop.registry.system.acls</name>
    <value>sasl:yarn@, sasl:mapred@, sasl:mapred@, sasl:hdfs@</value>
  </property>

  <property>
    <description>
      The kerberos realm: used to set the realm of
      system principals which do not declare their realm,
      and any other accounts that need the value.

      If empty, the default realm of the running process
      is used.

      If neither are known and the realm is needed, then the registry
      service/client will fail.
    </description>
    <name>hadoop.registry.kerberos.realm</name>
    <value></value>
  </property>

  <property>
    <description>
      Key to define the JAAS context. Used in secure
      mode
    </description>
    <name>hadoop.registry.jaas.context</name>
    <value>Client</value>
  </property>


  <property>
    <description>
      Zookeeper session timeout in milliseconds
    </description>
    <name>hadoop.registry.zk.session.timeout.ms</name>
    <value>60000</value>
  </property>

  <property>
    <description>
      Zookeeper session timeout in milliseconds
    </description>
    <name>hadoop.registry.zk.connection.timeout.ms</name>
    <value>15000</value>
  </property>

  <property>
    <description>
      Zookeeper connection retry count before failing
    </description>
    <name>hadoop.registry.zk.retry.times</name>
    <value>5</value>
  </property>

  <property>
    <description>
    </description>
    <name>hadoop.registry.zk.retry.interval.ms</name>
    <value>1000</value>
  </property>

  <property>
    <description>
      Zookeeper retry limit in milliseconds, during
      exponential backoff: {@value}

      This places a limit even
      if the retry times and interval limit, combined
      with the backoff policy, result in a long retry
      period
    </description>
    <name>hadoop.registry.zk.retry.ceiling.ms</name>
    <value>60000</value>
  </property>