问题描述:
Hive初始化是报错如下:
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:1380)
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1361)
at org.apache.hadoop.mapred.JobConf.setJar(JobConf.java:536)
at org.apache.hadoop.mapred.JobConf.setJarByClass(JobConf.java:554)
at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:448)
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)
问题原因:
执行初始化命令时发生报错是因为:hive和Hadoop的两个guava.jar的版本不一致:
hive:guava-19.0.jar
hadoop:guava-27.0-jre.jar
解决办法:
1.进入安装hive的文件夹,然后进入lib文件夹,删除里面的guava-19.0.jar
以我的安装路径为例:rm -f /export/server/hive/lib/guava-19.0.jar
2.把Hadoop里面的guava-27.0-jre.jar复制到hive的lib文件夹中
cp /export/server/hadoop/share/hadoop/common/lib/guava-27.0-jre.jar /export/server/hive/lib/guava-19.0.jar
前面的/export/server/hadoop是我的Hadoop安装路径