0

为了连接到 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,我不确定配置是否正确。你能指导并帮助我如何正确配置它们吗

4

2 回答 2

0

您是否确保将 phoenix 服务器 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 项目页面的安装指南。更新:我刚刚看到他们更新了他们的文档。文档的最后一个版本更加直接,但我认为你会管理......

于 2013-09-25T17:27:21.650 回答
0

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

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

jdbc:phoenix:zookeeper_quorum:2181:/hbase_znode

jdbc:phoenix:zookeeper_quorum:/hbase_znode

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

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

例如

jdbc:phoenix:server1.abc.com,server2.abc.com:2181:/hbase

于 2016-06-06T09:38:07.930 回答