Changing Status of HBase Global Secondary Indexes
Index Status
The index status reflects the current index usage. The global secondary index supports the following five states:
- ACTIVE: The index is normal and can be read and written normally.
- UNUSABLE: The index is disabled. Index data can be written normally and cannot be used for query.
- INACTIVE: The index is abnormal. The index data is inconsistent with that in the data table. The index data for generating the index is skipped. The index cannot be used during data query.
- BUILDING: Index data is generated in batches. After the index data generation tool is executed, the index data is automatically switched to the ACTIVE state. In this state, data can be read and written properly.
- DROPPING: The index is being deleted. The index data generated for the index is skipped. The index cannot be used during data query.
The index status can be changed based on the tool. Figure 1 describes the status change.
Scenarios
You can use the global secondary index tool to disable or enable an index.
Changing Status of HBase Global Secondary Indexes
Run the following command on the HBase client to disable or enable an index:
hbase org.apache.hadoop.hbase.hindex.global.mapreduce.GlobalTableIndexer -Dtablename.to.index='table' -D[idx_state_opt]='idx1'
The related parameters are described as follows:
- tablename.to.index: indicates the name of the data table whose index status needs to be changed.
- idx_state_opt: target status of the index to be modified. The options are as follows:
- indexnames.to.inactive: changes the status of a specified index to INACTIVE.
- indexnames.to.active: changes the status of a specified index to ACTIVE.
- indexnames.to.unusable: converts the specified index to the UNUSABLE state.
For example, to change the status of the idx1 index in the ACTIVE table to UNUSABLE, run the following command:
hbase org.apache.hadoop.hbase.hindex.global.mapreduce.GlobalTableIndexer -Dtablename.to.index='table' -Dindexnames.to.unusable='idx1'
After the command is executed successfully, check the index information again.
hbase org.apache.hadoop.hbase.hindex.global.mapreduce.GlobalTableIndexer -Dtablename.to.show='table'
As shown in Figure 2, the index status of idx1 has been changed.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot