• Phoenix创建Hbase二级索引_尚硅谷大数据培训


    配置Hbase支持Phoenix创建二级索引

    1 添加如下配置到Hbase的Hregionserver节点的hbase-site.xml

    hbase.regionserver.wal.codec

    org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec

    hbase.region.server.rpc.scheduler.factory.class

    org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory

    Factory to create the Phoenix RPC Scheduler that uses separate queues for index and metadata updates

    hbase.rpc.controllerfactory.class

    org.apache.hadoop.hbase.ipc.controller.ServerRpcControllerFactory

    Factory to create the Phoenix RPC Scheduler that uses separate queues for index and metadata updates

    2 添加如下配置到Hbase中Hmaster节点的hbase-site.xml中

    hbase.master.loadbalancer.class

    org.apache.phoenix.hbase.index.balancer.IndexLoadBalancer

    hbase.coprocessor.master.classes

    org.apache.phoenix.hbase.index.master.IndexMasterObserver

    3 常见问题汇总:

    1)注意:网上配置文档里有这一条,但在实际测试中(测试环境hbase-1.3.1,网上0.98.6),加入该条的regionserver会在hbase启动时失败,对应节点上没有HregionServer进程,去掉该配置后正常启动,且能正常创建local index。

    hbase.coprocessor.regionserver.classes

    org.apache.hadoop.hbase.regionserver.LocalIndexMerger

    2hbase-site.xml的zookeeeper的配置信息不能加2181,否则在创建local index的时候会报以下异常:

    正常配置:

            hbase.zookeeper.quorum

            hadoop101,hadoop102,hadoop103

    创建索引

    1 phoenix的索引分类

    1)global index是默认的索引格式。适用于多读少写的业务场景。写数据的时候会消耗大量开销,因为索引表也要更新,而索引表是分布在不同的数据节点上的,跨节点的数据传输带来了较大的性能消耗。在读数据的时候Phoenix会选择索引表来降低查询消耗的时间。如果想查询的字段不是索引字段的话索引表不会被使用,也就是说不会带来查询速度的提升。

    CREATE INDEX my_index ON my_table (my_index)

    2)Local index适用于写操作频繁的场景。索引数据和数据表的数据是存放在相同的服务器中的,避免了在写操作的时候往不同服务器的索引表中写索引带来的额外开销。查询的字段不是索引字段索引表也会被使用,这会带来查询速度的提升。

    CREATE LOCAL INDEX my_index ON my_table (my_index)

    2 三种提升效率查询方式

    1) CREATE INDEX my_index ON my_table (v1) INCLUDE (v2)

    2) SELECT /*+ INDEX(my_table my_index) */ v2 FROM my_table WHERE v1 = ‘foo’

    3) CREATE LOCAL INDEX my_index ON my_table (v1)

    3 如何删除索引

    DROP INDEX my_index ON my_table

     

  • 相关阅读:
    oracle RAC 集群归档模式的关闭和开启(适用于11g/12g/18c/19c)
    JSP forward动作
    SQLi-Labs系列之堆叠注入
    洛谷-1001-A+B问题
    Scrum认证高级Scrum Master (A-CSM) 认证培训课程
    java计算机毕业设计基于springboot电商项目(附源码讲解)
    Paper reading:Fine-Grained Head Pose Estimation Without Keypoints (CVPR2018)
    贪吃蛇项目(简单)
    【运维面试100问】(二)你最擅长什么?对某某擅长吗?---请设计一个符合公司使用的lvs架构
    leetcode题目分析(一)leetcode155最小栈
  • 原文地址:https://blog.csdn.net/zjjcchina/article/details/125890772