Hive-安装

Hive 官网地址:https://hive.apache.org/

文档查看地址:https://cwiki.apache.org/confluence/display/Hive/GettingStarted

下载地址:https://hive.apache.org/downloads.html & https://archive.apache.org/dist/hive/

Hadoop 2.x 版本要下载 Hive 2.x 或 1.x 的版本

Hadoop 3.x 版本要下载 Hive 3.x 的版本

一、下载

curl -o /opt/apache-hive-2.3.6-bin.tar.gz http://us.mirrors.quenda.co/apache/hive/hive-2.3.6/apache-hive-2.3.6-bin.tar.gz

tar -zxf /opt/apache-hive-2.3.6-bin.tar.gz -C /opt/

二、配置

hive-env.sh

cd /opt/apache-hive-2.3.6-bin/conf/
cp hive-env.sh.template hive-env.sh
vim hive-env.sh


# Set HADOOP_HOME to point to a specific hadoop install directory
# HADOOP_HOME=${bin}/../../hadoop
HADOOP_HOME=/opt/hadoop-2.9.2

# Hive Configuration Directory can be controlled by:
# export HIVE_CONF_DIR=
HIVE_CONF_DIR=/opt/apache-hive-2.3.6-bin/conf

hive-site.xml

cd /opt/apache-hive-2.3.6-bin/conf/
# 可配置项在 hive-default.xml.template 中查看
vim hive-site.xml

添加下面几项

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
  <property>
    <name>hive.metastore.schema.verification</name>
    <value>false</value>
  </property>
  <property>
    <name>hive.server2.webui.host</name>
    <value>0.0.0.0</value>
  </property>
  <property>
    <name>hive.server2.webui.port</name>
    <value>10002</value>
  </property>
</configuration>

环境变量

vim /etc/profile

export HIVE_HOME=/opt/apache-hive-2.3.6-bin
export PATH=$PATH:$HIVE_HOME/bin

source /etc/profile

三、启动

必须先启动 hdfs 和 yarn

start-dfs.sh
start-yarn.sh

初始化

cd /opt/apache-hive-2.3.6-bin/

# 使用 Hive 2.x 之前的版本,不做初始化元数据库也可以
# 使用 Hive 2.x 版本的,必须手动初始化元数据库
# 这里使用自带的 derby,也可以换成 MySQL
# 执行后会在当前目录下生成 derby.log(日志)和 metastore_db(元数据库)
schematool -dbType derby -initSchema

启动 Hive

cd /opt/apache-hive-2.3.6-bin/bin/

# hive --service metastore

# 启动 Hive
# 或 hive --service cli
hive
show databases;
quit;

启动 hiveserver2

cd /opt/apache-hive-2.3.6-bin/bin/

# 启动 Hive 自带的 WebUI,默认端口为 10002。
# hive --service hiveserver2
hiveserver2


https://cwiki.apache.org/confluence/display/Hive/GettingStarted#GettingStarted-InstallingHivefromaStableRelease

https://cwiki.apache.org/confluence/display/Hive/GettingStarted#GettingStarted-RunningHive

原文地址:https://www.cnblogs.com/jhxxb/p/11606842.html