在本地调用hadoop的api
第一次在本地运行Java代码,调用hadoop的hdfs的api接口,遇到下面的问题:
1、HADOOP_HOME and hadoop.home.dir are unset
解决办法:在本地安装配置hadoop,并且要配置hadoop的环境变量到path中;
2、java.io.FileNotFoundException: Could not locate Hadoop executable: D:\java\hadoop\hadoop-3.2.0\bin\winutils.exe
解决办法,由于本地是Windows操作系统,因而需要用到winutils.exe文件,下载一个,放到hadoop的binI目录,注意这个文件的版本要跟hadoop匹配;
3、java.net.ConnectException: Call From PC-20180901CTYX/192.168.247.1 to 192.168.64.101:9000 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:423)