Hive 3.1.3 在执行初始化配置命令
bin/schematool -dbType derby -initSchema
的时候报下方错误
[root@hadoop100 hive-3.1.3]# bin/schematool -dbType derby -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/module/hive-3.1.3/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.1.3/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]
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357)
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338)
at org.apache.hadoop.mapred.JobConf.setJar(JobConf.java:518)
at org.apache.hadoop.mapred.JobConf.setJarByClass(JobConf.java:536)
at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:430)
at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:5144)
at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:5107)
at org.apache.hive.beeline.HiveSchemaTool.<init>(HiveSchemaTool.java:96)
at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1473)
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:318)
at org.apache.hadoop.util.RunJar.main(RunJar.java:232)
这是因为hadoop和hive的两个guava.jar版本不一致,解决方案:
删除低版本的那个,将高版本的复制到低版本目录下文章来源:https://www.toymoban.com/news/detail-401246.html
- 第一步:查看hive3.1.3里的guava.jar
这个保存在hive的lib里,比如我的就在这个目录里面:
/opt/module/hive-3.1.3/lib
版本是 guava-19.0.jar
- 第二步:查看hadoop3.1.3 里的guava.jar
这个保存在hadoop3.1.3的这个目录里面:
/opt/module/hadoop-3.1.3/share/hadoop/common/lib
文章来源地址https://www.toymoban.com/news/detail-401246.html
- 第三步:对比hive3.1.3里面和hadoop3.1.3里面guava的版本,统一换成高版本
- 第四步:将hive3.1.3里面guava的版本,换成hadoop3.1.3里面的高版本即可
# 将hive3.1.3里面的guava重命名即可,不需要删除
mv guava-19.0.jar guava-19.0.jar_bak
# 将hadoop3.1.3里面的guava拷贝到hive3.1.3里面一份
cp /opt/module/hadoop-3.1.3/share/hadoop/common/lib/guava-27.0-jre.jar
- 第五步:重新执行初始化命令
[root@hadoop100 hive-3.1.3]# bin/schematool -dbType derby -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/module/hive-3.1.3/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.1.3/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:derby:;databaseName=metastore_db;create=true
Metastore Connection Driver : org.apache.derby.jdbc.EmbeddedDriver
Metastore connection User: APP
Starting metastore schema initialization to 3.1.0
Initialization script hive-schema-3.1.0.derby.sql
Initialization script completed
schemaTool completed
[root@hadoop100 hive-3.1.3]#
到了这里,关于Hive初始化报错Exception in thread “main“ java.lang.NoSuchMethodError: com.google.common.base.Precondition的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!