標籤:http 檔案 type name user os
Hadoop叢集配置完成,web監控介面的50070和50030連接埠不需使用者驗證即可訪問,對生產環境是不容許的,需要加上安全機制。
實驗環境:OS:Centos 6.5 x64, Soft:Hadoop 1.2.1
1、修改core-site.xml,增加如下內容,配置完成後拷貝到其他節點上。
<property>
<name>hadoop.http.filter.initializers</name>
<value>org.apache.hadoop.security.AuthenticationFilterInitializer</value>
</property>
<property>
<name>hadoop.http.authentication.type</name>
<value>simple</value>
</property>
<property>
<name>hadoop.http.authentication.token.validity</name>
<value>3600</value>
</property>
<property>
<name>hadoop.http.authentication.signature.secret.file</name>
<value>/home/huser/hadoop/hadoop-http-auth-signature-secret</value>
</property>
<property>
<name>hadoop.http.authentication.cookie.domain</name>
<value></value>
</property>
<property>
<name>hadoop.http.authentication.simple.anonymous.allowed</name>
<value>false</value>
</property>
2、在上述配置的目錄/home/huser/hadoop/下組建檔案hadoop-http-auth-signature-secret,拷貝到其他節點上。
$ echo "hadoop" > hadoop-http-auth-signature-secret
3、重啟叢集環境,訪問web頁面會報錯。
HTTP ERROR 401
Problem accessing /dfshealth.jsp. Reason:
org.apache.hadoop.security.authentication.client.AuthenticationException: Anonymous requests are disallowed
在訪問地址欄後面加上?user.name=xxx,其中“xxx“為hadoop-http-auth-signature-secret檔案寫入的內容,頁面可以正常訪問,由此可以做到安全機制。