用于在hdfs中列出目录的主机和端口

 你走以后_心若逝世灰决_677 发布于 2022-12-09 19:26

首先,我使用HortonWorks Sandbox作为Hadoop dist,根本没有自定义配置.

一旦连接到沙箱上,我就能列出一个HDFS目录的文件:

[root@sandbox ~]# hadoop fs -ls hdfs:///user/guest

但如果我尝试指定主机和端口,我只会得到错误:

[root@sandbox ~]# hadoop fs -ls hdfs://localhost:8020/user/guest ls: Call From sandbox.hortonworks.com/10.0.2.15 to localhost:8020 failed on connection exception: java.net.ConnectException: Connexion refusée; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused

[root@sandbox ~]# hadoop fs -ls hdfs://localhost:9000/user/guest ls: Call From sandbox.hortonworks.com/10.0.2.15 to localhost:9000 failed on connection exception: java.net.ConnectException: Connexion refusée; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused

一旦我知道要使用的正确主机和端口,我就可以在我的Java调用中使用它们:

Path pt = new Path("hdfs://host:port/user/guest/test-text-file.txt");

1 个回答
  • 检查的财产的价值fs.defaultFScore-site.xml这个包含其中的NameNode守护进程应该绑定到时候开始的了的IP地址/主机名和端口.

    我看到你正在使用hortonworks沙箱,这里是属性core-site.xml和它的位置/etc/hadoop/conf/core-site.xml

    <property>
      <name>fs.defaultFS</name>
      <value>hdfs://sandbox.hortonworks.com:8020</value>
    </property>
    

    所以,你可以尝试这样的事情:

    hadoop fs -ls hdfs://sandbox.hortonworks.com:8020/user/guest 
    

    或者您也可以在我的虚拟机上替换sandbox.hortonworks.com其各自条目中的IP地址,/etc/hosts如下所示:

    127.0.0.1       localhost.localdomain localhost
    192.168.1.3 sandbox.hortonworks.com sandbox
    

    所以,我也可以试试这个:

    hadoop fs -ls hdfs://192.168.1.3:8020/user/guest
    

    2022-12-11 02:04 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有