java.sql.SQLException: Failed to start database ‘metastore_db‘ with class loader sun.misc.Launcher$A

本文介绍了解决Hive使用Derby作为元数据库时出现的问题,并提供了将元数据迁移到MySQL的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

详细报错信息如下:

2021-12-19T19:20:16,310 ERROR [cbeeba86-79bb-4066-8f66-3997efd02277 main] pool.HikariPool: HikariPool-1 - Exception during pool initialization.
java.sql.SQLException: Failed to start database 'metastore_db' with class loader sun.misc.Launcher$AppClassLoader@2c8d66b2, see the next exception for details.
        at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_212]
        at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.jdbc.InternalDriver$LoginCallable.call(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.jdbc.InternalDriver$LoginCallable.call(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_212]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_212]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_212]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: org.apache.derby.iapi.error.StandardException: Failed to start database 'metastore_db' with class loader sun.misc.Launcher$AppClassLoader@2c8d66b2, see the next exception for details.
        at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source) ~[derby-10.14.1.0.jar:?]
        ... 15 more
Caused by: org.apache.derby.iapi.error.StandardException: Another instance of Derby may have already booted the database /home/lqs/module/hive/metastore_db.
        at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.privGetJBMSLockOnDB(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.run(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_212]
        at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.getJBMSLockOnDB(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.boot(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.FileMonitor.startModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.store.raw.RawStore$6.run(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_212]
        at org.apache.derby.impl.store.raw.RawStore.bootServiceModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.store.raw.RawStore.boot(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.FileMonitor.startModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.store.access.RAMAccessManager$5.run(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_212]
        at org.apache.derby.impl.store.access.RAMAccessManager.bootServiceModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.store.access.RAMAccessManager.boot(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.services.monitor.FileMonitor.startModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.db.BasicDatabase$5.run(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_212]
        at org.apache.derby.impl.db.BasicDatabase.bootServiceModule(Unknown Source) ~[derby-10.14.1.0.jar:?]
        at org.apache.derby.impl.db.BasicDatabase.bootStore(Unknown Source) ~[derby-10.14.1.0.jar:?]

在这里插入图片描述
原因如下:
Hive默认使用的元数据库为derby,开启Hive之后就会占用元数据库,且不与其他客户端共享数据,所以我们需要将Hive的元数据地址改为MySQL。

#解决办法:
1、在Hive的安装目录下将derby.log和metastore_db删除,顺便将hdfs上目录删除

[lqs@bdc112 hive]$ rm -rf derby.log metastore_db
[lqs@bdc112 hive]$ hadoop fs -rm -r /user
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小雏菊的成长

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值