问题:在hive中运行 show table时,以前存在的表显示不出来,而在hdfs上表的信息存储正常。
解决:到metastore_db目录所在的目录 运行命令,则显示正常。
原因:
hive使用内建的derby存储方式时,运行hive会在当前目录 生成一个derby文件和一个metastore_db目录。在别的目录下运行hive又会生成新的metastore_db目录。hive可以有多个不同的metastore_db实例,这些实例在不同的目录下存储的信息业不相关联。
这种存储方式的弊端是在同一个目录下 同时只能有一个hive客户端能使用数据库,否则会提示如下错误(这是一个很常见的错误)。
FAILED: Error in metadata: javax.jdo.JDOFatalDataStoreException: Failed to start database 'metastore_db', see the next exception for details.
NestedThrowables:
java.sql.SQLException: Failed to start database 'metastore_db', see the next exception for details.
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask