博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
通过phoenix在hbase上创建二级索引,Secondary Indexing
阅读量:6897 次
发布时间:2019-06-27

本文共 3372 字,大约阅读时间需要 11 分钟。

环境描述

  • 操作系统版本: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)

转载于:https://www.cnblogs.com/chuanzhang053/p/8515024.html

你可能感兴趣的文章
雷神2—狂热视觉震撼
查看>>
node.js实现多图片上传
查看>>
could not bind to address 0.0.0.0:443 no listening sockets available, shutting d
查看>>
Node.js 开发相关
查看>>
JFinal源码--获取表单数据
查看>>
JSONP安全防范解决方案新思路
查看>>
Web 开发最有用的50款 jQuery 插件集锦——《综合篇》
查看>>
import com.sun.image.codec.jpeg.JPEGCodec不通过 找不到包
查看>>
adrci中的purge
查看>>
前台对Seajs的用法个人见解
查看>>
java中的队列同步器AQS -- AbstractQueuedSynchronizer
查看>>
centos 脚本基础练习9
查看>>
我的友情链接
查看>>
GET和POST,有什么区别
查看>>
Android内存优化
查看>>
windows 安全策略
查看>>
centos6.9实现网卡bonding
查看>>
No module named 'MySQLdb' python3.6 + django 1.10 + mysql 无法连接
查看>>
使用nginx搭建https服务器 (转)
查看>>
Linux磁盘分区管理--ext2和ext3文件系统逻辑结构分析
查看>>