hive基本不需要配置什么,他本身可以找/etc/profile中的HADOOP_HOME与JAVA_HOME
本人用的是hadoop2.7.1 hive-1.2.1
配置的是分布式集群安装完hive后出现了如下错误
root@tarzan:/usr/local/hive/bin# ./hive Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/hadoop/hive/conf/HiveConf at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:274) at org.apache.hadoop.util.RunJar.run(RunJar.java:214) at org.apache.hadoop.util.RunJar.main(RunJar.java:136) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hive.conf.HiveConf at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) … 4 more |
很明显NoClassDefFoundError错误是没有找到某个东西的(
JVM在编译的时候能找到调用方法或静态变量所在的类,但在运行的时候找不到此类而引发的错误。
)
解决方法有三种:
1.配置hadoop中hadoop_env.sh 配置HADOOP_CLASSPATH=XXX/hive/lib/*.jar(该配置只能配一个,配置多个报错,如果有nutch等的软件,需要注释掉原来的HADOOP_CLASSPATH)
2.直接把hive中的jar放入hadoop/lib中
3.修改/etc/profile
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HIVE_HOME/lib/*
三种方法选一即可
搞定之后又报了一个新错 crying~~
[ERROR] Terminal initialization failed; falling back to unsupported java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected at jline.TerminalFactory.create(TerminalFactory.java:101) at jline.TerminalFactory.get(TerminalFactory.java:158) at jline.console.ConsoleReader.<init>(ConsoleReader.java:229) at jline.console.ConsoleReader.<init>(ConsoleReader.java:221) at jline.console.ConsoleReader.<init>(ConsoleReader.java:209) at org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787) at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721) at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.hadoop.util.RunJar.run(RunJar.java:221) at org.apache.hadoop.util.RunJar.main(RunJar.java:136) Exception in thread “main” java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected |
删除位于hadoop/share/hadoop/yarn/lib/jline-0.9.94.jar 的 jline-0.9.94.jar 文件,如果没有jline的类似jar也报相同错那可以把hive/lib中的jline-2.12.jar复制进该目录中即可