Unable to connect to hbase via phoenix

I am trying to connect hbase via : First, I added phoenix-2.jar to the hbase lib directory. Then restart the region server, and then create a project in netbeans and add the phoenic-2-client.jar to the project class. Then the lines below are added in hbase.site.xml for hbase and 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 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 config zoo.cfg. The directory where the snapshot is stored. </description> </property> 

My hbase is a pseudo-specific mode. Finally, I wrote the following code in netbeans to connect to 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); 

but shows this error:

  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) 

Please help me..

+4
source share
4 answers

Check if this helps .

As mentioned in the Phoenix project, the jdbc connection url should be like this: jdbc:phoenix:zookeeper1:port,zookeeper2:port

By default, zookeeper listens on port 2181.

thanks

+1
source

As the error clearly states, your db connection url is incorrect in the getConnection method:

 jdbc:phoenix:rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com:2222:hdfs://localhost:8020/hbase 

I believe your jdbc connection url should look something like this:

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

Adding an answer for those still looking:

The jdbc connection string should look like this:

jdbc: phoenix: zookeeper_quorum: 2181: / hbase_znode or

JDBC: phoenix: zookeeper_quorum: / hbase_znode

(By default, zookeeper listens on port 2181.)

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

eg.

JDBC: Phoenix: server1.abc.com, server2.abc.com: +2181: / HBase

0
source

I used Phoenix-4.7.0-HBase-1.1. If you work in pseudo-distributed mode, you can simply do connection = DriverManager.getConnection("jdbc:phoenix"); right away. Just make sure your Java program can communicate with the wizard, Zookeeper and RegionServer. Check which ports and IP / hostname are used. In my case (SSH Tunneling), I made sure that the ports of HMaster: 16000, HQuorumPeer: 2181 and HRegionServer: 16201 were not blocked.

0
source

Source: https://habr.com/ru/post/1498150/


All Articles