Hive1.2.1安裝筆記

weixin_34116110發表於2016-08-22

title: Hive1.2.1安裝筆記
date: 2016/8/22 0:47:36
tags: Hive
categories: 大資料


環境

ubuntu 16.04
4臺機器的Hadoop2.7.2叢集
Mysql安裝在slave2中
hive安裝在master上

下載Hive

$ wget http://mirrors.cnnic.cn/apache/hive/hive-1.2.1/apache-hive-1.2.1-bin.tar.gz
# 解壓
$ tar -zxvf apache-hive-1.2.1-bin.tar.gz /home/ubuntu/cloud

配置Hive環境變數

$ sudo vim /etc/profile

#新增
export HIVE_HOME=/home/ubuntu/cloud/apache-hive-1.2.1-bin
export PATH=$PATH:$HIVE_HOME/bin

$source /etc/profile

在Mysql中建立Hive使用者

mysql>CREATE USER 'hive' IDENTIFIED BY 'hive';
mysql>GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%' IDENTIFIED BY 'hive' WITH GRANT OPTION;
mysql>flush privileges;

建立Hive資料庫

$ mysql -uhive -phive
mysql>create database hive;

配置Hive

進入Hive的conf目錄,找到hive-default.xml.template,cp份為hive-site.xml

$ vim hive-site.xml
# 刪除configuration標籤裡的所有內容 新增如下內容

    <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://slave2:3306/hive?createDatabaseIfNotExist=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>hive</value>
        <description>username to use against metastore database</description>
    </property>
    <property>  
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>hive</value>
        <description>password to use against metastore database</description>  
    </property>          

下載mysql-connector-java-5.1.32-bin.jar

這裡用5.1.32版本測試不報錯,5.1.38會報warn

#將連線jar包拷貝到Hive的lib目錄
$ cp mysql-connector-java-5.1.32-bin.jar /home/ubuntu/cloud/apache-hive-1.2.1-bin/lib/

Hive啟動

要啟動metastore服務

$ hive --service metastore &
$ jps
10288 RunJar  #多了一個程式
9365 NameNode
9670 SecondaryNameNode
11096 Jps
9944 NodeManager
9838 ResourceManager
9471 DataNode

啟動hive命令列

ubuntu@master:~$ hive

Logging initialized using configuration in jar:file:/home/ubuntu/cloud/apache-hive-1.2.1-bin/lib/hive-common-1.2.1.jar!/hive-log4j.properties
hive> show tables;
OK
Time taken: 0.705 seconds

相關文章