Hadoop状态页面的Browse the filesystem链接无效的问题
来源:互联网 发布:淘宝巨型猪笼草 编辑:程序博客网 时间:2024/04/20 01:15
NameNode '192.168.1.164:9000'
Browse the filesystem
Namenode Logs
Cluster Summary
4 files and directories, 1 blocks = 5 total. Heap Size is 16.12 MB / 888.94 MB (1%)NameNode Storage:
Hadoop, 2010.
以上是我们安装完成,并且正常运行后的HDFS状态页面(访问地址:http://210.66.44.88:50070/dfshealth.jsp),其中的Browse the filesystem是查看文件系统的入口,但是有可能会出现无法访问的问题,我就遇到过,上网查了很久的解决办法都无果,后来我通过firebug拦截请求发现,Browse the filesystem这个链接的页面会跳转到另外一个页面,而这个页面的地址是http://192.168.1.164:50075/browseDirectory.jsp?namenodeInfoPort=50070&dir=%2F(
192.168.1.164是服务器的内网地址,在masters和slaves文件中配置的是局域网IP),但是需要通过外网才能访问(类似于http://210.66.44.88:50075/browseDirectory.jsp?namenodeInfoPort=50070&dir=%2F才行),这就是问题所在。
我们来看看nn_browsedfscontent.jsp的源代码:
- package org.apache.hadoop.hdfs.server.namenode;
- import java.io.IOException;
- import java.net.InetAddress;
- import java.net.InetSocketAddress;
- import java.net.URLEncoder;
- import java.util.Vector;
- import javax.servlet.ServletConfig;
- import javax.servlet.ServletContext;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import javax.servlet.jsp.JspFactory;
- import javax.servlet.jsp.JspWriter;
- import javax.servlet.jsp.PageContext;
- import javax.servlet.jsp.SkipPageException;
- import org.apache.hadoop.util.ServletUtil;
- import org.apache.jasper.runtime.HttpJspBase;
- import org.apache.jasper.runtime.JspSourceDependent;
- import org.apache.jasper.runtime.ResourceInjector;
- public final class nn_005fbrowsedfscontent_jsp extends HttpJspBase
- implements JspSourceDependent
- {
- private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
- private static Vector _jspx_dependants;
- private ResourceInjector _jspx_resourceInjector;
- //此处是将请求随机转发到一个DataNode节点上
- public void redirectToRandomDataNode(NameNode nn, HttpServletResponse resp)
- throws IOException
- {
- String nodeToRedirect;
- int redirectPort;
- FSNamesystem fsn = nn.getNamesystem();
- String datanode = fsn.randomDataNode();
- if (datanode != null) {
- redirectPort = Integer.parseInt(datanode.substring(datanode.indexOf(58) + 1));
- nodeToRedirect = datanode.substring(0, datanode.indexOf(58));
- }
- else {
- nodeToRedirect = nn.getHttpAddress().getHostName();
- redirectPort = nn.getHttpAddress().getPort();
- }
- // 此处是得到服务器的名称(hostname)
- String fqdn = InetAddress.getByName(nodeToRedirect).getCanonicalHostName();
- String redirectLocation = "http://" + fqdn + ":" + redirectPort + "/browseDirectory.jsp?namenodeInfoPort=" + nn.getHttpAddress().getPort() + "&dir=" + URLEncoder.encode("/", "UTF-8");
- resp.sendRedirect(redirectLocation);
- }
- public Object getDependants()
- {
- return _jspx_dependants;
- }
- public void _jspService(HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException
- {
- PageContext pageContext = null;
- HttpSession session = null;
- ServletContext application = null;
- ServletConfig config = null;
- JspWriter out = null;
- Object page = this;
- JspWriter _jspx_out = null;
- PageContext _jspx_page_context = null;
- try
- {
- response.setContentType("text/html; charset=UTF-8");
- pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
- _jspx_page_context = pageContext;
- application = pageContext.getServletContext();
- config = pageContext.getServletConfig();
- session = pageContext.getSession();
- out = pageContext.getOut();
- _jspx_out = out;
- this._jspx_resourceInjector = ((ResourceInjector)application.getAttribute("com.sun.appserv.jsp.resource.injector"));
- out.write(10);
- out.write("\n\n<html>\n\n<title></title>\n\n<body>\n");
- NameNode nn = (NameNode)application.getAttribute("name.node");
- redirectToRandomDataNode(nn, response);
- out.write("\n<hr>\n\n<h2>Local logs</h2>\n<a href=\"/logs/\">Log</a> directory\n\n");
- out.println(ServletUtil.htmlFooter());
- out.write(10);
- } catch (Throwable t) {
- if (!(t instanceof SkipPageException)) {
- out = _jspx_out;
- if ((out != null) && (out.getBufferSize() != 0))
- out.clearBuffer();
- if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
- }
- } finally {
- _jspxFactory.releasePageContext(_jspx_page_context);
- }
- }
- }
- package org.apache.hadoop.hdfs.server.namenode;
- import java.io.IOException;
- import java.net.InetAddress;
- import java.net.InetSocketAddress;
- import java.net.URLEncoder;
- import java.util.Vector;
- import javax.servlet.ServletConfig;
- import javax.servlet.ServletContext;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import javax.servlet.jsp.JspFactory;
- import javax.servlet.jsp.JspWriter;
- import javax.servlet.jsp.PageContext;
- import javax.servlet.jsp.SkipPageException;
- import org.apache.hadoop.util.ServletUtil;
- import org.apache.jasper.runtime.HttpJspBase;
- import org.apache.jasper.runtime.JspSourceDependent;
- import org.apache.jasper.runtime.ResourceInjector;
- public final class nn_005fbrowsedfscontent_jsp extends HttpJspBase
- implements JspSourceDependent
- {
- private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
- private static Vector _jspx_dependants;
- private ResourceInjector _jspx_resourceInjector;
- //此处是将请求随机转发到一个DataNode节点上
- public void redirectToRandomDataNode(NameNode nn, HttpServletResponse resp)
- throws IOException
- {
- String nodeToRedirect;
- int redirectPort;
- FSNamesystem fsn = nn.getNamesystem();
- String datanode = fsn.randomDataNode();
- if (datanode != null) {
- redirectPort = Integer.parseInt(datanode.substring(datanode.indexOf(58) + 1));
- nodeToRedirect = datanode.substring(0, datanode.indexOf(58));
- }
- else {
- nodeToRedirect = nn.getHttpAddress().getHostName();
- redirectPort = nn.getHttpAddress().getPort();
- }
- // 此处是得到服务器的名称(hostname)
- String fqdn = InetAddress.getByName(nodeToRedirect).getCanonicalHostName();
- String redirectLocation = "http://" + fqdn + ":" + redirectPort + "/browseDirectory.jsp?namenodeInfoPort=" + nn.getHttpAddress().getPort() + "&dir=" + URLEncoder.encode("/", "UTF-8");
- resp.sendRedirect(redirectLocation);
- }
- public Object getDependants()
- {
- return _jspx_dependants;
- }
- public void _jspService(HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException
- {
- PageContext pageContext = null;
- HttpSession session = null;
- ServletContext application = null;
- ServletConfig config = null;
- JspWriter out = null;
- Object page = this;
- JspWriter _jspx_out = null;
- PageContext _jspx_page_context = null;
- try
- {
- response.setContentType("text/html; charset=UTF-8");
- pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
- _jspx_page_context = pageContext;
- application = pageContext.getServletContext();
- config = pageContext.getServletConfig();
- session = pageContext.getSession();
- out = pageContext.getOut();
- _jspx_out = out;
- this._jspx_resourceInjector = ((ResourceInjector)application.getAttribute("com.sun.appserv.jsp.resource.injector"));
- out.write(10);
- out.write("\n\n<html>\n\n<title></title>\n\n<body>\n");
- NameNode nn = (NameNode)application.getAttribute("name.node");
- redirectToRandomDataNode(nn, response);
- out.write("\n<hr>\n\n<h2>Local logs</h2>\n<a href=\"/logs/\">Log</a> directory\n\n");
- out.println(ServletUtil.htmlFooter());
- out.write(10);
- } catch (Throwable t) {
- if (!(t instanceof SkipPageException)) {
- out = _jspx_out;
- if ((out != null) && (out.getBufferSize() != 0))
- out.clearBuffer();
- if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
- }
- } finally {
- _jspxFactory.releasePageContext(_jspx_page_context);
- }
- }
- }
从代码可以看出,当我们点击Browse the filesystem时后台会将请求随机转发到一台DataNode节点,使用的是slaves文件中配置的服务器列表所反解的域名或主机名,而通过局域网IP未能反解出域名和主机名,所以用的是IP,这样就出问题了,解决办法有两个:视redirectToRandomDataNode方法内生成的URL而定,如果反转域名是主机名的话,你只需要修改本地HOSTS映射就可以了(推荐使用Windows Hosts Editor,软件地址:http://yymmiinngg.iteye.com/blog/360779);如果反转出的域名是主机局域网IP的话,那就需要配置slaves和masters使用域名或外网IP
- Hadoop状态页面的Browse the filesystem链接无效的问题
- Hadoop状态页面的Browse the filesystem链接无效的问题
- Hadoop状态页面的Browse the filesystem链接无效的问题
- (csdn内转载)Hadoop状态页面的Browse the filesystem链接无效的问题
- Hadoop状态页面的Browse the filesystem链接无效的问题
- Hadoop状态页面的Browse the filesystem链接无效的问题
- Hadoop-2.2.0集群管理页面Browse the filesystem无效的问题
- hadoop常见问题Browse the filesystem链接打不开
- Hadoop遇到Browse the filesystem链接打不开
- hadoop常见问题——Browse the filesystem链接打不开
- Browse the filesystem链接打不开
- Browse the filesystem链接打不开
- 查看hadoop管理页面,修改本地hosts,Browse the filesystem
- 关于Browse the filesystem打不开问题
- 关于hadoop 安装好之后,web页面不能访问 “Browse the filesystem”
- 启动hdfs文件系统后,Browse the filesystem链接打不开
- Hadoop Filesystem 多次close的问题
- 2、Browse the filesystem连接打不开
- 详细解析Java中抽象类和接口的区别
- Hadoop学习——HDFS数据备份与放置策略
- Arabic Numberal
- servlet 的生命周期
- d3 is not defined
- Hadoop状态页面的Browse the filesystem链接无效的问题
- HyperV网络设置问题
- XMPP_Android上测试收发即时文本消息
- 开箱即用!Android四款系统架构工具
- Intel Galileo - Building Linux Image
- 文件保存和读取的问题
- repeater控件介绍、 repeater嵌套的代码实现
- Namenode做block Recovery过程详细剖析
- 十二 Django 1.5.4 外键操作