记录一下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)

成功~

相关推荐
花菜回锅肉2 小时前
【数据仓库】hadoop3.3.6 安装配置
数据仓库·hadoop
weixin_307779132 小时前
阿里云电商平台用户行为分析与人群画像系统设计与实现
数据仓库·阿里云·云计算
DashVector6 小时前
如何通过HTTP API更新Doc
数据库·数据仓库·人工智能·http·向量检索
大数据魔法师14 小时前
hdfs命令(三)- hdfs 管理命令(一)- hdfs cacheadmin命令
大数据·hadoop·hdfs
轻风细雨18 小时前
hive-sql 连续登录五天的用户
hive·hadoop·sql
xfcloud19 小时前
Hadoop HA安装配置(容器环境),大数据职业技能竞赛模块A平台搭建,jdk+zookeeper+hadoop HA
大数据·hadoop·分布式
ADFVBM20 小时前
Python大数据可视化:基于Python的王者荣耀战队的数据分析系统设计与实现_flask+hadoop+spider
hadoop·python·flask
喻师傅1 天前
数据仓库工具箱—读书笔记02(Kimball维度建模技术概述05、处理缓慢变化维度SCD属性)
数据仓库
幽兰的天空1 天前
Servlet中映射与部署
大数据·hadoop·servlet