一、问题描述
安装好hive后执行初始化命令
[root@bigdata111 hive-3.1.2]# bin/schematool -dbType derby -initSchema
报错信息如下:
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:5141)
at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:5104)
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版本不一致
hive中版本为:guava-19.0.jar
hadoop中的版本为:guava-27.0-jre.jar
第一步:删除hive里的guava-19.0.jar
(1)先到hive的lib目录里
[root@bigdata111 hive-3.1.2]# cd lib/
(2)再用命令rm -fr 删除guava.jar
[root@bigdata111 lib]# rm -fr guava-19.0.jar
第二步:把hadoop里的guava-27.0-jre.jar
复制到hive里
(1)先到hadoop的lib目录里
[root@bigdata111 module]# cd hadoop-3.1.3/share/hadoop/common/lib/
(2)用cp指令复制到hive
[root@bigdata111 lib]# cp -r guava-27.0-jre.jar /opt/module/hive-3.1.2/lib/
第三步:回到hive, 再次执行初始化命令文章来源:https://www.toymoban.com/news/detail-690146.html
[root@bigdata111 hive-3.1.2]# bin/schematool -dbType derby -initSchema
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
可以发现问题完美解决!!!文章来源地址https://www.toymoban.com/news/detail-690146.html
到了这里,关于Hive初始化报错Exception in thread “main“ java.lang.NoSuchMethodError: com.google.common.base.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!