java代码连接hadoop FileSystem 连接hdfs报错:Connection refused: no further information

java代码连接hadoop FileSystem 连接hdfs报错:Connection refused: no further information

确保应用正常启动、JPS该起的进程都要启动的情况下,用java接连hdfs做文件上传报如下错误:

java.net.ConnectException: Call From USER-20150505FN/192.168.1.115 to www.danpinshop.com: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(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at org.apache.hadoop.net.NetUtils.wrapWithMessage(NetUtils.java:783) 
    at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:730) 
    at org.apache.hadoop.ipc.Client.call(Client.java:1351) 
    at org.apache.hadoop.ipc.Client.call(Client.java:1300)

解决办法:
1.可能是权限问题
在hdfs-site.xml文件里添加

  
dfs.permissions  
false  

2.core-site.xml配置的fs.defaultFS,原来配置的hdfs://localhost:9000更改为机器ip

灵感来自于:

https://www.oschina.net/question/1399571_246927

你可能感兴趣的:(java)