我想通過phoenix連接hbase: 首先,我將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)
請指導我..
請使用適當的大小寫和縮進。我放棄了編輯的一半。 – kiheru
您是否在您的xml文件或連接網址中指定了用戶名和密碼? – Soosh
不,我沒有difine用戶名和密碼。我不知道代碼是否正確或不..我不知道該怎麼做 – Asma