Hive的安装配置,
Hive在大数据中占有很重要的地位,他作为HDFS中的数据引擎,把sql语句转化为MapReduce程序,提交到hadoop中执行。对于没有接触过大数据的开发人员来说,只要会普通的sql语句就可以很方便的来操作HDFS。在使用HUE的web操作工作台中,可以很容易的开发出复杂的Hive语句,实现一系列的功能。
准备
tar -zxvf apache-hive-2.3.0-bin.tar.gz -C ~/training
设置环境变量
HIVE_HOME=/root/training/apache-hive-2.3.0-bin
export HIVE_HOME
PATH=$HIVE_HOME/bin:$PATH
export PATH
核心配置文件:conf/hive-site.xml 。
Hive在官网中有两种安装模式,嵌入模式和本地模式(Local/Embeddeb / Remote Metastore database)
https://cwiki.apache.org/confluence/display/Hive/AdminManual+Metastore+Administration
1、嵌入模式
(*)不需要MySQL的支持,使用Hive的自带的数据库Derby
(*)局限:只支持一个连接
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby:;databaseName=metastore_db;create=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>org.apache.derby.jdbc.EmbeddedDriver</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>file:///root/training/apache-hive-2.3.0-bin/warehouse</value>
</property>
</configuration>
初始化Derby数据库
schematool -dbType derby -initSchema
日志
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.
2、本地模式、远程模式:需要MySQL
(*)重新创建hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?useSSL=false</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hiveowner</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>Welcome_1</value>
</property>
</configuration>
(*)将mysql的jar包放到lib目录下
注意一定要使用高版本的MySQL驱动(5.1.43以上的版本)
(*)初始化MySQL
(*)老版本:当第一次启动HIve的时候 自动进行初始化
(*)新版本:schematool -dbType mysql -initSchema
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Initialization script completed
schemaTool completed
Hive启动