hadoop基础操作

时间:2023-01-13 20:11:53

通过hadoop上的hive完成WordCount

启动hadoop

Hdfs上创建文件夹

上传文件至hdfs

启动Hive

创建原始文档表

导入文件内容到表docs并查看

用HQL进行词频统计,结果放在表word_count里

查看统计结果

start-all.sh
hdfs dfs -put ~/wordcount.txt input/wordcount.txt
hive > create database test02;
> create table test02(content string);
> load data inpath '/user/hadoop/input/wordcount.txt' into table test02;
> create table test03 as select word, count(1) as count from (select explode(split(regexp_replace(content, ',|\\.', ' ') , ' ')) as word from test02) word group by word;
> select * from test03;

结果显示:

hadoop基础操作