学习笔记Hive—— Hive安装配置
Posted 别呀
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了学习笔记Hive—— Hive安装配置相关的知识,希望对你有一定的参考价值。
一、环境介绍
环境 | 描述 |
---|---|
4个Linux操作系统虚拟机 | 使用centos7镜像配置 |
安装java | 1.8以上版本 |
安装Hadoop | 2.6.5以上版本 |
安装mysql | 5.1以上版本 |
二、安装MySQL
(这里我是CentOs7)
安装教程链接:https://www.jb51.net/article/150557.htm
1、安装完成后,启动mysql
直接在终端输入:mysql
2、执行以下命令为root用户设置权限
use mysql;
delete from user where 1=1;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
FLUSH PRIVILEGES;
三、安装Hive
Hive安装教程: https://blog.csdn.net/Shockang/article/details/118062872
四、测试:Hive单词计数
hive –e Hive语句
hive –f Hive脚本
准备一个text.txt和wordcount.hql文件(均放入/opt目录下)
text.txt
I am a student
I learn hadoop
I learn MapReduce
wordcount.hql
drop table if exists words;
create table words(textline string);
load data local inpath '/opt/test.txt' into table words;
set hive.cli.print.header=true;
select word,count(*) as wordcount from (select explode(split(textline," ")) as word from words) tmp group by word;
执行wordcount.hql:
hive -f wordcount.hql
结果:
![](https://image.cha138.com/20211022/1e3b8aac8d0240419379ad1890882514.jpg)
以上是关于学习笔记Hive—— Hive安装配置的主要内容,如果未能解决你的问题,请参考以下文章