大叔经验分享(133)hive元数据中location修复
作者:互联网
假如hive中table或者partition的location错误或者丢失,需要批量修复,可以参考如下步骤:
修复table的location
hdfs dfs -ls /data/hive/warehouse/$db | awk '{print $8}' |sed '1d' | awk -F '/' '{print "alter table "$5"."$7" set location ""$0"";"}'
输出的sql在hive中执行
修复partition的location
update DBS d, TBLS t, SDS ts, PARTITIONS p, SDS ps set ps.location = concat(ts.location, '/', p.part_name)
-> where d.db_id = t.db_id and t.sd_id = ts.sd_id and p.tbl_id = t.tbl_id and p.sd_id = ps.sd_id
-> and d.name = '$db';>
在hive元数据库中执行以上命令
确认修复
select * from $db.$table limit 10
标签:db,hive,133,location,table,id,sd 来源: https://www.cnblogs.com/barneywill/p/16289005.html