【发布时间】:2016-09-23 09:34:09
【问题描述】:
使用spark-1.6.0-bin-hadoop2.6 启动spark-shell 时出现错误。这是刚刚出现的新行为。
以下日志消息中显示的失败结果是 sqlContext 不可用(但 sc 可用)。
是否有某种可以释放的 Derby 锁? Another instance of Derby may have already booted the database /root/spark-1.6.0-bin-hadoop2.6/bin/metastore_db.
<console>:16: error: not found: value sqlContext
import sqlContext.implicits._
^
<console>:16: error: not found: value sqlContext
import sqlContext.sql
16/05/25 11:00:00 ERROR Schema: Failed initialising database.
Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@c2191a8, see the next exception for details.
org.datanucleus.exceptions.NucleusDataStoreException: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@c2191a8, see the next exception for details.
16/05/25 11:06:02 WARN Hive: Failed to access metastore. This class should not accessed in runtime.
org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
16/05/25 11:06:02 ERROR Schema: Failed initialising database.
Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@372e972d, see the next exception for details.
org.datanucleus.exceptions.NucleusDataStoreException: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@372e972d, see the next exception for details.
Caused by: java.sql.SQLException: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@c2191a8, see the next exception for details.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 134 more
Caused by: java.sql.SQLException: Another instance of Derby may have already booted the database /root/spark-1.6.0-bin-hadoop2.6/bin/metastore_db.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
... 131 more
Caused by: ERROR XSDB6: Another instance of Derby may have already booted the database /root/spark-1.6.0-bin-hadoop2.6/bin/metastore_db.
【问题讨论】:
-
是的,有一个 Derby 锁定文件可以防止两个不相关的应用程序尝试同时更新同一个嵌入式数据库。
-
修改或删除该文件以解决此问题是否有意义?
-
不,这会导致数据库损坏。正确的方法是弄清楚哪些是独立尝试同时打开同一个嵌入式数据库的两个应用程序,以及为什么它们都尝试同时运行。要么给他们各自的数据库,不要同时运行它们,要么重新配置您的系统,以便他们可以使用 Derby 服务器而不是 Derby 嵌入式数据库配置来共享数据库。
-
谢谢布莱恩。当 spark-shell 没有正常退出时(如在挂起的会话中),这似乎会发生,然后一个新会话调用 spark-shell。在这种情况下,有什么办法可以“重置”嵌入式数据库,即关闭挂起的连接?
-
当 Derby 以嵌入式模式运行时,Derby 代码直接在包含的 JVM 中运行。除了从该 JVM 中的 Java 代码之外,没有其他方法可以与 Derby 代码进行通信,并且无法在不停止包含的 JVM 的情况下停止 Derby 引擎。与数据库的“连接”完全在包含 JVM 的连接中。还有其他行为不同的 Derby 配置(例如,客户端-服务器),但对于嵌入式配置,这是现实情况。
标签: apache-spark derby