一、HDFS安装
1、解压到指定位置tar -zxvf apache-hive-3.1.2-bin.tar.gz -C /usr/local/apps/
2、改名mv apache-hive-3.1.2-bin/ hive-3.1.2
3、在·conf·目录下添加Hadoop安装路径mv hive-env.sh.template hive-env.sh
# 配置HADOOP_HOME路径
export HADOOP_HOME=/opt/module/hadoop-2.7.2
# 配置HIVE_CONF_DIR路径
export HIVE_CONF_DIR=/opt/module/hive/conf
4、环境变量vi /etc/profile
,source /etc/profile
#Hive
export HIVE_HOME=/usr/local/apps/hive-3.1.2
export PATH=$PATH:$HIVE_HOME/bin
export HIVE_CONF_DIR=$HIVE_HOME/conf
二、将Hive元数据配置到MySql
Hive Metastore服务将Hive表和分区的元数据存储在关系数据库中,并使用metastore服务API向客户端(包括Hive)提供对此信息的访问。 Metastore默认存储在自带的derby数据库中,推荐使用MySQL存储Metastore;
1、解压驱动包tar -zxvf mysql-connector-java-5.1.49.tar.gz
2、驱动拷贝cp mysql-connector-java-5.1.49-bin.jar /usr/local/apps/hive-3.1.2/lib
3、vim hive-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://Carlota1:3306/metastore?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false</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>root</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
<description>password to use against metastore database</description>
</property>
</configuration>
4、元数据初始化schematool -initSchema -dbType mysql
5、测试启动bin/hive
Logging initialized using configuration in jar:file:/usr/local/apps/hive-3.1.2/lib/hive-common-3.1.2.jar!/hive-log4j2.properties Async: true Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases. Hive Session ID = adfa8414-e92f-4208-b0fb-9d5e483e342d hive>