0
안녕하세요. 모두 내가 hadoop에서 작업 중이고 그 중에서 2 노드 hadoop 클러스터를 구성합니다. hadoop 파일 시스템에서 java 코드를 사용하여 디렉토리를 만들어야하지만,이 코드를 실행할 때마다 예외가 발생합니다. 내 코드자바 코드에서 예외가 발생했을 때 hadoop 파일 시스템을 호출 할 때
Exception in thread "main" java.io.IOException: Call to master/192.168.0.128:54310 failed on local exception: java.io.EOFException
at org.apache.hadoop.ipc.Client.wrapException(Client.java:775)
at org.apache.hadoop.ipc.Client.call(Client.java:743)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220)
at sun.proxy.$Proxy0.getProtocolVersion(Unknown Source)
at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:359)
at org.apache.hadoop.hdfs.DFSClient.createRPCNamenode(DFSClient.java:106)
at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:207)
at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:170)
at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:82)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:1378)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:66)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1390)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:196)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:95)
at com.widevision.hadoop.Hadoopjava.main(Hadoopjava.java:26)
Caused by: java.io.EOFException
at java.io.DataInputStream.readInt(DataInputStream.java:392)
at org.apache.hadoop.ipc.Client$Connection.receiveResponse(Client.java:501)
at org.apache.hadoop.ipc.Client$Connection.run(Client.java:446)
에서
내 자바 코드
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
public class Hadoopjava {
public static void main(String ar[]) throws IOException
{
Configuration conf = new Configuration();
/*conf.addResource(new Path("core-site.xml"));
conf.addResource(new Path("hdfs-site.xml"));*/
conf.set("fs.default.name", "hdfs://master:54310");
String dirName = "dd";
//values of hosthdfs:port can be found in the core-site.xml in the fs.default.name
FileSystem fileSystem = FileSystem.get(conf);
Path path = new Path("/user/hduser/dd/gg");
fileSystem.mkdirs(path) ;
// System.out.println(data);
/*Path path = new Path("/user/hduser/dd");
if (fileSystem.exists(path)) {
System.out.println("Dir " + dirName + " already exists");
return;
}
// Create directories
fileSystem.mkdirs(path);*/
fileSystem.close();
}
}
예외 나는 자바 코드를위한 이클립스 IDE를 사용하고 있습니다.
내 코드가 잘못 되었나요 ???
클러스터에있는 모든 시스템에서 동일한 버전을 실행 중입니다. 내 질문에 답해 주셔서 대단히 감사드립니다. – Simmant
Hadoop의 어떤 버전을 사용하고 있습니까?이 코드가 원격 컴퓨터에 있습니까? – Tariq
선생님 나는 hadoop 1.2.0을 사용하고 있습니다.이 코드는 같은 기계에 있습니다. – Simmant