hive常见问题解决。

以下问题及解决方法仅是个人在学习Hive过程中遇到并解决的,不一定适合所有人,请根据个人实际情况来解决。

 

问题1(hive-2.1.1):

Exception in thread "main" java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

这是因为从hive2.1开始,必须运行初始化命令,原文(Hive入门)是这么说的:

Starting from Hive 2.1, we need to run the schematool command below as an initialization step. For example, we can use "derby" as db type. 

 

$HIVE_HOME/bin/schematool -dbType <db type> -initSchema
 
因此,执行$schematool -initSchema -dbType mysql进行初始化,然后当看到以下信息:
Metastore connection URL:        jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:       hive
Starting metastore schema initialization to 2.1.0
Initialization script hive-schema-2.1.0.mysql.sql
Initialization script completed
schemaTool completed
表示初始化成功。

 

 

 

问题2(hive-2.1.1):

无法设置mysql为元数据库,执行命令schematool -initSchema -dbType mysql报错

org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
Underlying cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException : Communications link failure


Last packet sent to the server was 0 ms ago.
SQL Error code: 0
Use --verbose for detailed stacktrace.
*** schemaTool failed ***

 

检查$HIVE_HOME/bin/conf中的hive-site.xml配置文件。由于本人采用的是本地链接,将数据库链接value值修改为如下所示:

<property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
        <description>JDBC connect string for a JDBC metastore</description>
 </property>

 

 

问题3(hive-2.1.1):

在Hive下,可以执行部分命令,比如create table,Load data等。但是某些命令执行不了,比如drop table等。然后导致原来能执行的命令比如create table等页执行不了了。

 

如下所示:

 

hive> create table if not exists test6(name string,age int);
OK
Time taken: 0.285 seconds
hive> drop table test5;
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:You have an 


error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 


'OPTION SQL_SELECT_LIMIT=DEFAULT' at line 1)
hive> show tables;
FAILED: SemanticException [Error 10072]: Database does not exist: default
hive> create table if not exists test7(name string,age int);
FAILED: IllegalStateException Unxpected Exception thrown: Unable to fetch table test7. You have an error in your SQL 


syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION 


SQL_SELECT_LIMIT=DEFAULT' at line 1
hive> 

 

这应该是mysql驱动的问题所致。本人原来使用的是mysql-connector-java-5.1.6-bin.jar,换成mysql-connector-java-5.1.41-bin.jar就可以了。

 

问题4(hive-2.1.1):

 

启动Hive时提示

Mon Mar 27 21:28:11 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 


5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the 


verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for 


server certificate verification.

解决方法:修改hive-site.xml,将连接URL的value设置成如下所示

 

<property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false</value>
        <description>JDBC connect string for a JDBC metastore</description>
</property>

 

 

问题5(hive-2.1.1):

 

 

 

Hive启动时,提示如下信息:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/apache-hive-2.1.1-bin/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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]

 

这是jar包冲突了,删除hive中$HIVE_HOME/lib下面的log4j-slf4j-impl-2.4.1.jar包即可。

 

千万不要删除hadoop下面的,否则调用shell 脚本start-all.sh远程启动hadoop时会报找不到log4j包的错误。

 

问题6(hive-1.2.1)

启动hive报错:

 

ls: 无法访问'/usr/local/spark-2.1.0-bin-hadoop2-without-hive/lib/spark-assembly-*.jar': 没有那个文件或目录

 

这个问题是在使用hive on spark时候发生的。因为hive默认的引擎是MR,但是性能比不上spark。因此就使用了hive on spark。当然

前提是先装上spark。我装的是spark-2.1.0(no hive)。

 

从spark-2.0.0开始,原有lib目录下的大JAR包被分散成多个小JAR包,原来的spark-assembly-*.jar已经不存在,所以hive没有办法找到这个JAR包。解决方法是修改${HIVE_HOME}/bin/hive文件,将

 

sparkAssemblyPath=`ls ${SPARK_HOME}/lib/spark-assembly-*.jar`  改成

 

 

sparkAssemblyPath=`ls ${SPARK_HOME}/jars/*.jar`

 

问题7:

 

HIve:beeline终端上在输错hive语句时,无论 Backspace还是delete 都删除不掉错误的语句,没有办法退格

 

通过SecureCRT工具连上linux后,通过beeline连接上hive后,在输错hive语句时,无论 Backspace还是delete 都删除不掉错误的语句,没有办法退格。

解决方案:

第一步:SecureCRT菜单选项栏中"选项(O)"-》"会话选项(S)...",点击打开:

第二步:在“会话窗口”中,修改找到“终端”》“仿真”,修改 终端(T) 为 Linux

问题8:

在Ambari安装的hive中。

执行load data local inpath '/root/alert_group.txt' into table alert_group;

报错:
Error: Error while compiling statement: FAILED: SemanticException Line 1:23 Invalid path ''/root/alert_group.txt'': No files matching path file:/root/alert_group.txt (state=42000,code=40000)。

首先确定hiveserver2安装在哪个节点,并将文件上传到该节点的/tmp/hive目录下(该目录属于hive用户)。

原理都一样,无论是ambari还是apache的hive,从本地导入数据到hive表中,首先得是该节点下要有文件,然后确定文件存放目录所属用户的权限问题。

问题9:

hive执行hql语句时,有很多INFO信息,可以关闭它。

方法1:在启动hive的cli命令行时关闭,但只是暂时关闭

[root@Master ~]# hive --hiveconf hive.server2.logging.operation.level=NONE

方法2:永久关闭。在hive中的hive-site.xml中配置hive.server2.logging.operation.enabled属性为false

 

  • 4
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值