| 环境 | 描述 |
|---|---|
| 4个Linux操作系统虚拟机 | 使用centos7镜像配置 |
| 安装java | 1.8以上版本 |
| 安装Hadoop | 2.6.5以上版本 |
| 安装MySQL | 5.1以上版本 |
(这里我是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
结果:



