博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

phoenix创建二级索引

Posted on 2016-08-25 10:59  来碗酸梅汤  阅读(439)  评论(0编辑  收藏  举报
create table user (id varchar primary key, firstname varchar, lastname varchar); 
create index user_idx on user (firstname);

hbase-site.xml中配置

        <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>

        <property>
          <name>hbase.coprocessor.regionserver.classes</name>
          <value>org.apache.hadoop.hbase.regionserver.LocalIndexMerger</value> 
        </property>

否则报错

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=LAYER_IDX (state=42Y88,code=1029)