因为zookeeper无法连接到hbase

时间:2013-08-22 05:11:48

标签: jdbc hbase apache-zookeeper phoenix

连接到hbase我写这段代码:

 Class.forName("com.salesforce.phoenix.jdbc.PhoenixDriver");
           conn = DriverManager.getConnection("jdbc:phoenix:localhost:2181");  

但跑完后给我这个错误:

13/08/22 09:14:14 INFO zookeeper.ZooKeeper: 
Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:host.name=ubuntu
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:java.version=1.7.0_25
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:
java.vendor=Oracle Corporation
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:
java.home=/usr/local/jdk1.7.0_25/jre
13/08/22 09:14:14 INFO zookeeper.ZooKeeper:
 Client environment:java.class.path=/home/ubuntu/Phonix/phoenix-2.0.0-client.jar: 
/home/ubuntu/Downloads/hbql-0.90.0.1/hbql-0.90.0.1-src.jar:/home/ubuntu/Downloads/
 hbql-0.90.0.1/hbql-0.90.0.1.jar:/home/ubuntu/Downloads/protobuf-java-2.4.1.jar:
/home/ubuntu/NetBeansProjects/hbase-phoenix/build/classes
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:java.library.path=
/usr/local/jdk1.7.0_25/jre/lib/amd64:/usr/local/jdk1.7.0_25/jre/lib/i386:
/usr/java/packages/lib/i386:/lib:/usr/lib
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=/tmp
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:java.compiler=<NA>
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:os.name=Linux
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:os.arch=i386
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:os.version=
3.2.0-23-generic-pae
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:user.name=ubuntu
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:user.home=/home/ubuntu
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Client environment:user.dir=
/home/ubuntu/NetBeansProjects/hbase-phoenix
13/08/22 09:14:14 INFO zookeeper.ZooKeeper: Initiating client connection, 
connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection
13/08/22 09:14:14 INFO zookeeper.RecoverableZooKeeper: 
The identifier of this process is 4944@ubuntu
13/08/22 09:14:14 INFO zookeeper.ClientCnxn: Opening socket connection to server 
localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
13/08/22 09:14:14 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected 
error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:708)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport
    (ClientCnxnSocketNIO.java:350)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
13/08/22 09:14:15 WARN zookeeper.RecoverableZooKeeper:
Possibly transient
 ZooKeeper exception:org.apache.zookeeper.KeeperException$ConnectionLossException:
 KeeperErrorCode = 
 ConnectionLoss for /hbase/hbaseid
13/08/22 09:14:15 INFO util.RetryCounter: Sleeping 2000ms before retry #1...

我无法理解这是什么问题。 我单独安装hbase 0.94.10和zookeeper 3.4.5,我不确定配置是否正确。您可以指导并帮助我正确配置它们

2 个答案:

答案 0 :(得分:0)

您是否确保将凤凰服务器jar(其名称为phoenix-.jar,我认为应该是phoenix-2.0.0.jar)复制到您所有的区域服务器? 还要确保将phoenix jar的位置附加到HBase类路径。您需要将以下内容放在所有区域服务器的hbase-env.sh中:

HBASE_CLASSPATH=$HBASE_CLASSPATH:/path/to/phoenix-2.0.0.jar

之后您需要重新启动群集。然后凤凰会工作。 您还可以阅读他们github project page的安装指南。 更新: 我刚看到他们更新了他们的文档。最后一个版本的文档更直接,但我认为你会管理......

答案 1 :(得分:0)

为仍在寻找的人添加答案:

您的jdbc连接字符串必须如下所示:

  

JDBC:凤:zookeeper_quorum:2181:/ hbase_znode    

     

JDBC:凤:zookeeper_quorum:/ hbase_znode

(默认情况下,zookeeper侦听端口2181 。)

zookeeper_quorum - 可以是逗号分隔的服务器名称(必须是完全限定的DNS名称) hbase_znode - hbase或hbase-unsecured

e.g。

  

JDBC:凤:server1.abc.com,server2.abc.com:2181:/ HBase的