經過hadoop上的hive完成WordCountmysql
啓動hadoopsql
cd /usr/local/hadoop ./sbin/start-dfs.sh cd /usr/local/hive/lib service mysql start start-all.sh
Hdfs上建立文件夾oop
hdfs dfs -mkdir test
hdfs dfs -ls /user/hadoop
上傳文件至hdfsspa
hdfs dfs -put ./test.txt test
hdfs dfs -ls /user/hadoop/test
啓動Hivecode
建立原始文檔表blog
hive
create table docs(line string)
導入文件內容到表docs並查看hadoop
load data inpath '/user/hadoop/tese1/test.txt' overwrite into table docs
select * from docs
用HQL進行詞頻統計,結果放在表word_count裏文檔
create table word_count as select word,count(1) as count from (select explode(split(line," ")) as word from docs) word group by word order by word;
查看統計結果string
show tables;
select * from word_count;