【问题标题】:Can not connect to hbase via phoenix无法通过phoenix连接到hbase
【发布时间】:2013-08-23 13:33:35
【问题描述】:

我正在尝试通过 连接: 首先,我在 hbase lib 目录中添加了phoenix-2.jar。 然后重新启动区域服务器,然后在 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)

请指导我..

【问题讨论】:

  • 请使用正确的大小写和缩进。我中途放弃了编辑。
  • 您是否在 xml 文件或连接 url 中指定了用户名和密码?
  • 不,我没有定义用户名和密码。我不确定代码是否正确..我不知道该怎么做
  • 您是否在没有 phoenix 的情况下连接到 HBase?您的连接 url 中的“hdfs”是什么意思?或者您对所有这些有什么想法吗?
  • 不,我尝试通过 jdbc 驱动程序连接到 hbase,但找不到它..我变得困惑...您有什么建议可以连接到 hbase,我可以插入、扫描、...和处理操作..我想将我的关系数据库转换为 hbase。

标签: hbase phoenix java hbase apache-zookeeper phoenix


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    您的 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

    【讨论】:

      【解决方案3】:

      检查此link 是否有帮助。

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

      zookeeper 默认监听 2181 端口。

      谢谢

      【讨论】:

        【解决方案4】:

        正如错误清楚地表明,您的 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
        

        【讨论】:

        • 我认为这个连接 url 适用于 hbql 但我想通过 phoenix 连接...请帮助我。
        猜你喜欢
        • 2020-11-04
        • 2017-03-26
        • 2016-11-24
        • 2015-08-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-23
        • 1970-01-01
        相关资源
        最近更新 更多