ubuntu16.04 本地安装hive

前提条件 安装hadoop

1.下载hive2.3.3
2.创建hive文件夹
sudo mkdir /usr/share/hive
3.解压hive
sudo tar -zxvf apache-hive-2.3.3-bin.tar.gz -C /usr/share/hive
4.下载mysql-connector-java-5.1.46.tar.gz
sudo tar -zxvf mysql-connector-java-5.1.46.tar.gz
cd mysql-connector-java-5.1.46
cp mysql-connector-java-5.1.46-bin.jar  /usr/share/hive/apache-hive-2.3.3-bin/lib/
5.配置环境变量
# hive2.3.3 environment
export HIVE_HOME=/usr/share/hive/apache-hive-2.3.3-bin
export PATH=$PATH:$HIVE_HOME/bin
#保存退出 :wq
6.配置mysql
#进入mysql
mysql -u root -p
#回车后输入数据库密码
create database hive;
grant all privileges on hive.* to root@localhost identified by '设置密码' with grant option;
flush privileges;
exit
7.配置hive的conf
cd /usr/share/hive/apache-hive-2.3.3-bin
sudo mkdir warehouse
cd /usr/share/hive/apache-hive-2.3.3-bin/conf
sudo vim hive-site.xml

<configuration>
<property>
    <name>hive.metastore.schema.verification</name>
    <value>false</value>
     <description>
          Enforce metastore schema version consistency.
          True: Verify that version information stored in metastore matches with one from Hive jars.  Also disable automatic
          schema migration attempt. Users are required to manully migrate schema after Hive upgrade which ensures
          proper metastore schema migration. (Default)
          False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
      </description>
    </property>
    <!-- 存储在hdfs上的数据路径 -->
    <property>
        <name>hive.metastore.warehouse.dir</name>
        <value>/user/hive/warehouse</value>
        <description>location of default database for the warehouse</description>
    </property>
    <!-- 本地mysql -->
    <property>
        <name>hive.metastore.local</name>
        <value>true</value>
    </property>
    <property>
       <name>javax.jdo.option.ConnectionURL</name>
       <value>jdbc:mysql://localhost: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.ConnectionPassword</name>
       <value>你mysql的hive数据密码</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>root</value>
        <description>Username to use against metastore database</description>
     </property>
</configuration>
#保存退出:wq
cd /usr/share/hive/apache-hive-2.3.3-bin/conf
cp hive-env.sh.template hive-env.sh
8.初始化hive的数据库
cd /usr/share/hive/apache-hive-2.3.3-bin/bin
schematool  -dbType mysql -initSchema
schematool  -dbType mysql -info
9.运行
hive --service metastore
    原文作者:WJXZ
    原文地址: https://www.jianshu.com/p/d966c8179554
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞