搭建HWI(HiveWebInterface)步驟總結


  眾所周知,Hive有三種使用方式:CLI、HWI瀏覽器、Thrift客戶端。安裝配置完Hive后無需進行額外操作即可使用CLI。但是HWI則需要單獨搭建。本文主要記錄我自己搭建HWI的過程。

  說明:本文主要介紹HWI的安裝,后續會完成下面兩篇博文:

  • HWI的介紹
  • HWI的使用

  本博主主要是記錄自己的學習內容,有哪些理解不到位的地方還請各位讀者提出寶貴意見。

簡單查看hwi使用

  在命令行輸入:

hive --service hwi --help

  輸出內容如下,給出了HWI的使用方法。

Usage ANT_LIB=XXXX hive --service hwi

  在命令行輸入

hive --service hwi 

  報錯,報錯信息如下:

cannot access /home/linux/application/hive2.1.0/lib/hive-hwi-*.war: No such file or directory

報錯原因:lib下面沒有war包,查找各種資料都提示需要從官網下載hive源代碼src文件然后打包web文件夾的war文件。

搭建HWI

打包war文件

  • 下載src文件地址:http://apache.fayea.com/hive/hive-2.1.0/   PS:選擇自己的版本
  • 解壓src文件:tar -xzf  apache-hive-2.1.0-src.tar.gz
  • 進入web文件夾:cd apache-hive-2.1.0-src/hwi/web
  • 打包war文件:jar  -xcf hive-hwi-2.1.0.war *
  • 把war復制到${HIVE_HOME}/bin目錄:cp hive-hwi-2.1.0.war ${HIVE_HOME}/bin/
  • 根據官網配置hive hwi,步驟如下:
    • cd ${HIVE_HOME}/conf
    • vim hive-site.xml
    • 添加的配置信息如下:
<property>  
<name>hive.hwi.listen.host</name>
  <value>0.0.0.0</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>
<property>
  <name>hive.hwi.war.file</name>
  <value>${HIVE_HOME}/lib/hive-hwi-<version>.war</value>
  <description>This is the WAR file with the jsp content forHive Web Interface</description>
</property>

 安裝ANT

HWI需要用Apache的ANT來編譯,因此需要安裝ANT。

Apache Ant is a Java library and command-line tool that help building software.

ANT的安裝及配置步驟

  • 下載ANT下載地址:https://www.apache.org/dist/ant/binaries/
  • 解壓:unzip apache-ant-1.9.7-bin.zip
  • 重命名:mv apache-ant-1.9.7 ant1.9.7   PS:該步驟可以省略,重命名只是為了使用簡短方便
  • 建立軟連接:ln -s ant1.9.7 ant    PS:該步是為了方便在不同版本之間切換測試方便
  • 配置環境變量:vim /etc/profile

    export ANT_HOME=/opt/ant
    export PATH=$PATH:$ANT_HOME/bin

  • 使profile生效:source /etc/profile
  • 驗證ant是否安裝成功:ant -version

嘗試啟動HWI

  在命令行輸入下面的命令,目的是為了啟動相關服務。

hive --service hwi

  在瀏覽器中輸入 localhost:9999/hwi。一直刷不出網頁,我又把配置文件中hive.hwi.war.file的Value值改為:lib/hive-hwi-2.1.0.war (使用相對路徑),然后刷新頁面又報錯如下:

Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK

  出錯原因:${HIVE_HOME}/lib下沒有tools.jar所致。把JAVA安裝目錄下的tools.jar包復制到${HIVE_HOME}/lib,命令如下:

cp ${JAVA_HOME}/lib/tools.jar ${HIVE_HOME}/lib

  再次刷新localhost:9999/hwi又如下錯誤:

The following error occurred while executing this line:
jar:file:/home/linux/application/hive2.1.0/lib/ant-1.9.1.jar!/org/apache/tools/ant/antlib.xml:37: Could not create task or type of type: componentdef.

Ant could not find the task or a class this task relies upon.

This is common and has a number of causes; the usual 
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file: 
- You have misspelt 'componentdef'.
Fix: check your spelling.
- The task needs an external JAR file to execute
and this is not found at the right place in the classpath.
Fix: check the documentation for dependencies.
Fix: declare the task.
- The task is an Ant optional task and the JAR file and/or libraries
implementing the functionality were not found at the time you
yourself built your installation of Ant from the Ant sources.
Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the
task and make sure it contains more than merely a META-INF/MANIFEST.MF.
If all it contains is the manifest, then rebuild Ant with the needed
libraries present in ${ant.home}/lib/optional/ , or alternatively,
download a pre-built release version from apache.org
- The build file was written for a later version of Ant
Fix: upgrade to at least the latest release version of Ant
- The task is not an Ant core or optional task 
and needs to be declared using <taskdef>.
- You are attempting to use a task defined using 
<presetdef> or <macrodef> but have spelt wrong or not 
defined it at the point of use

Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the
classpath

Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.

  根據錯誤信息,${HIVE_HOME}/lib下的ant.jar版本為1.9.1,但是我裝的ant版本為1.9.7,因此該錯誤是因為版本不一致導致的。因此,需要把${ANT_HOME}/lib下的ant.jar包copy到${HIVE_HOME}/lib下,並修改權限為777。使用的命令如下:

cp ${ANT_HOME}/lib/ant.jar  ${HIVE_HOME}/lib/ant-1.9.7.jar
cd ${HIVE_HOME}/lib
chmod 777 ant-1.9.7.jar

 再次啟動HWI 

此時可以把原服務關掉,重新啟動服務,命令為:hive --service hwi,並在瀏覽器中輸入:localhost:9999/hwi,多刷新幾次即可。說明:localhost可能是你的主機名或IP。

HWI的界面如下:

 

 參考官網:https://cwiki.apache.org/confluence/display/Hive/HiveWebInterface

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM