CleanRoRtTables工具
功能说明
清理Hudi MOR表关联的孤立_ro和_rt Hive视图表。低版本Hudi会自动创建_ro/_rt视图,高版本不再需要这些视图,此工具用于清理这些残留的视图表。执行DROP TABLE仅删除Hive Metastore中的元数据,不删除HDFS上的数据文件(因为是EXTERNAL_TABLE)。
约束
- 只处理MOR表。
- 不支持备份恢复,DROP TABLE操作不可逆(但因为是EXTERNAL_TABLE,HDFS数据文件不会被删除)。
- 表名比较不区分大小写。
命令格式
spark-submit \
--master yarn \
--driver-memory 2G \
--num-executors 3 \
--executor-memory 4G \
--class com.huawei.mrs.hudi.tools.CleanRoRtTables \
/opt/hudi-fix-tools-1.0.jar \
${命令} ${库名} [${排除表}] 参数说明
| 参数 | 是否必选 | 参数说明 |
|---|---|---|
| ${命令} | 是 |
|
| ${库名} | 是 | 需要扫描的数据库名称。 |
| ${排除表} | 否 | 逗号分隔的排除表名列表,被排除的表不会被检查和清理。例如:table1_ro,table2_rt。 |
输出结果说明
| 字段 | 说明 |
|---|---|
| RESULT | success表示执行成功,failed表示执行失败。 |
| MESSAGE | 检测到的ro/rt视图表信息、执行结果信息或执行失败信息。 |
clean命令的输出分类:
| 分类 | 说明 |
|---|---|
| Cleaned | DROP成功的表。 |
| Cleaned (orphan ro/rt table) | DROP成功的孤立ro/rt表(主表location不存在)。 |
| Clean failed | DROP失败的表。 |
| Skipped | 被跳过的表及原因。 |
使用样例
- 检查数据库中可清理的ro/rt视图表:
spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \ --class com.huawei.mrs.hudi.tools.CleanRoRtTables \ /opt/hudi-fix-tools-1.0.jar \ check mydb
- 检查时排除特定表:
spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \ --class com.huawei.mrs.hudi.tools.CleanRoRtTables \ /opt/hudi-fix-tools-1.0.jar \ check mydb "important_table_ro,important_table_rt"
- 清理ro/rt视图表:
spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \ --class com.huawei.mrs.hudi.tools.CleanRoRtTables \ /opt/hudi-fix-tools-1.0.jar \ clean mydb
- 清理时排除特定表:
spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \ --class com.huawei.mrs.hudi.tools.CleanRoRtTables \ /opt/hudi-fix-tools-1.0.jar \ clean mydb "important_table_ro,important_table_rt"