您的位置:首页 > 编程语言 > Java开发

hadoop java api操作hdfs出现Retrying connect to server: localhost/127.0.0.1:8020

2014-03-25 09:53 1281 查看
写了一个简单的java代码查看hdfs 上文件内容,结果无法连接,出现Retrying connect to server: localhost/127.0.0.1:8020,具体如下:

4/03/24 18:45:56 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)

14/03/24 18:45:57 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 1 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)

14/03/24 18:45:58 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 2 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)

14/03/24 18:45:59 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 3 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)

14/03/24 18:46:00 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 4 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)

14/03/24 18:46:01 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 5 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)

14/03/24 18:46:02 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 6 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)

14/03/24 18:46:03 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 7 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)

14/03/24 18:46:04 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 8 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)

14/03/24 18:46:05 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 9 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)

Exception in thread "main" java.net.ConnectException: Call to localhost/127.0.0.1:8020 failed on connection exception: java.net.ConnectException: Connection refused

at org.apache.hadoop.ipc.Client.wrapException(Client.java:1142)

at org.apache.hadoop.ipc.Client.call(Client.java:1118)

at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:229)

at com.sun.proxy.$Proxy1.getProtocolVersion(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:85)

at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:62)

at com.sun.proxy.$Proxy1.getProtocolVersion(Unknown Source)

at org.apache.hadoop.ipc.RPC.checkVersion(RPC.java:422)

at org.apache.hadoop.hdfs.DFSClient.createNamenode(DFSClient.java:183)

at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:281)

at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:245)

at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:100)

at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:1446)

at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:67)

at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1464)

at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:263)

at org.apache.hadoop.fs.FsUrlConnection.connect(FsUrlConnection.java:45)

at org.apache.hadoop.fs.FsUrlConnection.getInputStream(FsUrlConnection.java:56)

at java.net.URL.openStream(URL.java:1010)

at com.inspur.lw.URLCat.main(URLCat.java:26)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.apache.hadoop.util.RunJar.main(RunJar.java:160)

Caused by: java.net.ConnectException: Connection refused

at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)

at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:599)

at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206)

at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:511)

at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:481)

at org.apache.hadoop.ipc.Client$Connection.setupConnection(Client.java:457)

at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:583)

at org.apache.hadoop.ipc.Client$Connection.access$2200(Client.java:205)

at org.apache.hadoop.ipc.Client.getConnection(Client.java:1249)

at org.apache.hadoop.ipc.Client.call(Client.java:1093)

... 27 more

查找相关资料,需要在localhost后面加上9000端口即可:

hadoop jar urlcat.jar com.inspur.lw.URLCat hdfs://localhost:9000/user/file1.copy.txt
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐