无法通过凤凰连接到hbase

时间:2013-08-21 08:56:45

标签: java hbase apache-zookeeper phoenix

我正在尝试通过连接: 首先,我将phoenix-2.jar添加到hbase lib目录中。 然后重新启动区域服务器,然后在netbeans中创建一个项目,并将phoenic-2-client.jar添加到项目的类路径中。 然后将以下行添加到hbase.site.xml中,用于hbase和phoenix。

    <property>
<name>hbase.master</name>
<value>23.201.00.100:60000</value>
<description>The host and port the HBase master runs at. 
</description>
</property>
<property>
  <name>hbase.zookeeper.property.clientPort</name>
  <value>2222</value>
  <description>Property from ZooKeeper's config zoo.cfg.
  The port at which the clients will connect.
  </description>
</property>
<property>
  <name>hbase.zookeeper.quorum</name>
         <value>rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com</value>
  <description>Comma separated list of servers in the ZooKeeper Quorum.
  For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".
  By default this is set to localhost for local and pseudo-distributed modes
  of operation. For a fully-distributed setup, this should be set to a full
  list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set in hbase-env.sh
  this is the list of servers which we will start/stop ZooKeeper on.
  </description>
</property>
<property>
  <name>hbase.zookeeper.property.dataDir</name>
  <value>/usr/local/zookeeper</value>
  <description>Property from ZooKeeper's config zoo.cfg.
  The directory where the snapshot is stored.
  </description>
</property>

我的hbase是pseodo分配模式。最后,我在netbeans中编写了以下代码以连接到hbase:

 Connection conn;
    Properties prop = new Properties();
      try{
        Class.forName("com.salesforce.phoenix.jdbc.PhoenixDriver");
        conn =  DriverManager.getConnection("jdbc:phoenix:rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com:2222:hdfs://localhost:8020/hbase");
        System.out.println(conn);

但显示此错误:

    java.sql.SQLException: ERROR 102 (08001): Malformed connection url. jdbc:phoenix:rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com:2222:hdfs://localhost:8020/hbase
    at com.salesforce.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:146)
    at com.salesforce.phoenix.jdbc.PhoenixEmbeddedDriver$ConnectionInfo.create(PhoenixEmbeddedDriver.java:206)
    at com.salesforce.phoenix.jdbc.PhoenixDriver.getConnectionQueryServices(PhoenixDriver.java:78)
    at  com.salesforce.phoenix.jdbc.PhoenixEmbeddedDriver.connect(PhoenixEmbeddedDriver.java:115)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:233)
    at hbase.phoenix.HbasePhoenix.main(HbasePhoenix.java:30)
BUILD SUCCESSFUL (total time: 2 seconds)

请指导我..

4 个答案:

答案 0 :(得分:1)

检查此link是否有帮助。

Phoenix项目中所述,jdbc连接网址应如下所示:jdbc:phoenix:zookeeper1:port,zookeeper2:port

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

由于

答案 1 :(得分:0)

正如错误清楚地说明的那样,您的数据库连接URL在getConnection方法中出错:

jdbc:phoenix:rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com:2222:hdfs://localhost:8020/hbase

我相信你的jdbc连接网址应该是这样的:

jdbc:hbql;maxtablerefs=10;hbase.master=23.201.00.100:60000

答案 2 :(得分:0)

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

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

  

jdbc:phoenix: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的

答案 3 :(得分:0)

我使用的是Phoenix-4.7.0-HBase-1.1。如果您在伪分布式模式下运行,则可以立即执行connection = DriverManager.getConnection("jdbc:phoenix");。只需确保您的Java程序可以与Master,Zookeeper和RegionServer通信。检查正在使用的端口和IP /主机名。在我的情况下(SSH隧道),我确保端口HMaster:16000,HQuorumPeer:2181和HRegionServer:16201没有被阻止。