1. 程式人生 > >hive-2.1.1安裝部署

hive-2.1.1安裝部署

hive介紹、理解相關,參考:

http://www.aboutyun.com/thread-20461-1-1.html

http://blog.csdn.net/lifuxiangcaohui/article/details/40145859

https://mp.weixin.qq.com/s?__biz=MzIzODExMDE5MA==&mid=2694182433&idx=1&sn=687b754cddc7255026434c683f487ac0#rd

http://blog.csdn.net/wangmuming/article/details/25226951

二. 安裝部署

hive安裝需要使用mysql,所以先需要有一可用的mysql資料庫。 下載安裝包後,將該壓縮包解壓在 /home/bigdata/run目錄下 (ubuntu1)目錄下:
[email protected]
:~/download$ tar -zxvf apache-hive-2.1.1-bin.tar.gz
[email protected]:~/download$ mv apache-hive-2.1.1-bin ../run/
[email protected]:~/run$ ln -s apache-hive-2.1.1-bin hive

三.修改配置檔案

hive-env.sh檔案內容如下:
[email protected]:~/run/hive/conf$ cat hive-env.sh
......
export JAVA_HOME=/home/bigdata/usr/jdk1.8.0_131
export HADOOP_HOME=/home/bigdata/run/hadoop
export HIVE=/home/bigdata/run/hive

hive-site.xml檔案中,修改如下內容:
<configuration>
    <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://master:3306/hive?createDatabaseInfoNotExist=true</value> 
        <description>JDBC connect string for a JDBC metastore</description>
    </property>

    <property>
            <name>javax.jdo.option.ConnectionDriverName</name>
            <value>com.mysql.jdbc.Driver</value>
            <description>Driver class name for a JDBC metastore</description>
    </property>

    <property>
            <name>javax.jdo.option.ConnectionUserName</name>
            <value>mysql_username</value>
            <description>Username to use against metastore database</description>
    </property>

    <property>
            <name>javax.jdo.option.ConnectionPassword</name>
            <value>mysql_password</value>
            <description>password to use against metastore database</description>
    </property>

</configuration>
下載mysql-connector-java-5.5-bin.jar檔案驅動包,並放到$HIVE_HOME/lib目錄下 啟動Hive
[email protected]:~/run/hive/bin$ ./hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/bigdata/run/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:/home/bigdata/run/hadoop-2.7.3/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]

Logging initialized using configuration in file:/home/bigdata/run/apache-hive-2.1.1-bin/conf/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> 


Hive的web頁面hwi安裝

安裝hwi頁面
wget https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-2.1.1/apache-hive-2.1.1-src.tar.gz
tar -zxvf apache-hive-2.1.1-src.tar.gz
cd apache-hive-2.1.1-src/hwi/web
jar -cvf hive-hwi-2.1.1.war *
mv hive-hwi-2.1.1.war /home/bigdata/run/hive/lib/
修改hive-site.xml中,hwi相關配置
<property>    
<name>hive.hwi.listen.host</name>    
<value>0.0.0.0</value>  
</property>  

<property>  
<name>hive.hwi.listen.port</name>   
<value>9999</value> 
 </property> 

 <property>   
<name>hive.hwi.war.file</name>  
<value>lib/hive-hwi-2.1.1.war</value>
 </property>
複製tools.jar
不知道為什麼,從很久以前的版本就有這個問題。找tools.jar一直找不到,所以需要手動複製一下:
cp ${JAVA_HOME}/lib/tools.jar ${HIVE_HOME}/lib 安裝ant
[email protected]:~/download$ wget https://mirrors.tuna.tsinghua.edu.cn/apache//ant/binaries/apache-ant-1.10.1-bin.tar.gz
[email protected]:~/download$ tar -zxvf apache-ant-1.10.1-bin.tar.gz 
[email protected]:~/download$ mv apache-ant-1.10.1 ../run/
[email protected]:~/download$ cd ../run/
[email protected]:~/run$ ln -s apache-ant-1.10.1 ant
[email protected]:~/run$ cp apache-ant-1.10.1/lib/ant.jar hive/lib/ant-1.10.1.jar

新增ant相關環境變數
[email protected]:~/run$ cat ~/.profile 
......
export ANT_HOME=/home/bigdata/run/ant
export PATH=$PATH:$ANT_HOME/bin

啟動hwi
[email protected]:~/run/hive/bin$ ./hive --service hwi &

訪問頁面: http://10.3.19.171:9999/hwi


hive建立表報錯"Specified key was too long; max key length is 767 bytes" 解決方法:
mysql > alter database hive character set latin1;
參考: http://blog.csdn.net/keljony/article/details/43371995 http://www.cnblogs.com/h2-database/archive/2011/12/06/2583296.html

參考:http://www.cnblogs.com/xing901022/p/5827165.html