更新时间:2026-10-28 GMT+08:00
FixHiveMetadata工具
功能说明
恢复Hive Metastore保存的Hudi表的schema,使其与Hudi表最新schema一致。修复时会同步更新主表及其关联的_ro/_rt视图表(如果存在)。
命令格式
spark-submit \
--master yarn \
--driver-memory 2G \
--num-executors 3 \
--executor-memory 4G \
--class com.huawei.mrs.hudi.tools.FixHiveMetadata \
/opt/hudi-fix-tools-1.0.jar \
${命令} ${库名.表名} 参数说明
| 参数 | 是否必选 | 参数说明 |
|---|---|---|
| ${命令} | 是 |
|
| ${库名.表名} | 是 | 需要处理的Hudi表名,格式为库名.表名。 |
输出结果说明
| 字段 | 说明 |
|---|---|
| RESULT | success表示执行成功,failed表示执行失败。 |
| MESSAGE | 检测、执行结果信息或执行失败信息。 |
check命令的MESSAGE:
| MESSAGE | 说明 |
|---|---|
| No problems found. | Hive Metastore schema与Hudi表schema一致。 |
| The schema in hive metastore is not the same with hoodie schema | Hive Metastore schema与Hudi表schema不一致。 |
使用样例
- 检查Hive Metastore schema是否与Hudi表schema一致:
spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \ --class com.huawei.mrs.hudi.tools.FixHiveMetadata \ /opt/hudi-fix-tools-1.0.jar \ check mydb.mytable
- 修复Hive Metastore schema(自动备份,同时更新_ro/_rt表):
spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \ --class com.huawei.mrs.hudi.tools.FixHiveMetadata \ /opt/hudi-fix-tools-1.0.jar \ fix mydb.mytable
- 修复效果不理想,恢复到修复前状态:
spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \ --class com.huawei.mrs.hudi.tools.FixHiveMetadata \ /opt/hudi-fix-tools-1.0.jar \ restore mydb.mytable
- 确认修复效果后,清理备份文件:
spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \ --class com.huawei.mrs.hudi.tools.FixHiveMetadata \ /opt/hudi-fix-tools-1.0.jar \ cleanbackup mydb.mytable
父主题: Hudi修复工具使用指导