Spark-shell 报错:Failed to get database default, returning NoSuchObjectException

Spark-shell 执行sql查询报错:
20/08/24 15:33:59 WARN metastore.ObjectStore: Failed to get database default, returning NoSuchObjectException
20/08/24 15:34:03 ERROR metastore.RetryingHMSHandler: AlreadyExistsException(message:Database default already exists)

在百度搜了很多解决方案,一点用没有,fq 找到了解决办法:
这个是因为没有在Spark配置hive的配置文件,把hive配置的hive-site.xml 文件拷贝到 spark 目录下即可

> mv hive/conf/hive-site.xml  spark/conf/hive-site.xml

这样就解决了。

另外一个问题:
报错:
Caused by: java.lang.reflect.InvocationTargetException: org.datanucleus.exceptions.NucleusException: Attempt toinvoke the "BONECP" plugin to create a ConnectionPool gave an error : The specified datastore driver ("com.mysql.jdbc.Driver") was not found in the CLASSPATH. Please check your CLASSPATH specification, and the name of the driver.

这个问题从字面意思上很容易看到,是因为jdbc的driver连接不上,需要依赖 mysql-connector 的jar包。
mysql-connector 这个jar包在 hive 的lib 目录下,spark 存放jia包的路径是在 jars目录下,
所以执行:

> mv hive/lib/mysql-connector-java-5.1.44-bin.jar  spark/jars/mysql-connector-java-5.1.44-bin.jar

这样就可以了,然后再重启spark-shell,就可以正常查询hive里面的表了。

posted @ 2020-08-25 10:48  水木青楓  阅读(5075)  评论(0编辑  收藏  举报