Restoring the HBase Table on MRS
After the CDH HBase table directories are migrated to MRS HBase, you can run commands to restore the directories. For data that may change, create snapshots to ensure that the data remains unchanged, and then migrate and restore the data.
Constraints
This solution supports only data migration to MRS 1.x clusters. In MRS 2.x and later versions, HBase tables cannot be rebuilt by running HBase repair commands.
If the target cluster version is 2.x or later, the HBase repair command is no longer supported, and the HBase data directory migration cannot be implemented.
Running Commands to Restore the Data Remaining Unchanged
- Access the node where MRS Client is located, for example, master1.
- Run the following command to switch to user omm:
su – omm
- Run the following command to load environment variables:
- Run the following command to change the directory permission:
hdfs dfs –chown omm:hadoop –R /hbase/data/default/table_20180811
- omm:hadoop: Indicates the username. Replace it with the actual username.
- /hbase/data/default/table_20180811: Indicates the path of the table.
- Run the following command to restore metadata:
- Run the command to restore regions:
- If the message "Status: OK" is displayed, the table is restored successfully.
Using Snapshots to Migrate and Restore the Data that May Change
- Run the following command in the HBase shell of the source CDH cluster:
- Run the following command in the HBase shell of the source CDH cluster:
- If the Snap function is not enabled in the table, run the following command to enable the function:
- Run the following commands to create an HDFS snapshot named s0:
hdfs dfs -createSnapshot <snapshotDir> [s0]
hdfs dfs -createSnapshot test
- CDM copies files to MRS using the HDFS snapshot. Configure the migration job on CDM as follows:
- Source Directory/File: /hbase/data/default/src_test/.snapshot/s0
- Write Directory: /hbase/data/default/Table name
- Run the fixMeta and fixAssignments commands to restore the table. For details, see Running Commands to Restore the Data Remaining Unchanged.
- Run the following command to delete the snapshot from the CDH cluster:
Rectifying the Fault That Occurs When Restoring a Table
- After the fixMeta command is executed, the error message "xx inconsistent" is displayed.
The fixMeta command is used to check the consistency of metadata between HDFS and HBase. This is a normal situation. Proceed to run the fixAssignments command.
- After the fixAssignments command is executed, the error message "xx inconsistent" is displayed.
The fixAssignments command is used to restore all regions. Sometimes, some regions go online slowly. You can run the following command to check whether the HBase table is successfully restored:
hbase hbck Table name
If the message "Status: OK" is displayed, the HBase table is restored successfully.
- After the fixAssignments command is executed, an error message is displayed, indicating that multiple regions have the same startkey and some regions overlap.
Run the following command:
hbase hbck –fixHdfsOverlaps Table name
Then run the fixMeta and fixAssignments commands.
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