有一个表,其后备hdfs文件不再存在。现在的问题是“drop table”命令失败:
Failed to load metadata for table: db.mytable
Caused by TAbleLoadingException: Failed to load metadata for table: db.mytable
File does not exist: hdfs://....
Caused by FileNotFoundException: File does not exist: hdfs:// ..
答案 0 :(得分:4)
您可以将位置更改为有效的位置,然后将其删除。
alter table mytable set location 'hdfs://valid/path';
drop table mytable;
这是一个例子
root@*****]# /opt/hive/bin/hive -e "create external table test (a string) ";
OK
Time taken: 0.822 seconds
[root@*****]# /opt/hive/bin/hive -e "desc extended test";
OK
a string
Detailed Table Information Table(tableName:test, dbName:default, owner:root, createTime:1459611644, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:a, type:string, comment:null)], location:hdfs://ec2-23-20-175-171.compute-1.amazonaws.com:8020/user/hive/warehouse/test, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[], skewedColValueLocationMaps:{}), storedAsSubDirectories:false), partitionKeys:[], parameters:{EXTERNAL=TRUE, transient_lastDdlTime=1459611644}, viewOriginalText:null, viewExpandedText:null, tableType:EXTERNAL_TABLE)
Time taken: 0.587 seconds, Fetched: 3 row(s)
销毁hadoop集群然后尝试删除表...
[root@*****]# /opt/hive/bin/hive -e "drop table test";
命令在日志中挂起以下内容:
2016-04-02 11:44:33,677 INFO [pool-4-thread-3]: ipc.Client (Client.java:handleConnectionFailure(666)) - Retrying connect to server: ec2-23-20-175-171.compute-1.amazonaws.com/23.20.175.171:8020. Already tried 3 time(s).
将位置设置为有效的
[root@*****]# /opt/hive/bin/hive -e "alter table test set location 's3n://*****/test'";
OK
Time taken: 0.807 seconds
再次尝试删除表
[root@*****]# /opt/hive/bin/hive -e "drop table test";
OK
Time taken: 1.097 seconds