请稍等 ...
×

采纳答案成功!

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

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

插入代码

3回答

提问者 少帅521 2018-07-08 16:24:40

https://img1.sycdn.imooc.com//szimg/5b41ca2b00016d2707200065.jpg


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)


0 回复 有任何疑惑可以回复我~
提问者 少帅521 2018-07-08 16:23:25

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");
   }
}

0 回复 有任何疑惑可以回复我~
  • 你命令能访问吗?HDFS启动了吗
    回复 有任何疑惑可以回复我~ 2018-07-08 17:14:20
  • 提问者 少帅521 回复 Michael_PK #2
    搞定了。
    回复 有任何疑惑可以回复我~ 2018-07-09 08:55:57
Michael_PK 2018-07-08 14:55:27

你这是这个机器没有配置hostname的映射关系,找不到hadoop000

0 回复 有任何疑惑可以回复我~
  • 提问者 少帅521 #1
    该如何解决呀,搞了很久还是没法解决
    回复 有任何疑惑可以回复我~ 2018-07-08 15:15:45
  • Michael_PK 回复 提问者 少帅521 #2
    你本地idea机器配置hadoop000机器和IP的映射关系就行了
    回复 有任何疑惑可以回复我~ 2018-07-08 15:56:02
  • 或者你别用hadoop000访问,直接使用IP
    回复 有任何疑惑可以回复我~ 2018-07-08 15:56:24
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信