gpt4 book ai didi

java - org.apache.hadoop.ipc.RemoteException 错误

转载 作者:可可西里 更新时间:2023-11-01 16:53:51 28 4
gpt4 key购买 nike

我想将一些文件从 Windows 机器复制到在 SingleNode 上的 ubuntu 14.04.02 上运行的 hadoop。这是用于此目的的代码;

Configuration configuration = new Configuration();
configuration.addResource(new Path("/core-site.xml"));
configuration.addResource(new Path("/mapred-site.xml"));
FileSystem hdfs = FileSystem.get(configuration);

Path homeDirectory = hdfs.getHomeDirectory();
System.out.println("Home directory\t\t: " + homeDirectory);
Path workingDirectory = hdfs.getWorkingDirectory();
System.out.println("Working directory\t: " + workingDirectory);
Path dataFolderPath = new Path("/ali");
dataFolderPath = Path.mergePaths(workingDirectory, dataFolderPath);
System.out.println("Data Folder Path\t: " + dataFolderPath);

if(hdfs.exists(dataFolderPath)){
System.out.println("Data Folder Path exists.\nExisting path deleting...");
hdfs.delete(dataFolderPath, true);
}
System.out.println("Data Folder Path creating...");

Path localFilePath = new Path("D:\\text.txt");
Path hdfsFilePath = new Path(dataFolderPath + "/text.txt");

System.out.println("Copying \'" + localFilePath + "\' to \'" + hdfsFilePath + "\'...");

hdfs.copyFromLocalFile(localFilePath, hdfsFilePath);

System.out.println("All completed");

这是我得到的控制台日志;

Home directory      : hdfs://10.0.0.14:9000/user/ademir
Working directory : hdfs://10.0.0.14:9000/user/ademir
Data Folder Path : hdfs://10.0.0.14:9000/user/ademir/ali
Data Folder Path exists.
Existing path deleting...
Data Folder Path creating...
Copying 'D:/text.txt' to 'hdfs://10.0.0.14:9000/user/ademir/ali/text.txt'...
org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /user/ademir/ali/text.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.
at org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.chooseTarget4NewBlock(BlockManager.java:1549)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:3200)
at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.addBlock(NameNodeRpcServer.java:641)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.addBlock(ClientNamenodeProtocolServerSideTranslatorPB.java:482)
at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:619)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:962)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2039)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2035)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2033)

at org.apache.hadoop.ipc.Client.call(Client.java:1468)
at org.apache.hadoop.ipc.Client.call(Client.java:1399)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:232)
at com.sun.proxy.$Proxy14.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.addBlock(ClientNamenodeProtocolTranslatorPB.java:399)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:187)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102)
at com.sun.proxy.$Proxy15.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.locateFollowingBlock(DFSOutputStream.java:1532)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1349)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:588)

当我在运行 Hadoop 的机器上执行此操作时,它没有任何问题地完成,但是在本地网络中的 Windows 机器上,这是我得到的结果。

这个实现有什么问题,或者这个问题的根源是什么,我该如何解决。

感谢您的帮助。

注:Hadoop 版本为 2.6.0。我也是 Hadoop 的初学者。

最佳答案

此提供的链接提供了更多可能的答案 HDFS error: could only be replicated to 0 nodes, instead of 1

特别是这个答案:这是您的问题 - 客户端无法与 Datanode 通信。因为客户端收到的 Datanode 的 IP 是内部 IP 而不是公共(public) IP。看看这个...这是您的问题 - 客户端无法与 Datanode 通信。因为客户端收到的 Datanode 的 IP 是内部 IP 而不是公共(public) IP。看看这个

如您所见,您的数据节点也被标记为已排除

关于java - org.apache.hadoop.ipc.RemoteException 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31018638/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com