问题描述:
环境:ESC中搭建的ambari大数据管理平台,添加Hbase服务时勾选Phoenix支持,Phoenix本版4.7。
step1: 添加phoenix服务器安装目录下的phoenix-[version]-client.jar到squirrel-sql安装目录lib/下
step2: 添加驱动,填写驱动类名:org.apache.phoenix.jdbc.PhoenixDriver
step3: Windown系统host文件添加主机ip映射
step4: 创建连接如下图
image.png
image.png
问题分析:
使用java连接可以打印详细问题原因
public static void main(String[] args) throws Exception {
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
Connection conn = DriverManager.getConnection("jdbc:phoenix:octserver1.hadoop,octserver2.hadoop,octserver3.hadoop:2181:/hbase-unsecure");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select * from \"hdyc\" limit 10");
while(rs.next()){
String v1 = rs.getString("meter_id");
String v2 = rs.getString("create_time");
System.out.println(v1+" "+v2);
}
stat.close();
conn.close();
}
- 问题1
phoenix The node /hbase is not in ZooKeeper
原因:hbase-site.xml中有如下配置
<property>
<name>zookeeper.znode.parent</name>
<value>/hbase-unsecure</value>
</property>
解决 jdbc:phoenix:node0.example.com:2181:/hbase-unsecure
Driver配置如下:
Name:phoenix(任意取名)
Example:jdbc:phoenix:node0.example.com:2181:/hbase-unsecure
Java Class Path:phoenix-[version]-client.jar到squirrel-sql安装目录lib/下就可以,不需要去选择。
Class Name:org.apache.phoenix.jdbc.PhoenixDriver
Aliases配置
Name:phoenix (随意取)
Driver:选择之前创建的phoenix驱动。
URl:jdbc:phoenix:node0.example.com:2181:/hbase-unsecure
User Name:任意取
Password:任意取