MENU

Hive启动报错 Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient解决方法总结

January 23, 2019 • Read: 504 • 资源教程阅读设置

Hive启动时报错,内容如下:

Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62                                                                                             )
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl                                                                                             .java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.                                                                                             metadata.SessionHiveMetaStoreClient
        at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.j                                                                                             ava:1523)
        at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.<init>(RetryingMeta                                                                                             StoreClient.java:86)
        at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMe                                                                                             taStoreClient.java:132)
        at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMe                                                                                             taStoreClient.java:104)
        at org.apache.hadoop.hive.ql.metadata.Hive.createMetaStoreClient(Hive.java:3005                                                                                             )
        at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:3024)
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:503)
        ... 8 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces                                                                                             sorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc                                                                                             torAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.j                                                                                             ava:1521)
        ... 14 more
Caused by: javax.jdo.JDOException: Exception thrown calling table.exists() for hive.`SE                                                                                             QUENCE_TABLE`
NestedThrowables:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long;                                                                                              max key length is 767 bytes
        at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(                                                                                             NucleusJDOHelper.java:596)
        at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersisten                                                                                             ceManager.java:732)
        at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceM                                                                                             anager.java:752)
        at org.apache.hadoop.hive.metastore.ObjectStore.setMetaStoreSchemaVersion(Objec                                                                                             tStore.java:6773)
        at org.apache.hadoop.hive.metastore.ObjectStore.checkSchema(ObjectStore.java:66                                                                                             70)
        at org.apache.hadoop.hive.metastore.ObjectStore.verifySchema(ObjectStore.java:6                                                                                             645)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62                                                                                             )
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl                                                                                             .java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.hive.metastore.RawStoreProxy.invoke(RawStoreProxy.java:114                                                                                             )
        at com.sun.proxy.$Proxy6.verifySchema(Unknown Source)
        at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.getMS(HiveMetaStor                                                                                             e.java:572)
        at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.createDefaultDB(Hi                                                                                             veMetaStore.java:624)
        at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.init(HiveMetaStore                                                                                             .java:461)
        at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandle                                                                                             r.java:66)
        at org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy(RetryingHMSHand                                                                                             ler.java:72)
        at org.apache.hadoop.hive.metastore.HiveMetaStore.newRetryingHMSHandler(HiveMet                                                                                             aStore.java:5768)
        at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreCli                                                                                             ent.java:199)
        at org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient.<init>(Session                                                                                             HiveMetaStoreClient.java:74)
        ... 19 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was                                                                                              too long; max key length is 767 bytes
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces                                                                                             sorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc                                                                                             torAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
        at com.mysql.jdbc.Util.getInstance(Util.java:408)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2482)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2440)
        at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:845)
        at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:745)
        at com.jolbox.bonecp.StatementHandle.execute(StatementHandle.java:254)
        at org.datanucleus.store.rdbms.table.AbstractTable.executeDdlStatement(Abstract                                                                                             Table.java:760)
        at org.datanucleus.store.rdbms.table.AbstractTable.executeDdlStatementList(Abst                                                                                             ractTable.java:711)
        at org.datanucleus.store.rdbms.table.AbstractTable.create(AbstractTable.java:42                                                                                             5)
        at org.datanucleus.store.rdbms.table.AbstractTable.exists(AbstractTable.java:48                                                                                             8)
        at org.datanucleus.store.rdbms.valuegenerator.TableGenerator.repositoryExists(T                                                                                             ableGenerator.java:242)
        at org.datanucleus.store.rdbms.valuegenerator.AbstractRDBMSGenerator.obtainGene                                                                                             rationBlock(AbstractRDBMSGenerator.java:86)
        at org.datanucleus.store.valuegenerator.AbstractGenerator.obtainGenerationBlock                                                                                             (AbstractGenerator.java:197)
        at org.datanucleus.store.valuegenerator.AbstractGenerator.next(AbstractGenerato                                                                                             r.java:105)
        at org.datanucleus.store.rdbms.RDBMSStoreManager.getStrategyValueForGenerator(R                                                                                             DBMSStoreManager.java:2005)
        at org.datanucleus.store.AbstractStoreManager.getStrategyValue(AbstractStoreMan                                                                                             ager.java:1386)
        at org.datanucleus.ExecutionContextImpl.newObjectId(ExecutionContextImpl.java:3                                                                                             827)
        at org.datanucleus.state.JDOStateManager.setIdentity(JDOStateManager.java:2571)

        at org.datanucleus.state.JDOStateManager.initialiseForPersistentNew(JDOStateMan                                                                                             ager.java:513)
        at org.datanucleus.state.ObjectProviderFactoryImpl.newForPersistentNew(ObjectPr                                                                                             oviderFactoryImpl.java:232)
        at org.datanucleus.ExecutionContextImpl.newObjectProviderForPersistentNew(Execu                                                                                             tionContextImpl.java:1414)
        at org.datanucleus.ExecutionContextImpl.persistObjectInternal(ExecutionContextI                                                                                             mpl.java:2218)
        at org.datanucleus.ExecutionContextImpl.persistObjectWork(ExecutionContextImpl.                                                                                             java:2065)
        at org.datanucleus.ExecutionContextImpl.persistObject(ExecutionContextImpl.java                                                                                             :1913)
        at org.datanucleus.ExecutionContextThreadedImpl.persistObject(ExecutionContextT                                                                                             hreadedImpl.java:217)
        at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersisten                                                                                             ceManager.java:727)
        ... 37 more

解决方法汇总:

首先请认真检查conf文件夹下的配置信息,确认无误后尝试以下方法:

  1. hive的版本过高导致的问题,请检查Hive和hadoop版本是有对应关系的:http://hive.apache.org/downloads.html
    如版本过高请尝试降低版本
  2. 需要hive元数据库初始化,执行下面命令初始化即可,我就是这个问题。
schematool -dbType mysql -initSchema
  1. HIVE_HOME/lib 下的derby-10.11.1.1.jar问题,,把derby-10.11.1.1.jar 换成derby-10.10.2.0.jar问题成功解决。