2013-08-21 81 views
4

我想通過連接: 首先,我將phoenix-2.jar添加到hbase lib目錄。 然後重新啓動區域服務器,然後在netbeans中創建一個項目,並將phoenic-2-client.jar添加到項目的類路徑中。 然後在hbase和phoenix的下面加入hbase.site.xml無法通過phoenix連接到hbase

<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 distribiuted mode.Finally,我寫在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) 

請指導我..

+0

請使用適當的大小寫和縮進。我放棄了編輯的一半。 – kiheru

+0

您是否在您的xml文件或連接網址中指定了用戶名和密碼? – Soosh

+0

不,我沒有difine用戶名和密碼。我不知道代碼是否正確或不..我不知道該怎麼做 – Asma

回答

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連接URL應該是這個樣子:

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

我覺得這方面URL與hbql的工作,但我希望通過鳳凰連接...請幫助我。 – Asma

1

檢查,如果這link幫助。

正如Phoenix項目提到的,JDBC連接的URL應該是這樣的:jdbc:phoenix:zookeeper1:port,zookeeper2:port

默認監聽飼養員在端口2181

感謝

0

添加答案的人仍在尋找:

您的jdbc連接字符串必須如下所示:

jdbc:phoenix:zookeeper_quorum:2181:/hbase_znode or

jdbc:phoenix:zookeeper_quorum:/hbase_znode

(默認情況下,飼養員會偵聽端口2181

zookeeper_quorum - 可以是逗號分隔的服務器名稱(必須是完全合格的DNS名稱) hbase_znode - HBase的或HBase的,不安全的

eg

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

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未被阻止。