window系统没安装hadoop,IDEA中运行mkdir出现问题。
来源:3-11 Java API操作HDFS文件系统
少帅521
2018-07-08
3回答
-
少帅521
提问者
2018-07-08
java.net.ConnectException: Call From DESKTOP-D742S3O/169.254.117.217 to 192.168.2.80:8020 failed on connection exception: java.net.ConnectException: Connection refused: no further information; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
00 -
少帅521
提问者
2018-07-08
package com.imooc.hadoop.hdfs;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.net.URI;
/**
* Hadoop HDFS Java API 操作
*/
public class HDFSApp {
public static final String HDFS_PATH="hdfs://192.168.2.80:8020";
FileSystem fileSystem=null;
Configuration configuration=null;
/**
* 创建HDFS目录
*/
@Test
public void mkdir() throws Exception{
fileSystem.mkdirs(new Path("/hdfsapi/test"));
}
@Before
public void setUp() throws Exception {
System.out.println("HDFSApp.setUp");
configuration= new Configuration();
fileSystem = FileSystem.get(new URI(HDFS_PATH), configuration);
}
@After
public void tearDown() throws Exception{
configuration=null;
fileSystem=null;
System.out.println("HDFSApp.tearDown");
}
}022018-07-09 -
Michael_PK
2018-07-08
你这是这个机器没有配置hostname的映射关系,找不到hadoop000
042018-07-08
相似问题