Hadoop Browse the filesystem 无效处理

简介: 当我们安装好并正常运行hdfs后输入http://xxxxxxxxx:50070会进入下图所示的页面。 其中Browse the filesystem 是查看文件系统的入口。 但是在发现这个链接一直无效。

当我们安装好并正常运行hdfs后输入http://xxxxxxxxx:50070会进入下图所示的页面。 其中Browse the filesystem 是查看文件系统的入口。

但是在发现这个链接一直无效。通过Chrome的开发工具可以看这个链接访问地址是:nn_browsedfscontent.jsp

下面是nn_browsedfscontent.jsp的代码

 1 <%@ page
 2   contentType="text/html; charset=UTF-8"
 3   import="java.io.*"
 4   import="java.security.PrivilegedExceptionAction"
 5   import="java.util.*"
 6   import="javax.servlet.*"
 7   import="javax.servlet.http.*"
 8   import="org.apache.hadoop.conf.Configuration"
 9   import="org.apache.hadoop.hdfs.*"
10   import="org.apache.hadoop.hdfs.server.namenode.*"
11   import="org.apache.hadoop.hdfs.server.datanode.*"
12   import="org.apache.hadoop.hdfs.protocol.*"
13   import="org.apache.hadoop.hdfs.security.token.delegation.*"
14   import="org.apache.hadoop.io.Text"
15   import="org.apache.hadoop.security.UserGroupInformation"
16   import="org.apache.hadoop.security.token.Token"
17   import="org.apache.hadoop.util.*"
18   import="java.text.DateFormat"
19   import="java.net.InetAddress"
20   import="java.net.URLEncoder"
21 %>
22 <%!
23   static String getDelegationToken(final NameNode nn,
24                                    HttpServletRequest request, Configuration conf) 
25                                    throws IOException, InterruptedException {
26     final UserGroupInformation ugi = JspHelper.getUGI(request, conf);
27     Token<DelegationTokenIdentifier> token =
28       ugi.doAs(
29               new PrivilegedExceptionAction<Token<DelegationTokenIdentifier>>()
30           {
31             public Token<DelegationTokenIdentifier> run() throws IOException {
32               return nn.getDelegationToken(new Text(ugi.getUserName()));
33             }
34           });
35     return token.encodeToUrlString();
36   }
37 
38   public void redirectToRandomDataNode(
39                             NameNode nn, 
40                             HttpServletRequest request,
41                             HttpServletResponse resp,
42                             Configuration conf
43                            ) throws IOException, InterruptedException {
44     String tokenString = null;
45     if (UserGroupInformation.isSecurityEnabled()) {
46       tokenString = getDelegationToken(nn, request, conf);
47     }
48     FSNamesystem fsn = nn.getNamesystem();
49     String datanode = fsn.randomDataNode();
50     String redirectLocation;
51     String nodeToRedirect;
52     int redirectPort;
53     if (datanode != null) {
54       redirectPort = Integer.parseInt(datanode.substring(datanode.indexOf(':')
55                      + 1));
56       nodeToRedirect = datanode.substring(0, datanode.indexOf(':'));
57     }
58     else {
59       nodeToRedirect = nn.getHttpAddress().getHostName();
60       redirectPort = nn.getHttpAddress().getPort();
61     }
62     String fqdn = InetAddress.getByName(nodeToRedirect).getCanonicalHostName();
63     redirectLocation = "http://" + fqdn + ":" + redirectPort + 
64                        "/browseDirectory.jsp?namenodeInfoPort=" + 
65                        nn.getHttpAddress().getPort() +
66                        "&dir=/" + 
67                        (tokenString == null ? "" :
68                         JspHelper.getDelegationTokenUrlParam(tokenString));
69     resp.sendRedirect(redirectLocation);
70   }
71 %>
72 
73 <html>
74 
75 <title></title>
76 
77 <body>
78 <% 
79   NameNode nn = (NameNode)application.getAttribute("name.node");
80   Configuration conf = (Configuration) application.getAttribute(JspHelper.CURRENT_CONF);
81   redirectToRandomDataNode(nn, request, response, conf); 
82 %>
83 <hr>
84 
85 <h2>Local logs</h2>
86 <a href="/logs/">Log</a> directory
87 
88 <%
89 out.println(ServletUtil.htmlFooter());
90 %>

 

从代码中可以看出实际是跳转到一台datanode的browseDirectory.jsp,如:

http://xxxxxxx:50075/browseDirectory.jsp?namenodeInfoPort=50070&dir=/

而xxxxxxx是集群中一台datanode的主机名。

 

那么就可以从以下两个点出发去看为什么无效:

1.50075端口是否正常

2.使用的机器是否能通过主机面访问datanode

检查之后发现自己这两个都没有配置......

最后通过在hdfs-site.xml中添加如下配置

<property>
<name>dfs.datanode.http.address</name>
<value>10.0.0.234:50075</value>
</property>

在hosts中添加datanode的主机命和ip修复了这个问题

 

 

记录、共勉。

 

 

如果本文对您有帮助,点一下右下角的“推荐”
目录
相关文章
|
3月前
|
存储 分布式计算 Hadoop
Hadoop Distributed File System (HDFS): 概念、功能点及实战
【6月更文挑战第12天】Hadoop Distributed File System (HDFS) 是 Hadoop 生态系统中的核心组件之一。它设计用于在大规模集群环境中存储和管理海量数据,提供高吞吐量的数据访问和容错能力。
507 4
|
4月前
|
存储 分布式计算 资源调度
|
分布式计算 Hadoop Java
Hadoop获取 FileSystem 实例
Hadoop获取 FileSystem 实例
|
存储 机器学习/深度学习 SQL
Hadoop基础-03-HDFS(Hadoop Distributed File System)基本概念
Hadoop基础-03-HDFS(Hadoop Distributed File System)基本概念 14
157 0
Hadoop基础-03-HDFS(Hadoop Distributed File System)基本概念
|
机器学习/深度学习 分布式计算 Java
Hadoop状态页面的Browse the filesystem链接无效的问题
NameNode '192.168.1.164:9000' Started: Tue Jul 06 14:37:10 CST 2010 Version: 0.
828 0
|
1月前
|
存储 分布式计算 Hadoop
|
20天前
|
图形学 数据可视化 开发者
超实用Unity Shader Graph教程:从零开始打造令人惊叹的游戏视觉特效,让你的作品瞬间高大上,附带示例代码与详细步骤解析!
【8月更文挑战第31天】Unity Shader Graph 是 Unity 引擎中的强大工具,通过可视化编程帮助开发者轻松创建复杂且炫酷的视觉效果。本文将指导你使用 Shader Graph 实现三种效果:彩虹色渐变着色器、动态光效和水波纹效果。首先确保安装最新版 Unity 并启用 Shader Graph。创建新材质和着色器图谱后,利用节点库中的预定义节点,在编辑区连接节点定义着色器行为。
71 0
|
26天前
|
分布式计算 资源调度 Hadoop
Hadoop入门基础(五):Hadoop 常用 Shell 命令一网打尽,提升你的大数据技能!
Hadoop入门基础(五):Hadoop 常用 Shell 命令一网打尽,提升你的大数据技能!
|
27天前
|
存储 SQL 分布式计算
Hadoop生态系统概述:构建大数据处理与分析的基石
【8月更文挑战第25天】Hadoop生态系统为大数据处理和分析提供了强大的基础设施和工具集。通过不断扩展和优化其组件和功能,Hadoop将继续在大数据时代发挥重要作用。

相关实验场景

更多