Updated on 2024-11-29 GMT+08:00

Creating Indexes in Batches

Scenarios

If a large amount of data exists in a data table, you can create indexes for the data in batches based on MapReduce tasks.

How to Use

  • Only indexes in INACTIVE state can be created in batches. To re-create index data, change the index status first.
  • If a data table contains a large amount of data, the creation takes a long time. You are advised to run the nohup command in the background to prevent the operation from being interrupted unexpectedly.

Run the following command on the HBase client to create indexes in batches:

hbase org.apache.hadoop.hbase.hindex.global.mapreduce.GlobalTableIndexer -Dtablename.to.index='table' -Dindexnames.to.build='idx1'

The parameters are described as follows:

  • tablename.to.index: indicates the name of the data table whose index status needs to be changed.
  • indexnames.to.build: indicates the names of the indexes you want to create in batches. You can specify multiple names and separate them with number signs (#).
  • (Optional)hbase.gsi.cleandata.enabled: indicates whether to clear the index table before creating indexes. The default value is false.
  • (Optional) hbase.gsi.cleandata.timeout: indicates timeout interval for clearing the index table before creating indexes. The default value is 1800, in seconds.