文章目录
- 一. Introduction
- 二. Configuration
- 1. 在每一个hadoop节点配置core-site.xml
- 2.创建密钥
- 3. 重启 hadoop 集群
- 4. 访问示例
- 三、不是银弹
- 解决方案一
- 解决方案二-自定义插件ing
官网:Authentication for Hadoop HTTP web-consoles
一. Introduction
可以通过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 acustomauthentication mechanism is required for the HTTP
web-consoles, it is possible to implement aplugin to support the
alternate authentication mechanism(refer to Hadoop hadoop-auth for
details on writing an AuthenticationHandler).
二. Configuration
1. 在每一个hadoop节点配置core-site.xml
The following properties should be in the core-site.xml of all the nodes in the cluster.
<configuration>......//此处省略已有配置<!-- Authentication for Hadoop HTTP web-consoles --><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>/data/app/hadoop/etc/hadoop/secret/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></configuration>2.创建密钥
//在每个hadoop 节点都操作mkdir-p/data/app/hadoop/etc/hadoop/secret cd/data/app/hadoop/etc/hadoop/secret echo \"hadoop\">hadoop-http-auth-signature-secret3. 重启 hadoop 集群
# 关闭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.sh4. 访问示例
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)放到一个位置,方案有待完善。
解决方案二-自定义插件ing
此外我们还可以自定义一个插件实现自己的安全机制,参考AuthenticationHandler