Apache Hive是一个建立在Hadoop架构之上的数据仓库。它能够提供数据的精炼,查询和分析。Hadoop之前已经安装好了(Hadoop database安装手册),本文主要描述如何安装配置hive。Hive框架如下图所示:

一、MySQL配置
Metastore(元数据存储)是一个独立的关系型数据库,Hive会在其中保存表模式和其他系统元数据,这里使用MySQL作为hive的元数据存储(metastore)。

root@mydb01 ~]# mysql -U smsqw -p
mysql> drop database metadb;
mysql> create database metadb;
mysql> grant all on metadb.* to smsqw@'%' identified by 'abcABC@12';
mysql> flush privileges; 

二、Hive安装配置
1、Hive下载与安装

hadoop@bdi:~$ cd /u01/software
hadoop@bdi:/u01/software$ wget http://mirrors.hust.edu.cn/apache/hive/stable-2/apache-hive-2.3.2-bin.tar.gz
hadoop@bdi:/u01/software$ cd ../
hadoop@bdi:/u01$ mv apache-hive-2.3.2-bin hive

2、Hive环境变量设置
编辑.bashr文件,加入以下内容:

hadoop@bdi:~$ vi .bashrc
export HIVE_HOME=/u01/hive
export PATH=$PATH:$HIVE_HOME/bin
export CLASSPATH=$CLASSPATH:/u01/hive/lib/*:.
hadoop@bdi:~$ source .bashrc

3、Hadoop上创建文件夹

hadoop@bdi:~$ hadoop fs -mkdir /tmp
hadoop@bdi:~$ hadoop fs -mkdir -p /user/hive/warehouse
hadoop@bdi:~$ hadoop fs -chmod g+w /tmp
hadoop@bdi:~$ hadoop fs -chmod g+w /user/hive/warehouse
hadoop@bdi:~$ hadoop fs -ls /
Found 3 items
drwxr-xr-x   - hadoop supergroup          0 2017-12-05 14:48 /hbase
drwxr-xr-x   - hadoop supergroup          0 2017-12-06 10:07 /user
drwxrwx---   - hadoop supergroup          0 2017-12-05 10:13 /tmp
hadoop@bdi:~$ hadoop fs -ls /user/hive
Found 1 items
drwxrwxr-x   - hadoop supergroup          0 2017-12-06 10:07 /user/hive/warehouse

4、配置Hive
编辑hive-env.sh文件,加入以下内容:

hadoop@bdi:~$ cd $HIVE_HOME
hadoop@bdi:/u01/hive/conf$ cp hive-env.sh.template hive-env.sh
hadoop@bdi:/u01/hive/conf$ vi hive-env.sh
......
export HADOOP_HOME=/u01/hadoop

创建hive-site.xml文件,修改内容如下:

hadoop@bdi:/u01/hive/conf$ cp hive-default.xml.template hive-site.xml
hadoop@bdi:/u01/hive/conf$ vi hive-site.xml


以上配置中包含了临时工作目录hive.exec.scratchdir,metastore的工作目录hive.metastore.warehouse.dir,以及存储Hive的元数据和表模式的MySQL数据库的配置。
另外创建一个临时目录,替换掉hive-site.xml的所有包含 ${system:Java.io.tmpdir} 字段的 value,即路径。否则,在执行hive命令时会报错,如下图所示:
hadoop@bdi:~$ mkdir $HIVE_HOME/iotmp
hadoop@bdi:~$ vi $HIVE_HOME/conf/hive-site.xml

5、初始化metastore schema
这里使用schematool离线工具来初始化,如下:

hadoop@bdi:/u01/hive/lib$ schematool -dbType mysql -initSchema -verbose
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/u01/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/u01/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:        jdbc:mysql://192.168.120.92:3306/metadb?useSSL=false
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:       smsqw
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Connecting to jdbc:mysql://192.168.120.92:3306/metadb?useSSL=false
Connected to: MySQL (version 5.7.20)
Driver: MySQL Connector Java (version mysql-connector-java-5.1.44 ( Revision: b3cda4f864902ffdde495b9df93937c3e20009be ))
Transaction isolation: TRANSACTION_READ_COMMITTED
......
0: jdbc:mysql://192.168.120.92:3306/metadb> !closeall
Closing: 0: jdbc:mysql://192.168.120.92:3306/metadb?useSSL=false
beeline>
beeline> Initialization script completed
schemaTool completed

6、Hive测试验证
到此,准备工作已经完成,接下来可以通过Hive CLI来验证配置是否正确。创建数据库以及表,并显示表的schema信息。

hadoop@bdi:~$ hive --service metastore &
hadoop@bdi:~$ hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/u01/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/u01/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]Logging initialized using configuration in jar:file:/u01/hive/lib/hive-common-2.3.2.jar!/hive-log4j2.properties Async: true
hive> show databases;
OK
default
Time taken: 5.321 seconds, Fetched: 1 row(s)
hive> create database if not exists hivedb;
OK
Time taken: 0.399 seconds
hive> create table hivedb.htb01 (id int,name string);
OK
Time taken: 0.23 seconds
hive> use hivedb;
OK
Time taken: 0.027 seconds
hive> show tables;
OK
htb01
Time taken: 0.037 seconds, Fetched: 1 row(s)
hive> show create table hivedb.htb01;
OK
CREATE TABLE `hivedb.htb01`(`id` int, `name` string)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION'hdfs://192.168.120.95:9000/user/hive/warehouse/hivedb.db/htb01'
TBLPROPERTIES ('transient_lastDdlTime'='1512562710')
Time taken: 0.215 seconds, Fetched: 13 row(s)

参考文献:
1、Hive Schema Tool
2、Tutorialspoint之Hive Installation
3、Hive常见问题汇总

Hive 2.3.2 Installation Guide相关推荐

  1. Symantec Backup Exec Remote Agent for Linux/Unix Servers Installation Guide

    Symantec Backup Exec Remote Agent for Linux/Unix Servers Installation Guide [root@test testdb]# scp ...

  2. RedHat Directory Server 8.2 Installation Guide

    RHDS是一套基于openldap的目录服务,当前可在官方下载的最新版本是8.2,不过下载下来的都是源代码rpm软件包,需要编译成二进制rpm软件包.我这里已经编译好了,总共12个软件包,已经包含了依 ...

  3. Greenplum installation guide

    Envireronment: VMware® Workstation 12 Pro 12.0.1 build-3160714(Host: Windows 7 Ultimate) Centos 6.5 ...

  4. Ubuntu Mint Installation Guide

    http://forum.ubuntu.org.cn/viewtopic.php?f=28&t=273647 喀纳斯Ubuntu 10.04中文定制版是由喀纳斯自由软件专卖店根据用户的需要制作 ...

  5. Arch Installation guide

    分区和挂载 parted /dev/sdamklabel gptmkpart ESP fat32 1M 513Mset 1 boot onmkpart primary ext4 513M 20.5Gm ...

  6. ligplot java jre_CentOS 6.4 software installation guide

    1: Gromacs 的安装 (1) 下载:gromacs(gromacs-4.63.tar)安装包和cmake(cmake-2.8.11.2.tar)安装包. (2)  安装cmake:    先解 ...

  7. Red Hat Enterprise MRG 2.0 Installation And Configuration Guide

    在红帽的云计算里,这个MRG也算是一个重要的部分.之前写过一篇使用Cobbler批量部署Linux操作系统,也是云计算的一部分.还有一个重点就是红帽的卫星网络(RHSAT),这个后续会补上来.等这三部 ...

  8. hive的hql怎么运行_在Ubuntu上安装Apache Hive并运行HQL查询

    hive的hql怎么运行 In this lesson, we will see how we can get started with Apache Hive by installing it on ...

  9. 达观数据分析平台架构和Hive实践

    http://www.infoq.com/cn/articles/hadoop-ten-years-part03 编者按:Hadoop于2006年1月28日诞生,至今已有10年,它改变了企业对数据的存 ...

最新文章

  1. 全国知名高校网站挂马现象严重 考生面临安全风险
  2. php tp 重加载页面,thinkPHP线上自动加载异常与修复方法实例分析
  3. 5 加盐_小葱拌豆腐的5种做法,收藏起来慢慢学!
  4. C语言振动排序shaker sort算法(附完整源码)
  5. spring四种依赖注入方式
  6. laraval如何使用tdd
  7. 字符数组和strcpy
  8. java 百度账号注册界面_基于百度AI使用H5实现调用摄像头进行人脸注册、人脸搜索功能(Java)...
  9. powershell自动化操作AD域、Exchange邮箱系列(1)——powershell 简介
  10. php unlink()函数使用
  11. 3D点云语义分割认知随便写写(更新中)
  12. 计算机科学导论第8章答案,第8章计算机科学导论.ppt
  13. 百度云无限速下载工具:JDownloader 2 for Mac
  14. 公网IP地址获取:移动网络IP、Wifi IP
  15. [Power--IC]电源管理IC-STNS01
  16. 大S《美容大王》内容80%都是没用的东西
  17. vue中控制浏览器滚动
  18. 商人渡河问题(MATLAB版)
  19. Feasibility of Learning
  20. APDL电磁仿真学习中可能会遇到的问题1

热门文章

  1. Android中四种补间动画的使用示例(附代码下载)
  2. SSM中通过Json做前后端分离
  3. 企业架构(三)——联邦企业架构框架(FEAF)
  4. flutter 实现不可滚动的ListView构建器
  5. 2 Redis基本知识
  6. 3、mybatis主配置文件之settings
  7. mysql 集群备份脚本_MysqlBackup
  8. 案例 | 锋芒易商如何做到年省 50 人天?
  9. 神策数据成为 Adjust 在中国首家数据分析合作伙伴
  10. 2017 企业服务创新大会启动,助力中国企业敏捷发展