Hive(HQL)数据库
Hive的特点
- Hive与SQL语句相像
- 能将SQL语句转变成MapReduce任务来执行
- Hive要依赖于yarn
- 只能用于结构化
- Hive只能处理离线数据,处理大型数据
Hive在集群上的操作
1.Hive安装及配置
(1)点击Shell,进入到 cd /opt/software目录下
cd /opt/software/
(2)把apache-hive-3.1.2-bin.tar.gz压缩包上传到Shell的 cd /opt/software目录下
(3)解压apache-hive-3.1.2-bin.tar.gz 到cd /opt/module/目录下
tar -zxvf /opt/software/apache-hive-3.1.2-bin.tar.gz -C /opt/module/
(4)修改apache-hive-3.1.2-bin.tar.gz 的名称为hive-3.1.2
mv apache-hive-3.1.2-bin/ hive-3.1.2
cd hive-3.1.2/
(5)修改/etc/profile.d/my_env.sh,添加环境变量
sudo vim /etc/profile.d/my_env.sh
(6)my_env.sh 添加的内容
#HIVE_HOME
export HIVE_HOME=/opt/module/hive
export PATH=$PATH:$HIVE_HOME/bin
(7)加载配置信息用source命令
source /etc/profile.d/my_env.sh
cd /lib
(8)解决日志jar包冲突:把log4j-slf4j-impl-2.10.0.jar 更名为log4j-slf4j-impl-2.10.0.bak
mv log4j-slf4j-impl-2.10.0.jar log4j-slf4j-impl-2.10.0.bak
ll (查看是否更名成功)
cd ..(退出至hive-3.1.2目录)
(9)初始化元数据库derby
bin/schematool -dbType derby -initSchema
(10)启动Hive,进入到Hive界面(HQL语句)
bin/hive
show databases; (展示数据库)
create database 'my_db'; (创建数据库)
show tables;
create table test (id int); (建表tset:表名,字段,字段类型)
show tables;
desc test; (看表描述信息)
insert into test values (1); (插入信息)
select * from test;