Hive提供了三种用户接口:CLI、HWI和客户端方式。其中最常用的的就是CLI,CLI启动的时候,会同时启动一个Hive副本。Client是Hive的客户端,用户连接至Hive Server。在启动 Client模式的时候,需要指出Hive Server所在节点,并且在该节点启动Hive Server。 HWI是通过浏览器访问Hive。本文介绍Hive Web访问接口。
启动 hwi :
#hive --service hwi
ls:cannot access/home/hadoopUser/cloud/hive/apache-hive-0.13.1-bin/lib/hive-hwi-*.war: No suchfile or directory
报错误的原因是,Hive目前的发行包里没有hwi的war包文件,没有这个war包就不能启动hwi服务。
1、终端启动HWI服务
http://apache.fayea.com/hive/ 下载apache-hive-1.2.1-src.tar.gz 源码包,然后解压:
# tar -zxvf apache-hive-1.2.1-src.tar.gz
# cd hwi/
# pwd
/usr/local/apache-hive-1.2.1-src/hwi
# jar cvfM0 hive-hwi-1.2.1.war -C web/ .
# ll
total 164
-rw-r--r-- 1 root root 151343 Nov 26 18:29 hive-hwi-1.2.1.war
-rw-rw-r-- 1 root root 4982 Jun 19 2015 pom.xml
drwxrwxr-x 4 root root 4096 Apr 30 2015 src
drwxrwxr-x 5 root root 4096 Nov 26 18:21 web
2、将生成的hive-hwi-1.2.1.war拷贝到/usr/local/hive/lib/
3、在hive-site.xml中添加HWI配置:
<property>
<name>hive.hwi.war.file</name>
<value>lib/hive-hwi-1.2.1.war</value>
<description>This sets the path to the HWI war file, relative to ${HIVE_HOME}. </description>
</property>
<property>
<name>hive.hwi.listen.host</name>
<value>centos1</value>
<description>This is the host address the Hive Web Interface will listen on</description>
</property>
<property>
<name>hive.hwi.listen.port</name>
<value>9999</value>
<description>This is the port the Hive Web Interface will listen on</description>
</property>
4、启动:
#hive --service hwi
#hive --service metastore
注:不管是使用HiveCLI、客户端还是HWI访问Hive,都需要首先启动Hive 元数据服务,否则无法访问Hive数据库。
5、访问:

注:启动时可能会报错,Unable to find a javaccompiler;com.sun.tools.javac.Main is not on the classpath.Perhaps JAVA_HOMEdoes not point to the JDK.It is currently set to