1、Hive安装地址
Hive官网地址:http://hive.apache.org/
文档查看地址:https://cwiki.apache.org/confluence/display/Hive/GettingStarted
下载地址:http://archive.apache.org/dist/hive/
github地址: https://github.com/apache/hive
2、Hive安装部署
2-1、Hive安装及配置
(1)把apache-hive-1.2.1-bin.tar.gz上传到linux的/opt/software目录下
(2)解压apache-hive-1.2.1-bin.tar.gz到/opt/module/目录下面
[root@hadoop100 software]# tar -zxvf apache-hive-1.2.1-bin.tar.gz -C /opt/software/module/
(3)修改apache-hive-1.2.1-bin.tar.gz的名称为hive
[root@hadoop100 software]# mv apache-hive-1.2.1-bin.tar.gz hive
(4)配置/etc/profile文件
[root@hadoop100 software]# vim /etc/profile
#HIVE_HONE
export HIVE_HOME=/opt/software/module/hive-1.2.1
export PATH=$JAVA_HOME/bin:$PATH:$HIVE_HOME/bin
[root@hadoop100 software]# source /etc/profile
2-2、Hadoop集群配置
(1)必须启动hdfs和yarn
[root@hadoop100 hadoop-2.7.2]# sbin/start-dfs.sh
[root@hadoop100 hadoop-2.7.2]# sbin/start-yarn.sh
(2)拷贝复制hive-env.sh.template文件重名hive-env.sh
[root@hadoop100 conf]# cp hive-env.sh.template hive-env.sh
编辑进入
HADOOP_HOME=/opt/hadoop/module/hadoop-2.7.2
需要把图片注释部分打开,并添加hadoop安装目录
继续编辑
export HIVE_CONF_DIR=/opt/software/module/hive-1.2.1/conf
下方图片中注释也要打开,指定配置信息文件夹路径
(3)启动hive
[root@hadoop100 bin]# hive
Logging initialized using configuration in jar:file:/opt/software/module/hive-1.2.1/lib/hive-common-1.2.1.jar!/hive-log4j.properties
2-3、Hive基本操作
(1)查看数据库
hive> show databases;
OK
default
Time taken: 1.053 seconds, Fetched: 1 row(s)
(2)打开默认数据库
hive> use default;
OK
Time taken: 0.04 seconds
(3)显示default数据库中的表
hive> show tables;
OK
Time taken: 0.057 seconds
(4)创建一张表
hive> create table student(id int, name string);
OK
Time taken: 0.735 seconds
(5)显示数据库中有几张表
hive> show tables;
OK
student