Java – Connect to Cloudera VM from my desktop

Connect to Cloudera VM from my desktop… here is a solution to the problem.

Connect to Cloudera VM from my desktop

I downloaded the Cloudera VM on my Windows 7 laptop to try it out. I
I’m trying to connect to a Hadoop instance running in a VM
window 。 I made an ifconfig and got the IP address of the VM. I can
Connect from a running Firefox to the web interface running in the VM
On my Windows machine, so I know I can at least connect to it.

Next, I tried connecting to Hadoop from Java.

public class FileSystemWriter
{

static
        {
                URL.setURLStreamHandlerFactory( new FsUrlStreamHandlerFactory() );
        }

public static void main( String[] args ) throws Exception
        {
                String uri = "hdfs://192.168.171.128/user";
                Configuration conf = new Configuration();

System.out.println( "uri: " + uri );

FileSystem fs = FileSystem.get( URI.create( uri ), conf );
       }

} 

But I get the error.

uri: hdfs://192.168.171.128/user

Aug 9, 2011 8:29:26 AM org.apache.hadoop.ipc.Client$Connection
handleConnectionFailure
INFO: Retrying connect to server: /192.168.171.128:8020. Already tried
0 time(s).
Aug 9, 2011 8:29:28 AM org.apache.hadoop.ipc.Client$Connection
handleConnectionFailure
INFO: Retrying connect to server: /192.168.171.128:8020. Already tried
1 time(s).
Aug 9, 2011 8:29:30 AM org.apache.hadoop.ipc.Client$Connection
handleConnectionFailure
INFO: Retrying connect to server: /192.168.171.128:8020. Already tried
2 time(s).

Can anyone help me?

Solution

First, try connecting via HFTP.

        uri = "hftp://172.16.xxx.xxx:50070/";

System.out.println( "uri: " + uri );           
        Configuration conf = new Configuration();

FileSystem fs = FileSystem.get( URI.create( uri ), conf );
        fs.printStatistics();

If you see something (no exception), then you are connected.

If you don’t, then your problem is not HDFS, but your problem is that your IP is wrong, or hadoop is not working, or your port is blocked… And so on.

.

Related Problems and Solutions