/**
* 生成连接
*
* @param jdbcDataSource
* 连接信息
* @throws IOException
* 连接异常
*/
private void getDataSource(JdbcDataSource jdbcDataSource) throws IOException {
String[] zkAdress = jdbcDataSource.getZkAddress().split(CommonConstants.SPLIT_SCOLON);
conf.set("zookeeper.znode.parent", "/hbase");
conf.set("hbase.zookeeper.quorum", "192.168.20.91");
conf.set("hadoop.user.name", "root");
conf.set("hbase.zookeeper.property.clientPort", "2181");
conf.setInt("hbase.client.operation.timeout", JdbcConstants.HBASE_TIMEOUT);
connection = ConnectionFactory.createConnection(conf, pool);
admin = connection.getAdmin();
}
==原因:==
总结一句话:该报错原因是hbase配置文件和java链接参数路径不一致问题
java链接hbase客户端需指定其中两个参数:"hbase.zookeeper.quorum"、"zookeeper.znode.parent",
其中"hbase.zookeeper.quorum" ——> zk的master地址 ,"zookeeper.znode.parent" ——>是zk在该文件夹下保存hbase相关操作链接的缓存信息
==解决方案:==
第一种:修改java连接参数"zookeeper.znode.parent"
第二种:修改参数对应linux下的/usr/hdp/3.1.0.0-78/hbase/conf/hbase-site.xml文件的最后一行 ↓,
<property>
<name>zookeeper.znode.parent</name>
<value>/hbase-unsecure</value>
</property>
确保java连接参数和linux的hbase这个配置参数保持一致即可,且以linux中hbase配置文件中为基准最好