經過hadoop上的hive完成WordCountmysql
啓動hadoopsql
ssh localhost cd /usr/local/hadoop ./sbin/start-dfs.sh cd /usr/local/hive/lib service mysql start start-all.sh
Hdfs上建立文件夾ssh
hdfs dfs -mkdir test1
hdfs dfs -ls /user/hadoop
上傳文件至hdfsoop
hdfs dfs -put ./123.txt test1
hdfs dfs -ls /user/hadoop/test1
啓動Hivespa
hive
建立原始文檔表code
create table docs(line string)
導入文件內容到表docs並查看blog
load data inpath '/user/hadoop/tese1/123.txt' overwrite into table docs select * from docs
用HQL進行詞頻統計,結果放在表word_count裏hadoop
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;
查看統計結果文檔
show tables; select * from word_count;