此頁面說明如何針對使用偽驗證的 Hadoop 群集,快速設定使用偽驗證的 HttpFS。
~ $ tar xzf httpfs-3.3.6.tar.gz
預設情況下,HttpFS 會假設 Hadoop 設定檔 (core-site.xml & hdfs-site.xml
) 在 HttpFS 設定目錄中。
如果並非如此,請將 httpfs.hadoop.config.dir
屬性 (設定為 Hadoop 設定目錄的位置) 加入 httpfs-site.xml
檔案。
編輯 Hadoop core-site.xml
並定義將執行 HttpFS 伺服器的 Unix 使用者為 proxyuser。例如
<property> <name>hadoop.proxyuser.#HTTPFSUSER#.hosts</name> <value>httpfs-host.foo.com</value> </property> <property> <name>hadoop.proxyuser.#HTTPFSUSER#.groups</name> <value>*</value> </property>
重要:將 #HTTPFSUSER#
取代為將啟動 HttpFS 伺服器的 Unix 使用者。
您需要重新啟動 Hadoop,讓 proxyuser 設定生效。
若要啟動/停止 HttpFS,請使用 hdfs --daemon start|stop httpfs
。例如
hadoop-3.3.6 $ hdfs --daemon start httpfs
注意:指令碼 httpfs.sh
已不建議使用。它現在只是 hdfs httpfs
的包裝器。
$ curl -sS 'http://<HTTPFSHOSTNAME>:14000/webhdfs/v1?op=gethomedirectory&user.name=hdfs' {"Path":"\/user\/hdfs"}
HttpFS 將 HTTP 埠預先設定為 14000。
HttpFS 支援 HttpFS 的 etc/hadoop/httpfs-site.xml
設定檔中的下列 設定屬性。
在 etc/hadoop/httpfs-site.xml
中啟用 SSL
<property> <name>httpfs.ssl.enabled</name> <value>true</value> <description> Whether SSL is enabled. Default is false, i.e. disabled. </description> </property>
使用適當的值設定 etc/hadoop/ssl-server.xml
,例如
<property> <name>ssl.server.keystore.location</name> <value>${user.home}/.keystore</value> <description>Keystore to be used. Must be specified. </description> </property> <property> <name>ssl.server.keystore.password</name> <value></value> <description>Must be specified.</description> </property> <property> <name>ssl.server.keystore.keypassword</name> <value></value> <description>Must be specified.</description> </property>
SSL 密碼可由憑證提供者保護。請參閱 憑證提供者 API。
您需要為 HttpFS 伺服器建立 SSL 憑證。使用 Java keytool
指令,以 httpfs
Unix 使用者身分建立 SSL 憑證
$ keytool -genkey -alias jetty -keyalg RSA
系統會在互動式提示中詢問您一系列問題。它會建立金鑰庫檔案,檔案名稱為 .keystore,並位於 httpfs
使用者家目錄中。
您為「金鑰庫密碼」輸入的密碼必須與設定目錄中 ssl-server.xml
中設定的 ssl.server.keystore.password
屬性的值相符。
「您的名字和姓氏是什麼?」(即「CN」)的答案必須是 HttpFS 伺服器將執行的機器主機名稱。
啟動 HttpFS。它應該透過 HTTPS 運作。
使用 Hadoop FileSystem
API 或 Hadoop FS shell,使用 swebhdfs://
架構。如果使用自簽署憑證,請確保 JVM 會擷取包含 SSL 憑證公開金鑰的信任儲存區。如需有關用戶端設定的更多資訊,請參閱 SWebHDFS 的 SSL 設定。
注意:某些舊的 SSL 用戶端可能會使用 HttpFS 伺服器不支援的弱加密。建議升級 SSL 用戶端。
下列環境變數已不建議使用。請改為設定對應的設定屬性。
環境變數 | 設定屬性 | 組態檔 |
---|---|---|
HTTPFS_HTTP_HOSTNAME | httpfs.http.hostname | httpfs-site.xml |
HTTPFS_HTTP_PORT | httpfs.http.port | httpfs-site.xml |
HTTPFS_MAX_HTTP_HEADER_SIZE | hadoop.http.max.request.header.size 和 hadoop.http.max.response.header.size | httpfs-site.xml |
HTTPFS_MAX_THREADS | hadoop.http.max.threads | httpfs-site.xml |
HTTPFS_SSL_ENABLED | httpfs.ssl.enabled | httpfs-site.xml |
HTTPFS_SSL_KEYSTORE_FILE | ssl.server.keystore.location | ssl-server.xml |
HTTPFS_SSL_KEYSTORE_PASS | ssl.server.keystore.password | ssl-server.xml |
名稱 | 說明 |
---|---|
/conf | 顯示組態屬性 |
/jmx | Java JMX 管理介面 |
/logLevel | 取得或設定每個類別的記錄等級 |
/logs | 顯示記錄檔 |
/stacks | 顯示 JVM 堆疊 |
/static/index.html | 靜態首頁 |
若要控制對 servlet /conf
、/jmx
、/logLevel
、/logs
和 /stacks
的存取,請在 httpfs-site.xml
中設定下列屬性
<property> <name>hadoop.security.authorization</name> <value>true</value> <description>Is service-level authorization enabled?</description> </property> <property> <name>hadoop.security.instrumentation.requires.admin</name> <value>true</value> <description> Indicates if administrator ACLs are required to access instrumentation servlets (JMX, METRICS, CONF, STACKS). </description> </property> <property> <name>httpfs.http.administrators</name> <value></value> <description>ACL for the admins, this configuration is used to control who can access the default servlets for HttpFS server. The value should be a comma separated list of users and groups. The user list comes first and is separated by a space followed by the group list, e.g. "user1,user2 group1,group2". Both users and groups are optional, so "user1", " group1", "", "user1 group1", "user1,user2 group1,group2" are all valid (note the leading space in " group1"). '*' grants access to all users and groups, e.g. '*', '* ' and ' *' are all valid. </description> </property>