CentOS 7 + Hadoop 3.2 安装 Hive 3.1.2,启动hive报错

参考文档:https://www.cnblogs.com/caoxb/p/11333741.html

执行hive,报错

which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/java/jdk1.8/bin:/usr/local/java/jdk1.8/jre/bin:/usr/local/hadoop/hadoop-3.2.0/bin:/usr/local/hive/apache-hive-3.1.2-bin/bin:/root/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive/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:/usr/local/hadoop/hadoop-3.2.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]
Hive Session ID = xxx
Exception in thread "main" java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
	at org.apache.hadoop.hive.ql.session.SessionState.<init>(SessionState.java:413)
	at org.apache.hadoop.hive.ql.session.SessionState.<init>(SessionState.java:389)
	at org.apache.hadoop.hive.cli.CliSessionState.<init>(CliSessionState.java:60)
	at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:705)
	at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:683)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.hadoop.util.RunJar.run(RunJar.java:323)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:236)

博主一脸懵逼,以为是因为自己自以为是CentOS上面装了JDK11导致的,重新安装JDK8,还是没能解决,本来就在conf下面执行下面的命令

cp hive-default.xml.template hive-default.xml
touch hive-site.xml

hive-site.xml里面的内容为:



<configuration>
    
    
    <property>
        <name>javax.jdo.option.ConnectionUserNamename>
        <value>yournamevalue>
    property>
    
    <property>
        <name>javax.jdo.option.ConnectionPasswordname>
        <value>yourpasswordvalue>
    property>
    
    <property>
        <name>javax.jdo.option.ConnectionURLname>
        <value>jdbc:mysql://ip:3306/myhivevalue>
    property>
    
    <property>
        <name>javax.jdo.option.ConnectionDriverNamename>
        <value>com.mysql.cj.jdbc.Drivervalue>
    property>

configuration>

后来参考文档:https://www.cnblogs.com/weavepub/p/11130869.html

执行命令:

cp hive-log4j2.properties.template hive-log4j2.properties

就可以了,不知道为啥,发现打印的日志有一条

Logging initialized using configuration in file:/usr/local/hive/apache-hive-3.1.2-bin/conf/hive-log4j2.properties Async: true

无知诱惑我去验证是谁的锅,所以执行命令,改了hive-log4j2.properties的名字,看看错误会不会重现,来确定是不是hive-log4j2.properties的锅

mv hive-log4j2.properties hive-log4j2.properties.tmp

然而,还是能够执行,措手不及,日志变成这样子

Logging initialized using configuration in jar:file:/usr/local/hive/apache-hive-3.1.2-bin/lib/hive-common-3.1.2.jar!/hive-log4j2.properties Async: true

好吧,能力有限,实在不懂,我认为可能是因为没有参考官方文档,望引以为戒。官方文档在此

你可能感兴趣的:(大数据,hive,hadoop)