学习笔记Hive—— Hive安装配置

Posted 别呀

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了学习笔记Hive—— Hive安装配置相关的知识,希望对你有一定的参考价值。

一、环境介绍

环境描述
4个Linux操作系统虚拟机使用centos7镜像配置
安装java1.8以上版本
安装Hadoop2.6.5以上版本
安装mysql5.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

结果:

以上是关于学习笔记Hive—— Hive安装配置的主要内容,如果未能解决你的问题,请参考以下文章

hive学习笔记

Hive学习笔记

学习笔记--HIVE网站日志统计分析

Hive 系统性学习笔记

Hive 系统性学习笔记

hive学习笔记_hive的介绍与安装