1. 程式人生 > >phoenix建立二級索引索要修改的配置

phoenix建立二級索引索要修改的配置

如果不進行任何配置,直接在phoenix上建立二級索引 ,比如

create index A_INDEX on "t_tablename"("from_account","to_account","quantity","status") include("from_account","to_account");

那麼會報錯:

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=A_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=A_INDEX
        at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:455)
        at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:145)
        at org.apache.phoenix.schema.MetaDataClient.createIndex(MetaDataClient.java:1290)
        at org.apache.phoenix.compile.CreateIndexCompiler$1.execute(CreateIndexCompiler.java:85)
        at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:344)
        at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:332)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:331)
        at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1442)
        at sqlline.Commands.execute(Commands.java:822)
        at sqlline.Commands.sql(Commands.java:732)
        at sqlline.SqlLine.dispatch(SqlLine.java:807)
        at sqlline.SqlLine.begin(SqlLine.java:681)
        at sqlline.SqlLine.start(SqlLine.java:398)
        at sqlline.SqlLine.main(SqlLine.java:292)

網上百度各種方法試了又試,搞了又搞,發現有的人都是貼上複製,一點都不負責,弄的我的hbase叢集出問題,最後沒辦法,自己在phoenix官網看到詳細配置搞定(在每個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>