本篇文章主要介紹Hive的搭建,由於公司環境要求,這裏選擇的是hive-1.2.1。安裝Hive之前必須安裝MySQL,因爲這裏Hive的元數據是保存在MySQL中的。Hive在任一節點安裝即可。
1、下載安裝包,並解壓
下載地址
解壓命令如下:
2、配置/etc/profile
export HIVE_HOME=/home/hadoop/app/hive/apache-hive-1.2.1-bin
export PATH=$HIVE_HOME/bin:$PATH
3、配置hive-env.sh
進入/home/hadoop/app/hive/apache-hive-1.2.1-bin/conf目錄,修改配置文件:
# Set HADOOP_HOME to point to a specific hadoop install directory
export HADOOP_HOME=/home/hadoop/app/hadoop/hadoop-2.6.5
# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/home/hadoop/app/hive/apache-hive-1.2.1-bin/conf
# Folder containing extra libraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=/home/hadoop/app/hive/apache-hive-1.2.1-bin/lib
4、配置hive-site.sh
<configuration>
<!-- WARNING!!! This file is auto generated for documentation purposes ONLY! -->
<!-- WARNING!!! Any changes you make to this file will be ignored by Hive. -->
<!-- WARNING!!! You must make your changes in hive-site.xml instead. -->
<!-- Hive Execution Parameters -->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.129.13:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
</configuration>
5、複製mysql的驅動程序mysql-connector-java-5.0.8-bin.jar到/home/hadoop/app/hive/apache-hive-1.2.1-bin/lib目錄
6、初始化元數據(在此之前需要在MySQL下創建hive數據庫)
./bin/schematool -initSchema -dbType mysql
7、複製hive lib目錄下jline-2.12.jar文件到/home/hadoop/app/hadoop/hadoop-2.6.5/share/hadoop/yarn/lib目錄,並刪除目錄下原有的jline文件
8、測試hive
9、問題
原因:因爲沒有初始化數據庫,hive元數據保存在mysql中,因此依賴於mysql的執行。在hive的根目錄執行./bin/schematool -dbType mysql -initSchema 即可