[Hadoop] problem record: filesystemapi reads HDFS data: info IPC. Client: retrying connect to server: localhost/127.0.0.1

Source: Internet
Author: User

[Problem]

When this code is used to read data on HDFS

public static void main(String[] args) throws Exception { String uri = args[0]; Configuration conf = new Configuration(); FileSystem fs = FileSystem.get(URI.create(uri),conf); InputStream in = null; try{ in = fs.open(new Path(uri)); IOUtils.copyBytes(in, System.out, 4096,false); }finally{ IOUtils.closeStream(in); }}

Error:

Ubuntu @ snda:/data/soft/hadoop-0.20.203.0 $ bin/hadoop jar ~ /Desktop/filesystemcat. Jar HDFS: // localhost/user/Ubuntu/output/part-00000
11/08/04 09:12:10 info IPC. Client: retrying connect to server: localhost/127.0.0.1: 8020. Already tried 0 time (s ).
11/08/04 09:12:11 info IPC. Client: retrying connect to server: localhost/127.0.0.1: 8020. Already tried 1 time (s ).
11/08/04 09:12:12 info IPC. Client: retrying connect to server: localhost/127.0.0.1: 8020. Already tried 2 time (s ).
11/08/04 09:12:13 info IPC. Client: retrying connect to server: localhost/127.0.0.1: 8020. Already tried 3 time (s ).
11/08/04 09:12:14 info IPC. Client: retrying connect to server: localhost/127.0.0.1: 8020. Already tried 4 time (s ).
11/08/04 09:12:15 info IPC. Client: retrying connect to server: localhost/127.0.0.1: 8020. Already tried 5 time (s ).
11/08/04 09:12:16 info IPC. Client: retrying connect to server: localhost/127.0.0.1: 8020. Already tried 6 time (s ).
11/08/04 09:12:17 info IPC. Client: retrying connect to server: localhost/127.0.0.1: 8020. Already tried 7 time (s ).
11/08/04 09:12:18 info IPC. Client: retrying connect to server: localhost/127.0.0.1: 8020. Already tried 8 time (s ).
11/08/04 09:12:19 info IPC. Client: retrying connect to server: localhost/127.0.0.1: 8020. Already tried 9 time (s ).
Exception in thread "Main" Java. Lang. Reflect. invocationtargetexception
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. Eclipse. jdt. Internal. jarinjarloader. jarrsrcloader. Main (jarrsrcloader. Java: 58)
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: 156)
Caused by: 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: 1057)
At org. Apache. hadoop. IPC. Client. Call (client. Java: 1033)
At org. Apache. hadoop. IPC. RPC $ invoker. Invoke (rpc. Java: 224)
At $ proxy1.getprotocolversion (unknown source)
At org. Apache. hadoop. IPC. rpc. getproxy (rpc. Java: 364)
At org. Apache. hadoop. HDFS. dfsclient. createrpcnamenode (dfsclient. Java: 106)
At org. Apache. hadoop. HDFS. dfsclient. <init> (dfsclient. Java: 208)
At org. Apache. hadoop. HDFS. dfsclient. <init> (dfsclient. Java: 175)
At org. Apache. hadoop. HDFS. distributedfilesystem. initialize (distributedfilesystem. Java: 89)
At org. Apache. hadoop. fs. filesystem. createfilesystem (filesystem. Java: 1310)
At org. Apache. hadoop. fs. filesystem. Access $100 (filesystem. Java: 65)
At org. Apache. hadoop. fs. filesystem $ cache. Get (filesystem. Java: 1328)
At org. Apache. hadoop. fs. filesystem. Get (filesystem. Java: 226)
At filesystemcat. Main (filesystemcat. Java: 20)
... 10 more
Caused by: java.net. connectexception: Connection refused
At sun. NiO. Ch. socketchannelimpl. checkconnect (native method)
At sun. NiO. Ch. socketchannelimpl. finishconnect (socketchannelimpl. Java: 567)
At org.apache.hadoop.net. socketiowithtimeout. Connect (socketiowithtimeout. Java: 206)
At org.apache.hadoop.net. netutils. Connect (netutils. Java: 406)
At org. Apache. hadoop. IPC. Client $ connection. setupconnection (client. Java: 414)
At org. Apache. hadoop. IPC. Client $ connection. setupiostreams (client. Java: 527)
At org. Apache. hadoop. IPC. Client $ connection. Access $1800 (client. Java: 187)
At org. Apache. hadoop. IPC. Client. getconnection (client. Java: 1164)
At org. Apache. hadoop. IPC. Client. Call (client. Java: 1010)
... 22 more

[Solution]

Add port 9000 to uri. Do not use 127.0.0.1 for localhost.

$ Bin/hadoop jar ~ /Desktop/filesystemcat. Jar HDFS: // localhost: 9000/user/Ubuntu/output/part-00000

[Reference]

Http://sileryang.wordpress.com/2011/05/24/%E6%8F%90%E4%BA%A4%E4%B8%80%E4%B8%AAhadoop%E4%BD%9C%E4%B8%9A%E6%97%B6%E8%BF%94%E5%9B%9Eipc-client-retrying-connect-to-server/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.