4

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

    <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

4 回答 4

1

检查此链接是否有帮助。

凤凰项目中提到,jdbc连接url应该是这样的:jdbc:phoenix:zookeeper1:port,zookeeper2:port

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

谢谢

于 2013-08-23T12:35:25.070 回答
0

正如错误清楚地表明,您的 db connect 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 连接 url 应该是这样的:

jdbc:hbql;maxtablerefs=10;hbase.master=23.201.00.100:60000
于 2013-08-21T09:06:22.270 回答
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 没有被阻止。

于 2016-06-08T16:41:24.640 回答
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:34:26.270 回答