可以通过Kerberos、Pseudo或Simple能够实现web页面的安全设置。
本文通过使用user.name的(Simple)方式实现web页面的安全设置:http://localhost:8088/cluster?user.name=babu.
此外我们还可以自定义一个插件实现自己的安全机制,参考AuthenticationHandler
By default Hadoop HTTP web-consoles (ResourceManager,
NameNode, NodeManagers and DataNodes) allow access without any form of authentication.
Hadoop HTTP web-consoles can be configured to require Kerberos
authentication using HTTP SPNEGO protocol (supported by browsers like Firefox and Internet Explorer).
In addition, Hadoop HTTP web-consoles support the equivalent of
Hadoop’s Pseudo/Simple authentication. If this option is enabled, the
user name must be specified in the first browser interaction using the
user.name query string parameter. e.g.
http://localhost:8088/cluster?user.name=babu.
If a custom authentication mechanism is required for the HTTP
web-consoles, it is possible to implement a plugin to support the
alternate authentication mechanism (refer to Hadoop hadoop-auth for
details on writing an AuthenticationHandler).
The following properties should be in the core-site.xml of all the nodes in the cluster.
<configuration>
......//此处省略已有配置
<property>
<name>hadoop.http.filter.initializersname>
<value>org.apache.hadoop.security.AuthenticationFilterInitializervalue>
property>
<property>
<name>hadoop.http.authentication.typename>
<value>simplevalue>
property>
<property>
<name>hadoop.http.authentication.token.validityname>
<value>3600value>
property>
<property>
<name>hadoop.http.authentication.signature.secret.filename>
<value>/data/app/hadoop/etc/hadoop/secret/hadoop-http-auth-signature-secretvalue>
property>
<property>
<name>hadoop.http.authentication.cookie.domainname>
<value>value>
property>
<property>
<name>hadoop.http.authentication.simple.anonymous.allowedname>
<value>falsevalue>
property>
configuration>
//在每个hadoop 节点都操作
mkdir -p /data/app/hadoop/etc/hadoop/secret
cd /data/app/hadoop/etc/hadoop/secret
echo \"hadoop\" > hadoop-http-auth-signature-secret
# 关闭hadoop 集群
cd /data/app/hadoop
./sbin/stop-dfs.sh
./sbin/stop-yarn.sh
# 启动hadoop 集群
cd /data/app/hadoop
./sbin/start-dfs.sh
./sbin/start-yarn.sh
http://namenode_ip:18137 出现错误
http://namenode_ip:18137?user.name=hadoop 访问正确
简单的说,hadoop的simple认证的密钥文件并没有起作用,输入任何认证(例如:http://namenode_ip:18137?user.name=xxxx)都可以进入hadoop界面。
详见其他博主博文:
Hadoop Web 控制台安全认证——使用用户名 + 密码登陆设置方法 (Hadoop HTTP web-控制台认证 )
但似乎tengine要和管理节点(namenode和resourcemanager)放到一个位置,方案有待完善。
此外我们还可以自定义一个插件实现自己的安全机制,参考AuthenticationHandler