前提

系统:centos 7.3.1611

hadoop: 2.6.5

安装

hive版本:apache-hive-2.3.3-bin.tar.gz

解压tar包

tar -xzvf apache-hive-2.3.3-bin.tar.gz

配置环境变量

export HIVE_HOME=/data/apache-hive-2.3.3-bin
export HIVE_CONF_DIR=$HIVE_HOME/conf
export PATH=$HIVE_HOME/bin:$PATH

配置hive-site.xml

进入$HIVE_CONF_DIR

cp hive-default.xml.template hive-site.xml

hdfs配置

在hdfs中创建hive相关目录

hdfs dfs -mkdir -p /user/hive/warehouse
hdfs dfs -mkdir -p /tmp/hive
hdfs dfs -chmod -R 777 /user/hive/warehouse
hdfs dfs -chmod -R 777 /tmp/hive
hdfs dfs -chown -R hdfs:hdfs /user/hive/warehouse
hdfs dfs -chown -R hdfs:hdfs /tmp/hive

$HIVE_HOME 创建临时目录

cd $HIVE_HOME && mkdir tmp
chmod -R 777 tmp/

将hive-site.xml中的${system:java.io.tmpdir}替换为临时目录,将${system:user.name} 替换为root

属性 说明
hive.downloaded.resources.dir
hive.server2.logging.operation.log.location

数据库配置

hive默认的数据库是derby,现在替换为mysql

属性
javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver
javax.jdo.option.ConnectionURL jdbc:mysql://10.110.13.208:3307/hive?createDatabaseIfNotExist=true
javax.jdo.option.ConnectionUserName root
javax.jdo.option.ConnectionPassword 123456

将mysql驱动放到Hive的lib目录。

配置hive-env.sh

cp hive-env.sh.template hive-env.sh

配置环境变量

export HADOOP_HOME=/data/hadoop-2.6.5
export HIVE_CONF_DIR=/data/apache-hive-2.3.3-bin/conf
export HIVE_AUX_JARS_PATH=/data/apache-hive-2.3.3-bin/lib

启动

初始化mysql

cd $HIVE_HOME/bin
schematool -initSchema -dbTypemysql

启动hive

cd $HIVE_HOME/bin
./hive

results matching ""

    No results matching ""