请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

JAVA API 操作HDFS遇到问题

  1. 我的虚拟机放在阿里云上, create方法失败,mkdirs和cat却成功

  2. 使用shell, -put 可以成功写入文件

  3. 我在本机的VMWare上部署了一套,按照一样的方式,create方法可以成功

  4. 阿里云上我开了8020,50070端口,后来乱试又开了8021, 50010端口

我截取异常栈上的一些我认为重要的错误信息:

17/09/18 10:19:20 INFO hdfs.DFSClient: Exception in createBlockOutputStream

java.net.ConnectException: Connection timed out: no further information

at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)

......

17/09/18 10:19:20 WARN hdfs.DFSClient: Abandoning BP-2124473397-172.17.27.58-1505697429586:blk_1073741829_1005

17/09/18 10:19:20 WARN hdfs.DFSClient: Excluding datanode DatanodeInfoWithStorage[172.17.27.58:50010,DS-1b16be95-7c4d-4b75-a4f5-76526271e147,DISK]

17/09/18 10:19:20 WARN hdfs.DFSClient: DataStreamer Exception

org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /hdfsapi/test/a.txt could only be replicated to 0 nodes instead of minReplication (=1).  There are 1 datanode(s) running and 1 node(s) are excluded in this operation.

......


正在回答 回答被采纳积分+3

1回答

Michael_PK 2017-09-18 11:02:18

你确定下datanode活不

0 回复 有任何疑惑可以回复我~
  • 提问者 apodemakeles #1
    jps显示存在datanode, 浏览器里dashboard显示"in service", 直接在虚拟机上操作-put可以成功,应该可以确定没问题
    我windows本机和hadoop微集群应该只通过8020交互吧?所以就特别不明白什么shell可以API就不行,需要对Configuration类进行修改嘛?
    回复 有任何疑惑可以回复我~ 2017-09-18 11:09:00
  • Michael_PK 回复 提问者 apodemakeles #2
    嗯那说明环境OK的,只需要代码中设置hdfs路径即可,阿里云的我没玩过,不太确定是不是阿里云有限制问题
    回复 有任何疑惑可以回复我~ 2017-09-18 11:30:23
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信