這份文件針對部署 HDFS
於多宿主網路中的叢集管理員。YARN
/MapReduce
的類似支援正在進行中,並將於可用時記錄。
在多宿主網路中,叢集節點連線至多個網路介面。這樣做的原因可能有多種。
安全性:安全性需求可能要求叢集內部流量限制在與叢集內外資料傳輸所使用的網路不同的網路中。
效能:叢集內部流量可能使用一個或多個高頻寬互連,例如光纖通道、Infiniband 或 10GbE。
故障轉移/備援:節點可能有多個網路介面卡連線至單一網路,以處理網路介面卡故障。
請注意,NIC 連結 (也稱為 NIC 團隊或連結聚合) 是一個相關但獨立的主題。以下設定通常不適用於 NIC 連結組態,它在呈現單一「邏輯網路」給應用程式時,會透明地處理多工和故障轉移。
預設情況下,HDFS
端點會指定為主機名稱或 IP 位址。在任何情況下,HDFS
守護程式都會繫結到單一 IP 位址,讓守護程式無法從其他網路存取。
解決方案是為伺服器端點設定獨立設定,以強制繫結萬用字元 IP 位址 INADDR_ANY
,即 0.0.0.0
。請勿在任何這些設定中提供埠號。
注意:在主控/從屬組態檔案中,優先使用主機名稱而非 IP 位址。
<property> <name>dfs.namenode.rpc-bind-host</name> <value>0.0.0.0</value> <description> The actual address the RPC server will bind to. If this optional address is set, it overrides only the hostname portion of dfs.namenode.rpc-address. It can also be specified per name node or name service for HA/Federation. This is useful for making the name node listen on all interfaces by setting it to 0.0.0.0. </description> </property> <property> <name>dfs.namenode.servicerpc-bind-host</name> <value>0.0.0.0</value> <description> The actual address the service RPC server will bind to. If this optional address is set, it overrides only the hostname portion of dfs.namenode.servicerpc-address. It can also be specified per name node or name service for HA/Federation. This is useful for making the name node listen on all interfaces by setting it to 0.0.0.0. </description> </property> <property> <name>dfs.namenode.http-bind-host</name> <value>0.0.0.0</value> <description> The actual address the HTTP server will bind to. If this optional address is set, it overrides only the hostname portion of dfs.namenode.http-address. It can also be specified per name node or name service for HA/Federation. This is useful for making the name node HTTP server listen on all interfaces by setting it to 0.0.0.0. </description> </property> <property> <name>dfs.namenode.https-bind-host</name> <value>0.0.0.0</value> <description> The actual address the HTTPS server will bind to. If this optional address is set, it overrides only the hostname portion of dfs.namenode.https-address. It can also be specified per name node or name service for HA/Federation. This is useful for making the name node HTTPS server listen on all interfaces by setting it to 0.0.0.0. </description> </property>
預設情況下,HDFS
用戶端會使用名稱節點提供的 IP 位址連線至資料節點。根據網路組態,用戶端可能無法存取此 IP 位址。解決方法是讓用戶端執行自己的資料節點主機名稱 DNS 解析。以下設定會啟用此行為。
<property> <name>dfs.client.use.datanode.hostname</name> <value>true</value> <description>Whether clients should use datanode hostnames when connecting to datanodes. </description> </property>
在罕見情況下,名稱節點解析的資料節點 IP 位址可能無法從其他資料節點存取。解決方法是強制資料節點執行自己的 DNS 解析,以進行資料節點間連線。以下設定會啟用此行為。
<property> <name>dfs.datanode.use.datanode.hostname</name> <value>true</value> <description>Whether datanodes should use datanode hostnames when connecting to other datanodes for data transfer. </description> </property>
在 安全模式下使用 Hadoop 組態多宿主主機可能需要其他組態。
Hadoop 服務的 Kerberos 主體使用模式 ServiceName/_HOST@REALM.TLD
指定,例如 nn/_HOST@REALM.TLD
。這允許在所有主機上使用相同的組態檔案。服務會用自己的主機名稱 (在執行階段查詢) 取代主體中的 _HOST
。
當節點組態為在 DNS 或 /etc/hosts
檔案中具有多個主機名稱時,服務可能會查詢與伺服器預期不同的主機名稱。例如,兩個服務之間的群集內流量可能會透過私人介面路由,但用戶端服務會查詢其公用主機名稱。由於主體中的主機名稱與流量到達的 IP 位址不符,因此 Kerberos 驗證會失敗。
下列設定(從 Apache Hadoop 2.8.0 開始提供)可控制服務查詢的主機名稱。
<property> <name>hadoop.security.dns.interface</name> <description> The name of the Network Interface from which the service should determine its host name for Kerberos login. e.g. eth2. In a multi-homed environment, the setting can be used to affect the _HOST subsitution in the service Kerberos principal. If this configuration value is not set, the service will use its default hostname as returned by InetAddress.getLocalHost().getCanonicalHostName(). Most clusters will not require this setting. </description> </property>
服務也可以設定為使用特定 DNS 伺服器進行主機名稱查詢(很少需要)。
<property> <name>hadoop.security.dns.nameserver</name> <description> The host name or IP address of the name server (DNS) which a service Node should use to determine its own host name for Kerberos Login. Requires hadoop.security.dns.interface. Most clusters will not require this setting. </description> </property>