Super new for HBase / Hadoop here. I already have a HBase test cluster for two node classes, and now I'm trying to connect to this cluster from a remote Java client. Here's where I'm stuck: the client successfully connects to the Zookeeper single-server quorum (runs on the same server as the main HBase), but the address passed to the Zookeeper client is localhost, and (obviously) the client does not work to connect to anything, because HBase does not work locally. Given that I cannot edit the hosts file on the client side for administrative reasons (and in any case, I am not inclined, since this seems like a terrible hack), is there a way to force Zookeeper to return the correct IP address for the HBase Main server?
Java Code:
public static final String MASTER_IP = "10.3.248.105"; public static final String ZOOKEEPER_PORT = "2181"; Configuration config = HBaseConfiguration.create(); config.set("hbase.zookeeper.quorum", MASTER_IP); config.set("hbase.zookeeper.property.clientPort", ZOOKEEPER_PORT); System.out.println("Running connecting test..."); try { HBaseAdmin.checkHBaseAvailable(config); System.out.println("HBase found!"); HTable table = new HTable(config, "testTable"); System.out.println("Table testTable obtained!"); } catch (MasterNotRunningException e) { System.out.println("HBase connection failed!"); e.printStackTrace(); } catch (ZooKeeperConnectionException e) { System.out.println("Zookeeper connection failed!"); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); }
Error Reset:
13/06/27 11:20:25 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=10.3.248.105:2181 sessionTimeout=180000 watcher=hconnection 13/06/27 11:20:25 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 5896@HQNJVCVM0004 13/06/27 11:20:29 INFO zookeeper.ClientCnxn: Opening socket connection to server 10.3.248.105/10.3.248.105:2181. Will not attempt to authenticate using SASL (unknown error) 13/06/27 11:20:29 INFO zookeeper.ClientCnxn: Socket connection established to 10.3.248.105/10.3.248.105:2181, initiating session 13/06/27 11:20:29 INFO zookeeper.ClientCnxn: Session establishment complete on server 10.3.248.105/10.3.248.105:2181, sessionid = 0x13f8638485c0003, negotiated timeout = 180000 13/06/27 11:20:30 INFO client.HConnectionManager$HConnectionImplementation: getMaster attempt 0 of 1 failed; no more retrying. java.net.UnknownHostException: unknown host: localhost.localdomain HBase connection failed! at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.<init>(HBaseClient.java:276) at org.apache.hadoop.hbase.ipc.HBaseClient.createConnection(HBaseClient.java:255) at org.apache.hadoop.hbase.ipc.HBaseClient.getConnection(HBaseClient.java:1111) at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:974) at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:86) at com.sun.proxy.$Proxy5.getProtocolVersion(Unknown Source) at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:138) at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:712) at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:126) at org.apache.hadoop.hbase.client.HBaseAdmin.checkHBaseAvailable(HBaseAdmin.java:1781) at hbaseimagestore.HBaseImageStore.main(HBaseImageStore.java:44) 13/06/27 11:20:30 INFO client.HConnectionManager$HConnectionImplementation: Closed zookeeper sessionid=0x13f8638485c0003 13/06/27 11:20:30 INFO zookeeper.ZooKeeper: Session: 0x13f8638485c0003 closed org.apache.hadoop.hbase.MasterNotRunningException: Retried 1 times at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:138) at org.apache.hadoop.hbase.client.HBaseAdmin.checkHBaseAvailable(HBaseAdmin.java:1781) at hbaseimagestore.HBaseImageStore.main(HBaseImageStore.java:44) 13/06/27 11:20:30 INFO zookeeper.ClientCnxn: EventThread shut down
Edit: also the / etc / hosts file on the master / zookeeper server:
10.3.248.105 master 10.3.248.106 slave 127.0.0.1 localhost
source share