springboot+hbase 集成

项目中使用 phoenix 使用SQL 方式来操作Hbase 数据库,但是遇到一个是,SQL在Dbeaver 中查询速度还可以,但是使用phoenix+ibatis 后返回结果集数据量20w ,速度特别慢,先是考虑用redis方式缓存,但是内存有限,想着是用,hbase直连的方式,测试一下解决一下,

一:简介
hbase-client是HBase提供的一套比较底层的API,在实际使用时需要对其进行封装,提供更好用的api给用户。

操作hbase的客户端有以下几种方式:

hbase-client 比较底层,需要自己进一步封装api,而且版本号和安装的hbase也要匹配,否则会报错
spring-data-hadoop 2019年4月5停止维护
Apache Phoenix 使用SQL的方式来操作HBase

  • 下面是springboot+ hbase-client方式

注意!需要去掉slf4j和log4j jar 否则会报相应的错误:pom.xml 引入

<dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-client</artifactId>
            <version>2.1.3</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

注意!hbase application.yml 设置: hbase.zookeeper.znode 更正为hbase.zookeeper.parent

hbase:
  config:
    hbase.zookeeper.quorum: 127.0.0.1
    hbase.zookeeper.port: 2181
    hbase.zookeeper.parent: /hbase
    hbase.client.keyvalue.maxsize: 1572864000

hbase.zookeeper.parent的作用:

Zookeeper作用在于:

1、hbase regionserver向zookeeper注册,提供hbase regionserver状态信息(是否在线)。

2、hmaster启动时候会将hbase系统表-ROOT-加载到zookeeper cluster,通过zookeeper cluster可以获取当前系统表.META.的存储所对应的regionserver信息。

zookeeper是hbase集群的"协调器"。由于zookeeper的轻量级特性,因此我们可以将多个hbase集群共用一个zookeeper集群,以节约大量的服务器。多个hbase集群共用zookeeper集群的方法是使用同一组ip,修改不同hbase集群的"zookeeper.znode.parent"属性,让它们使用不同的根目录。比如cluster1使用/hbase-c1,cluster2使用/hbase-c2,等等。

HMaster主要作用在于,通过HMaster维护系统表-ROOT-,.META.,记录regionserver所对应region变化信息。此外还负责监控处理当前hbase cluster中regionserver状态变化信息。

hbase regionserver则用于多个/单个维护region。

region则对应为hbase数据表的表分区数据维护。

参考:https://www.cnblogs.com/cxzdy/p/5369187.html

https://www.jianshu.com/p/67a817a157ee

项目搭建参考如下:

https://blog.csdn.net/vbirdbest/article/details/88410954

3. hbase API 建议参考:

https://www.cnblogs.com/frankdeng/p/9310209.html

4.hbase 基本的JavaApi 数据操作及数据过滤(filter)

https://www.cnblogs.com/frankdeng/p/9310262.html

https://www.cnblogs.com/asker009/p/10626508.html

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

利剑 -~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值