简体   繁体   English

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

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

I am using the following JAVA code to establish the connection : 我正在使用以下JAVA代码建立连接:

 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 : 这是我在Windows上的CmdLine的ipConfig:

Ethernet adapter Local Area Connection: 以太网适配器本地连接:

Link-local IPv6 Address . 链接本地IPv6地址。 . . . . : fe80::a03b:5ec2:cc82:f952%12 :fe80 :: a03b:5ec2:cc82:f952%12

IPv4 Address. IPv4地址。 . . . . . . . . . . : 10.108.0.87 :10.108.0.87

Subnet Mask . 子网掩码 。 . . . . . . . . . . : 255.255.254.0 :255.255.254.0

Default Gateway . 默认网关 。 . . . . . . . . : 10.108.0.1 :10.108.0.1

Ethernet adapter VirtualBox Host-Only Network: 以太网适配器VirtualBox仅主机网络:

Connection-specific DNS Suffix . 特定于连接的DNS后缀。 :

Link-local IPv6 Address . 链接本地IPv6地址。 . . . . : fe80::ecfb:969e:aa2e:1195%52 :fe80 :: ecfb:969e:aa2e:1195%52

IPv4 Address. IPv4地址。 . . . . . . . . . . : 192.168.56.1 :192.168.56.1

Subnet Mask . 子网掩码 。 . . . . . . . . . . : 255.255.255.0 :255.255.255.0

Default Gateway . 默认网关 。 . . . . . . . . :

This is my Hosts file in the cloudera VM : 这是我在cloudera VM中的主机文件

127.0.0.1 localhost.localdomain localhost 127.0.0.1 localhost.localdomain本地主机

I tried out different things to connect to Hbase according to suggestions on the net, but those did not work for me. 我根据网络上的建议尝试了各种不同的方法来连接到Hbase,但这些方法对我没有用。

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 13/11/11 16:13:03警告zookeeper.ClientCnxn:服务器null的会话0x0,意外错误,关闭套接字连接并尝试重新连接

java.net.ConnectException: Connection refused: no further information java.net.ConnectException:连接被拒绝:没有更多信息

at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 在sun.nio.ch.SocketChannelImpl.checkConnect(本机方法)

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

at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350) 在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: 13/11/11 16:13:03警告zookeeper.RecoverableZooKeeper:可能是暂时的ZooKeeper异常:

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

/hbase/hbaseid / hbase / hbaseid

13/11/11 16:13:03 INFO util.RetryCounter: Sleeping 4000ms before retry #2... 13/11/11 16:13:03 INFO util.RetryCounter:重试#2之前睡眠4000毫秒...

13/11/11 16:13:04 INFO zookeeper.ClientCnxn: Opening socket connection to server 13/11/11 16:13:04信息zookeeper.ClientCnxn:打开与服务器的套接字连接

localhost.localdomain/192.168.56.1:2181. localhost.localdomain / 192.168.56.1:2181。 Will not attempt to authenticate using SASL (unknown error) 不会尝试使用SASL进行身份验证(未知错误)

13/11/11 16:13:05 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect 13/11/11 16:13:05警告zookeeper.ClientCnxn:服务器null的会话0x0,意外错误,关闭套接字连接并尝试重新连接

java.net.ConnectException: Connection refused: no further information java.net.ConnectException:连接被拒绝:没有更多信息

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. 13/11/11 16:13:06信息zookeeper.ClientCnxn:打开与服务器localhost.localdomain / 192.168.56.1:2181的套接字连接。 Will not attempt to authenticate using SASL (unknown error) 不会尝试使用SASL进行身份验证(未知错误)

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. 收到错误“服务器null的会话0x0”时,可能的问题之一是您的HBase代码不知道在哪里连接。 Best way to solve this is to load your hbase-site.xml config-file. 解决此问题的最佳方法是加载hbase-site.xml配置文件。

Configuration config = HBaseConfiguration.create();
config.addResource(new Path("/XXXX/hbase/hbase-0.98.9/conf/hbase-site.xml"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM