Hive连接mysql驱动,初始化Hive元数据

一、背景:

需求:需要上传Hive连接mysql的驱动,进行Hive元数据初始化

驱动一:Hive连接datagrip的驱动路径+驱动名称:D:\hive-jdbc-3.1.2-standalone.jar

驱动二:Hive连接mysql的驱动+驱动名称:D:\mysql-connector-java-5.1.32.jar

二、现象

上传驱动:错误上传成①的驱动,

然后对Hive的元数据进行初始化,显示如下报错:

[root@node1 lib]# rz
rz waiting to receive.
Starting zmodem transfer.  Press Ctrl+C to cancel.
Transferring hive-jdbc-3.1.2-standalone.jar...
  100%   70722 KB    23574 KB/sec    00:00:03       0 Errors  

[root@node1 lib]# cd /export/server/apache-hive-3.1.2-bin/
[root@node1 apache-hive-3.1.2-bin]# bin/schematool -initSchema -dbType mysql -verbos
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/export/server/apache-hive-3.1.2-bin/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/export/server/hadoop-3.3.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:        jdbc:mysql://node1:3306/hive3?createDatabaseIfNotExist=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:       root
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
Underlying cause: java.lang.ClassNotFoundException : com.mysql.jdbc.Driver
Use --verbose for detailed stacktrace.
*** schemaTool failed ***

三、解决

1.初始化失败了,思路:

    ①优先判断配置的用户名密码是否正确                  

    ②地址写的对不对,驱动写的对不对

2.报错分析:

    ①hive.metastore元数据  HiveMetaException配置单元元异常   Failed to load driver  未能成功加载驱动

    ②Underlying cause根本原因 java.lang 语言太长了   ClassNotFoundException类未找到异常  com.mysql.jdbc.Driver (mysql驱动)

3.小结:

    ①显示驱动未加载成功,但是我们上面上传驱动显示是成功的,所以说明上传没问题,传错了。

    ②显示mysql的驱动显示异常,就说明Hive连接mysql驱动出现异常,说明在Hive驱动,因为mysql驱动我们没动。

 四、拓展:

当我们加载错驱动了,这个时候驱动时可以共存的,但是课程中讲解是只用这一个驱动,所以,想想办法删掉这个驱动吧!

①找到这个驱动的放置的文件夹

[root@node1 lib]# pwd
/export/server/apache-hive-3.1.2-bin/lib
[root@node1 lib]# 

②找到错误装上去的驱动,将这个驱动删除

rm -rf hive-jdbc-3.1.2-standalone.jar

③继续加载二的驱动,初始化后显示成功

[root@node1 lib]# rz
rz waiting to receive.
Starting zmodem transfer.  Press Ctrl+C to cancel.
Transferring mysql-connector-java-5.1.32.jar...
  100%     946 KB     946 KB/sec    00:00:01       0 Errors  

[root@node1 lib]# cd /export/server/apache-hive-3.1.2-bin
[root@node1 apache-hive-3.1.2-bin]# bin/schematool -initSchema -dbType mysql -verbos
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/export/server/apache-hive-3.1.2-bin/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/export/server/hadoop-3.3.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:        jdbc:mysql://node1:3306/hive3?createDatabaseIfNotExist=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:       root
Starting metastore schema initialization to 3.1.0
Initialization script hive-schema-3.1.0.mysql.sql


Initialization script completed
schemaTool completed

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值