1. 程式人生 > >(4.1)搭建HWI(HiveWebInterface)步驟總結

(4.1)搭建HWI(HiveWebInterface)步驟總結

搭建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複製到HIVEHOME/bin目錄:cphive−hwi−2.1.0.warHIVEHOME/bin目錄:cphive−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:PATH:ANT_HOME/bin

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

嘗試啟動HWI

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

+ View Code

  在瀏覽器中輸入 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

  出錯原因:HIVEHOME/lib下沒有tools.jar所致。把JAVA安裝目錄下的tools.jar包複製到HIVEHOME/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.

  根據錯誤資訊,HIVEHOME/lib下的ant.jar版本為1.9.1,但是我裝的ant版本為1.9.7,因此該錯誤是因為版本不一致導致的。因此,需要把HIVEHOME/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的介面如下: