Connect to Hbase on Cloudera VM using the Java Client API :

I am using the following JAVA code to establish the connection :

 Configuration hConfig = null;
        hConfig = HBaseConfiguration.create();
        hConfig.set("hbase.zookeeper.quorum", **zookepperQuorum**);
        hConfig.set("hbase.zookeeper.property.clientPort", **zookepperClientPort**);
 HBaseAdmin.checkHBaseAvailable(hConfig);

This is my ipConfig from CmdLine on windows :

Ethernet adapter Local Area Connection:

Link-local IPv6 Address . . . . . : fe80::a03b:5ec2:cc82:f952%12

IPv4 Address. . . . . . . . . . . : 10.108.0.87

Subnet Mask . . . . . . . . . . . : 255.255.254.0

Default Gateway . . . . . . . . . : 10.108.0.1

Ethernet adapter VirtualBox Host-Only Network:

Connection-specific DNS Suffix . :

Link-local IPv6 Address . . . . . : fe80::ecfb:969e:aa2e:1195%52

IPv4 Address. . . . . . . . . . . : 192.168.56.1

Subnet Mask . . . . . . . . . . . : 255.255.255.0

Default Gateway . . . . . . . . . :

This is my Hosts file in the cloudera VM :

127.0.0.1 localhost.localdomain localhost

I tried out different things to connect to Hbase according to suggestions on the net, but those did not work for me.

I am getting the following error :

13/11/11 16:13:03 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect

java.net.ConnectException: Connection refused: no further information

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

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

at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)

at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)

13/11/11 16:13:03 WARN zookeeper.RecoverableZooKeeper: Possibly transient ZooKeeper exception:

org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for

/hbase/hbaseid

13/11/11 16:13:03 INFO util.RetryCounter: Sleeping 4000ms before retry #2...

13/11/11 16:13:04 INFO zookeeper.ClientCnxn: Opening socket connection to server

localhost.localdomain/192.168.56.1:2181. Will not attempt to authenticate using SASL (unknown error)

13/11/11 16:13:05 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect

java.net.ConnectException: Connection refused: no further information

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

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

at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)

at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)

13/11/11 16:13:06 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost.localdomain/192.168.56.1:2181. Will not attempt to authenticate using SASL (unknown error)

It would be great if anyone can list steps which will help me in setting up the remote connection.


This answer is a bit late, but I hope others might benefit from it.

When getting the error "Session 0x0 for server null" one of the likely issues is that your HBase-code doesn't know where to connect. Best way to solve this is to load your hbase-site.xml config-file.

Configuration config = HBaseConfiguration.create();
config.addResource(new Path("/XXXX/hbase/hbase-0.98.9/conf/hbase-site.xml"));
链接地址: http://www.djcxy.com/p/65798.html

上一篇: IP地址和AS号码之间的关系

下一篇: 使用Java客户端API连接到Cloudera VM上的Hbase: