环境描述

  • 操作系统版本:CentOS release 6.5 (Final)
  • 内核版本:2.6.32-431.el6.x86_64
  • phoenix版本:phoenix-4.10.0
  • hbase版本:hbase-1.2.6
  • hbase节点分布:1个HMaster,2个RegionServer

文档目的

通过在phoenix客户端连接hbase数据库,在phoenix中创建二级索引。

配置过程

1.登录到RegionSever节点,修改hbase-site.xml配置文件,加入如下配置

<property>

<name>phoenix.query.maxServerCacheBytes</name>

<value>2097152000</value>

</property>

<property>

<name>hbase.regionserver.wal.codec</name>

<value>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec</value>

</property>

<property>

<name>hbase.region.server.rpc.scheduler.factory.class</name>

<value>org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory</value>

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

</property>

<property>

<name>hbase.rpc.controllerfactory.class</name>

<value>org.apache.hadoop.hbase.ipc.controller.ServerRpcControllerFactory</value>

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

</property>

备注:要在所有的RegionServer节点进行添加,HMaster节点的hbase-site.xml配置文件不需要进行修改。

2.修改之后,重新启动hbase服务

进入hbase-1.2.6目录:

bin/stop-hbase.sh

bin/start-hbase.sh

3.通过jps检查各个hbase节点进程无异常

4.通过phoenix连接hbase,然后创建二级索引

创建表测试表:

CREATE TABLE IF NOT EXISTS WEB_STAT (

HOST CHAR(2) NOT NULL,

DOMAIN VARCHAR NOT NULL,

FEATURE VARCHAR NOT NULL,

DATE DATE NOT NULL,

USAGE.CORE BIGINT,

USAGE.DB BIGINT,

STATS.ACTIVE_VISITOR INTEGER

CONSTRAINT PK PRIMARY KEY (HOST, DOMAIN, FEATURE, DATE)

);

创建二级索引:

CREATE INDEX IDX_01 ON WEB_STAT(HOST);

删除二级索引:

DROP INDEX IDX_01 ON WEB_STAT

备注:如果以上创建索引没有报错,说明以上的基本配置是没有问题的。

如果不配置以上参数,会报下面的错误

0: jdbc:phoenix:redhat6> create index my_index on example (M.C0);

Error: ERROR 1029 (42Y88): Mutable secondary indexes must have the hbase.regionserver.wal.codec property set to org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec in the hbase-sites.xml of every region server. tableName=MY_INDEX (state=42Y88,code=1029)

java.sql.SQLException: ERROR 1029 (42Y88): Mutable secondary indexes must have the hbase.regionserver.wal.codec property set to org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec in the hbase-sites.xml of every region server. tableName=MY_INDEX

at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:488)

at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:150)

at org.apache.phoenix.schema.MetaDataClient.createIndex(MetaDataClient.java:1456)

at org.apache.phoenix.compile.CreateIndexCompiler$1.execute(CreateIndexCompiler.java:85)

at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:394)

at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:377)

at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)

at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:375)

at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:364)

at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1738)

at sqlline.Commands.execute(Commands.java:822)

at sqlline.Commands.sql(Commands.java:732)

at sqlline.SqlLine.dispatch(SqlLine.java:813)

at sqlline.SqlLine.begin(SqlLine.java:686)

at sqlline.SqlLine.start(SqlLine.java:398)

at sqlline.SqlLine.main(SqlLine.java:291)

通过phoenix在hbase上创建二级索引,Secondary Indexing的更多相关文章

  1. Phoenix二级索引(Secondary Indexing)的使用

    摘要 HBase只提供了一个基于字典排序的主键索引,在查询中你只能通过行键查询或扫描全表来获取数据,使用Phoenix提供的二级索引,可以避免在查询数据时全表扫描,提高查过性能,提升查询效率   测试 ...

  2. 利用Phoenix为HBase创建二级索引

    为什么需要Secondary Index 对于Hbase而言,如果想精确地定位到某行记录,唯一的办法是通过rowkey来查询.如果不通过rowkey来查找数据,就必须逐行地比较每一列的值,即全表扫瞄. ...

  3. Phoneix(三)HBase集成Phoenix创建二级索引

    一.Hbase集成Phoneix 1.下载 在官网http://www.apache.org/dyn/closer.lua/phoenix/中选择提供的镜像站点中下载与安装的HBase版本对应的版本. ...

  4. phoenix连接hbase数据库,创建二级索引报错:Error: org.apache.phoenix.exception.PhoenixIOException: Failed after attempts=36, exceptions: Tue Mar 06 10:32:02 CST 2018, null, java.net.SocketTimeoutException: callTimeou

    v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VM ...

  5. HBase协处理器同步二级索引到Solr

    一. 背景二. 什么是HBase的协处理器三. HBase协处理器同步数据到Solr四. 添加协处理器五. 测试六. 协处理器动态加载 一. 背景 在实际生产中,HBase往往不能满足多维度分析,我们 ...

  6. HBase Region级别二级索引

    我们会经常谈及二级索引,这是对全表数据进行另外一种方式的组织存储,是针对table级别的.如果要为HBase上的表实现一个强一致性的二级索引,那么就无法逃避分布式事务,而这一直是用户最期待的功能. 而 ...

  7. Hbase(三) hbase协处理器与二级索引

    一.协处理器—Coprocessor 1. 起源Hbase 作为列族数据库最经常被人诟病的特性包括:无法轻易建立“二级索引”,难以执 行求和.计数.排序等操作.比如,在旧版本的(<0.92)Hb ...

  8. HBase 协处理器实现二级索引

    HBase在0.92之后引入了coprocessors,提供了一系列的钩子,让我们能够轻易实现访问控制和二级索引的特性.下面简单介绍下两种coprocessors,第一种是Observers,它实际类 ...

  9. HBase协处理器同步二级索引到Solr(续)

    一. 已知的问题和不足二.解决思路三.代码3.1 读取config文件内容3.2 封装SolrServer的获取方式3.3 编写提交数据到Solr的代码3.4 拦截HBase的Put和Delete操作 ...

随机推荐

  1. 简析TCP的三次握手与四次分手<转>

    TCP是什么? 具体的关于TCP是什么,我不打算详细的说了:当你看到这篇文章时,我想你也知道TCP的概念了,想要更深入的了解TCP的工作,我们就继续.它只是一个超级麻烦的协议,而它又是互联网的基础,也 ...

  2. 使用PD进行数据库建模时的问题

    在PowerDesigner中建立好概念模型后,将其转为物理模型的时候出现如下错误提示: 前面四个是相同的问题,原因是由于没有修改默认设置.可以在Tools--->Model Options-& ...

  3. Fine-tuning Convolutional Neural Networks for Biomedical Image Analysis: Actively and Incrementally如何使用尽可能少的标注数据来训练一个效果有潜力的分类器

    作者:AI研习社链接:https://www.zhihu.com/question/57523080/answer/236301363来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载 ...

  4. keras系列︱Application中五款已训练模型、VGG16框架(Sequential式、Model式)解读(二)

    引自:http://blog.csdn.net/sinat_26917383/article/details/72859145 中文文档:http://keras-cn.readthedocs.io/ ...

  5. Java Servlet (1) —— Filter过滤请求与响应

    Java Servlet (1) -- Filter过滤请求与响应 版本: Java EE 6 参考来源: Oracle:The Java EE 6 Tutorial: Filtering Reque ...

  6. angula学习

    入门 http://www.angularjs.cn/A004 http://www.cnblogs.com/whitewolf/p/angularjs-start.html http://www.n ...

  7. Access restriction: The method typeNameToClass(String) from the type ObjectHandler is not accessible due to restriction on required library

    异常: Access restriction: The method typeNameToClass(String) from the type ObjectHandler is not access ...

  8. an error has occurred while trying to access the log file. logging may not function properly

    I had this issure a couple of days ago  when  open my vs2012 on windows8,by google i find the soluth ...

  9. Spark算子总结(带案例)

    Spark算子总结(带案例) spark算子大致上可分三大类算子: 1.Value数据类型的Transformation算子,这种变换不触发提交作业,针对处理的数据项是Value型的数据. 2.Key ...

  10. Materialize快速入门教程

    https://materializecss.com/ https://github.com/Dogfalo/materialize http://www.materializecss.cn/ 1,下 ...