Reply
Highlighted
New Contributor
Posts: 7
Registered: ‎12-26-2014

Build a Java Client App to use Hbase / Connection problem

Hi

 

Currently I am using the Cloudera VM (IP: 192.168.0.206 in my network) to get into Hadoop.

 

Now I want to access Hbase via a Java App to write an read some db data.

I'm using IntelliJ on my mac.

 

I use some code found online

 

 

package com.example.helloworld;



import com.google.protobuf.ServiceException;
import org.apache.hadoop.hbase.HBaseConfiguration;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.hbase.client.HBaseAdmin;
import java.io.IOException;



public class HelloWorld {




public static void main(String[] args) throws ServiceException, IOException {


System.out.println("Hello: ");



Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "192.168.0.206");
config.set("hbase.master", "192.168.0.206:60000");
config.set("hbase.zookeeper.property.clientport", "2181");
HBaseAdmin.checkHBaseAvailable(config);

...

}

 

But I cant't connect ...

 

 

 

[main-SendThread(localhost:2181)] INFO org.apache.zookeeper.ClientCnxn - Opening socket connection to server localhost/192.168.0.206:2181. Will not attempt to authenticate using SASL (unknown error)
[main-SendThread(localhost:2181)] INFO org.apache.zookeeper.ClientCnxn - Socket connection established to localhost/192.168.0.206:2181, initiating session
[main-SendThread(localhost:2181)] INFO org.apache.zookeeper.ClientCnxn - Session establishment complete on server localhost/192.168.0.206:2181, sessionid = 0x14b08f4da690220, negotiated timeout = 60000
[main] INFO org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation - getMaster attempt 1 of 1 failed; no more retrying.
com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: quickstart.cloudera
	at org.apache.hadoop.hbase.ipc.RpcClient.callBlockingMethod(RpcClient.java:1678)
	at org.apache.hadoop.hbase.ipc.RpcClient$BlockingRpcChannelImplementation.callBlockingMethod(RpcClient.java:1719)
	at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$BlockingStub.isMasterRunning(MasterProtos.java:44411)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$MasterServiceStubMaker.isMasterRunning(HConnectionManager.java:1669)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$StubMaker.makeStubNoRetries(HConnectionManager.java:1578)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$StubMaker.makeStub(HConnectionManager.java:1604)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$MasterServiceStubMaker.makeStub(HConnectionManager.java:1658)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getKeepAliveMasterService(HConnectionManager.java:1865)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.isMasterRunning(HConnectionManager.java:881)
	at org.apache.hadoop.hbase.client.HBaseAdmin.checkHBaseAvailable(HBaseAdmin.java:2395)
	at com.example.helloworld.HelloWorld.main(HelloWorld.java:35)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.net.UnknownHostException: unknown host: quickstart.cloudera
	at org.apache.hadoop.hbase.ipc.RpcClient$Connection.<init>(RpcClient.java:385)
	at org.apache.hadoop.hbase.ipc.RpcClient.createConnection(RpcClient.java:351)
	at org.apache.hadoop.hbase.ipc.RpcClient.getConnection(RpcClient.java:1530)
	at org.apache.hadoop.hbase.ipc.RpcClient.call(RpcClient.java:1442)
	at org.apache.hadoop.hbase.ipc.RpcClient.callBlockingMethod(RpcClient.java:1661)
	... 15 more
[main] INFO org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation - Closing zookeeper sessionid=0x14b08f4da690220
[main] INFO org.apache.zookeeper.ZooKeeper - Session: 0x14b08f4da690220 closed
[main-EventThread] INFO org.apache.zookeeper.ClientCnxn - EventThread shut down
Exception in thread "main" org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: quickstart.cloudera
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$StubMaker.makeStub(HConnectionManager.java:1632)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$MasterServiceStubMaker.makeStub(HConnectionManager.java:1658)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getKeepAliveMasterService(HConnectionManager.java:1865)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.isMasterRunning(HConnectionManager.java:881)
	at org.apache.hadoop.hbase.client.HBaseAdmin.checkHBaseAvailable(HBaseAdmin.java:2395)
	at com.example.helloworld.HelloWorld.main(HelloWorld.java:35)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: quickstart.cloudera
	at org.apache.hadoop.hbase.ipc.RpcClient.callBlockingMethod(RpcClient.java:1678)
	at org.apache.hadoop.hbase.ipc.RpcClient$BlockingRpcChannelImplementation.callBlockingMethod(RpcClient.java:1719)
	at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$BlockingStub.isMasterRunning(MasterProtos.java:44411)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$MasterServiceStubMaker.isMasterRunning(HConnectionManager.java:1669)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$StubMaker.makeStubNoRetries(HConnectionManager.java:1578)
	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$StubMaker.makeStub(HConnectionManager.java:1604)
	... 10 more
Caused by: java.net.UnknownHostException: unknown host: quickstart.cloudera
	at org.apache.hadoop.hbase.ipc.RpcClient$Connection.<init>(RpcClient.java:385)
	at org.apache.hadoop.hbase.ipc.RpcClient.createConnection(RpcClient.java:351)
	at org.apache.hadoop.hbase.ipc.RpcClient.getConnection(RpcClient.java:1530)
	at org.apache.hadoop.hbase.ipc.RpcClient.call(RpcClient.java:1442)
	at org.apache.hadoop.hbase.ipc.RpcClient.callBlockingMethod(RpcClient.java:1661)
	... 15 more

 

 

What's wrong ?

 

 

THX

 

 

Michael

 

Posts: 1,903
Kudos: 435
Solutions: 307
Registered: ‎07-31-2013

Re: Build a Java Client App to use Hbase / Connection problem

Your code-running client (Mac) needs to be able to resolve the VM's hostname (quickstart.cloudera), as HMaster addresses are resolved via ZK data (not via hbase.master property) and this data is stored in hostname form.

Perhaps you can try placing a relevant entry on your Mac's /etc/hosts pointing to the IP with the same hostname.

When I last attempted something like that (to general success), I'd also wanted fixed IP assignments on the VM-side, so had followed also the DHCP instructions at http://blog.mclaughlinsoftware.com/2010/03/01/vmware-fusion-nat/, but this may be an optional thing.