自学内容网 自学内容网

记录一下hive启动metestore服务时报错

【背景说明】

之前hadoop有问题,把hadoop和MySQL删了重装,hive没有动,然后启hive的metastore服务的时候,显示找不到metastore数据库

【报错】

Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.GeneratedConstructorAccessor74.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:606)
        at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:330)
        at org.datanucleus.store.AbstractStoreManager.registerConnectionFactory(AbstractStoreManager.java:203)
        at org.datanucleus.store.AbstractStoreManager.<init>(AbstractStoreManager.java:162)
        at org.datanucleus.store.rdbms.RDBMSStoreManager.<init>(RDBMSStoreManager.java:285)
        at sun.reflect.GeneratedConstructorAccessor73.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:606)
        at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:301)
        at org.datanucleus.NucleusContextHelper.createStoreManagerForProperties(NucleusContextHelper.java:133)
        at org.datanucleus.PersistenceNucleusContextImpl.initialise(PersistenceNucleusContextImpl.java:422)
        at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.freezeConfiguration(JDOPersistenceManagerFactory.java:817)
        ... 43 more
Caused by: org.datanucleus.exceptions.NucleusException: Attempt to invoke the "HikariCP" plugin to create a ConnectionPool gave an error : Failed to initialize pool: Unknown database 'metastore'
        at org.datanucleus.store.rdbms.ConnectionFactoryImpl.generateDataSources(ConnectionFactoryImpl.java:232)
        at org.datanucleus.store.rdbms.ConnectionFactoryImpl.initialiseDataSources(ConnectionFactoryImpl.java:117)
        at org.datanucleus.store.rdbms.ConnectionFactoryImpl.<init>(ConnectionFactoryImpl.java:82)
        ... 59 more
Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Unknown database 'metastore'
        at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:544)
        at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:536)
        at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:112)
        at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:72)
        at org.datanucleus.store.rdbms.connectionpool.HikariCPConnectionPoolFactory.createConnectionPool(HikariCPConnectionPoolFactory.java:176)
        at org.datanucleus.store.rdbms.ConnectionFactoryImpl.generateDataSources(ConnectionFactoryImpl.java:213)
        ... 61 more
Caused by: java.sql.SQLSyntaxErrorException: Unknown database 'metastore'
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
        at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:828)
        at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:448)
        at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241)
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
        at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:95)
        at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:101)
        at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:356)
        at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:199)
        at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:444)
        at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:515)

【原因】

我真是个傻子,重装以后要在MySQL初始化metastore元数据库

【解决】

3.3.1初始化元数据库
1)登陆MySQL。
[atguigu@hadoop102 conf]$ mysql -uroot -p000000
2)新建Hive元数据库。
mysql> create database metastore;
3)初始化Hive元数据库。
[atguigu@hadoop102 conf]$ schematool -initSchema -dbType mysql -verbose
4)修改元数据库字符集。
Hive元数据库的字符集默认为Latin1,由于其不支持中文字符,所以建表语句中如果包含中文注释,会出现乱码现象。如需解决乱码问题,须做以下修改。
修改Hive元数据库中存储注释的字段的字符集为utf-8。
(1)字段注释。
mysql> use metastore;
mysql> alter table COLUMNS_V2 modify column COMMENT varchar(256) character set utf8;
(2)表注释。
mysql> alter table TABLE_PARAMS modify column PARAM_VALUE mediumtext character set utf8;
5)退出mysql。
mysql> quit;
3.3.2启动Hive客户端
1)启动Hive客户端。
[atguigu@hadoop102 hive]$ hive
2)查看一下数据库。
hive (default)> show databases;
OK
database_name
default
Time taken: 0.955 seconds, Fetched: 1 row(s)

成功~


原文地址:https://blog.csdn.net/yuanlaishidahuaa/article/details/137930046

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!