Mac上搭建Hadoop环境(3) — Hive下载及安装

前言

之前已经完成了hadoop集群的安装,测试了HDFS的使用,现在准备在此基础上,继续安装Hive。

主要步骤

  • 安装mysql
  • 安装hive
  • 配置hive

安装mysql

brew install mysql;

配置hive元数据库

mysql.server start 
mysql -uroot 
mysql> CREATE DATABASE hive;
mysql> USE hive;
mysql> CREATE USER 'hive'@'localhost' IDENTIFIED BY 'hive';
mysql> GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'localhost';

Hive安装

在Mac上我们可以利用Homebrew进行Hive的快速安装

brew update;
brew install hive;

我选择从官网下载压缩包进行安装,步骤如下

sudo tar -C /opt -xvf ~/Downloads/apache-hive-2.3.4-bin.tar.gz
mv apache-hive-2.3.4-bin hive
chown -R lestat:staff hive

设置环境变量

/etc/profile 中添加以下环境变量

#Hadoop Cluster
export HADOOP_HOME="/opt/hadoop"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home"
export HIVE_HOME="/opt/hive"
export PATH=$PATH:$HIVE_HOME/bin
export CLASSPATH=$CLASSPATH:$HIVE_HOME/lib

设置配置文件

cd $HIVE_HOME/libexec/conf
cp hive-env.sh.template hive-env.sh;
cp hive-default.xml.template hive-site.xml;

修改 hive-env.sh

export HADOOP_HEAPSIZE=1024
# Set HADOOP_HOME to point to a specific hadoop install directory
HADOOP_HOME=$HADOOP_HOME
# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/opt/hive/conf
# Folder containing extra ibraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=/opt/hive/lib

修改 hive-site.xml
首先在前面添加如下设置:


    system:java.io.tmpdir
    /tmp/


    system:user.name
    ${user.name}

然后修改相应设置



        javax.jdo.option.ConnectionUserName
        hive
    
    
        javax.jdo.option.ConnectionPassword
        hive
    
    
        javax.jdo.option.ConnectionURLmysql
        jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true
    
    
        javax.jdo.option.ConnectionDriverNamemysql驱动>程序
        com.mysql.jdbc.Driver
    

准备mysql-connector-java

cp ~/Downloads/mysql-connector-java-8.0.15.jar /opt/hive/lib/

初始化元数据

$HIVE_HOME/bin/schematool -dbType mysql -initSchema

启动metastore

$HIVE_HOME/bin/hive --service metastore &

测试

进入hive

show databases;

你可能感兴趣的:(Mac上搭建Hadoop环境(3) — Hive下载及安装)