4

経由でに接続しようとしています。まず、 hbase lib ディレクトリに追加しました。次に、リージョン サーバーを再起動してから、netbeans でプロジェクトを作成し、プロジェクトのクラスパスに を追加します。次に、以下の行をfor 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 は疑似分散モードです。最後に、hbase に接続するために netbeans で次のコードを書きました。

 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

このリンクが役立つかどうかを確認してください。

Phoenixプロジェクトで述べたように、jdbc 接続 URL は次のようになります。jdbc:phoenix:zookeeper1:port,zookeeper2:port

デフォルトでは、zookeeper はポート 2181 でリッスンします。

ありがとう

于 2013-08-23T12:35:25.070 に答える
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

Adding answer for anyone still looking:

Your jdbc connection string must look like:

jdbc:phoenix:zookeeper_quorum:2181:/hbase_znode or

jdbc:phoenix:zookeeper_quorum:/hbase_znode

(By default zookeeper listens at port 2181.)

zookeeper_quorum - Can be comma-separated server-names(must be fully qualified DNS names) hbase_znode - hbase or hbase-unsecured

e.g.

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

于 2016-06-06T09:34:26.270 に答える