一、 测试组件版本
测试用例使用版本如下:
apache-hive-2.1.1
hadoop-2.7.4
hbase-1.3.0-bin
jdk-8u181-linux-x64
二、 Hive配置
Hive配置安装之前需要先正确安装Hadoop和HBase,安装过程不在说明。
1. 配置环境变量
解压hive安装包到指定路径,然后配置环境变量
修改 /etc/profile 文件 :
# Hive environment
1. export HIVE_HOME=/usr/local/apache-hive-2.1.1-bin
2. export PATH=$HIVE_HOME/bin:$HIVE_HOME/conf:$PATH
使环境变量生效:
source /etc/profile
2.修改hive配置文件
- a) 将hbase配置文件hbase-site.xml复制到hive的配置文件目录中
cp /usr/local/hbase-1.3.0/conf/hbase-site.xml /usr/local/apache-hive-2.1.1-bin/conf/
- b) 修改hive-site.xml
Hive切换到HBase作为metastore存储,需要注意修改此处,更改rawstore的实现类:
1. <property>
2. <name>hive.metastore.rawstore.impl</name>
3. <value>org.apache.hadoop.hive.metastore.hbase.HBaseStore</value>
4. <description>
5. Name of the class that implements org.apache.hadoop.hive.metastore.rawstore interface.
6. This class is used to store and retrieval of raw metadata objects such as table, database
7. </description>
8. </property>
配置hive.metastore.warehouse.dir
参数指定了 Hive 的数据存储目录,默认位置在 HDFS 上面的 /user/hive/warehouse 路径下。
1. <property>
2. <name>hive.metastore.warehouse.dir</name>
3. <value>/user/hive/warehouse</value>
4. <description>location of default database for the warehouse</description>
5. </property>
然后再hdfs中创建配置的目录文件夹。
- c) 修改hive-env.sh
- export JAVA_HOME=/usr/java/jdk1.8.0_181-amd64
- # Set HADOOP_HOME to point to a specific hadoop install directory
- HADOOP_HOME=/usr/local/hadoop-2.7.4
- # Hive Configuration Directory can be controlled by:
- export HIVE_CONF_DIR=/usr/local/apache-hive-2.1.1-bin/conf
- # Folder containing extra ibraries required for hive compilation/execution can be controlled by:
- export HIVE_AUX_JARS_PATH=/usr/local/apache-hive-2.1.1-bin/lib
- d) 修改 io.tmpdir 路径
修改 hive-site.xml 中所有包含 ${system:java.io.tmpdir} 字段的 value 更改为自己新建的目录。
3. 初始化HBaseMetaStore
使用hbaseschematool工具初始化HBase的metatore数据库。
1. hive --service hbaseschematool -i
初始化成功后HBase中应该创建了相应的hive元数据库表如下:
4. 启动hive metastore服务
1. hive --service metastore
5. 启动hive客户端
成功切换到HBase作为hive的metastore存储数据库。
以上配置流程主要强调hbase metastore的配置,其他根据hive需求进行配置。