您的位置:首页 > 运维架构

hadoop学习笔记003(感受上传到dfs和hadoop统计计算)

2017-10-19 22:10 260 查看
启动和停止hadoop常用命令

stop-all.sh

start-all.sh
start-dfs.sh


datanode没有启动成功,删除格式化日志

解决:
1)删除“/usr/hadoop/tmp”里面的内容
rm -rf /usr/hadoop/tmp/*
2)删除“/tmp”下以“hadoop”开头的文件
rm -rf /tmp/hadoop*
3)重新格式化hadoop
hadoop namenode -format
4)启动hadoop
start-all.sh


启动hadoop

hadoop fs -ls hdfs://localhost:9000/


将本文件放到dfs文件上

hadoop fs -put install.log.syslog hdfs://127.0.0.1:9000/


查看hadoop的dfs下根目录

hadoop fs -ls /


获取dfs上的文件刚才上传的文件

hadoop fs -get /install.log.syslog


======>初步实验

去到目录

/usr/mysoft/hadoop-2.4.0/share/hadoop/mapreduce

建目录

hadoop fs -mkdir /testdata
hadoop fs -mkdir /testdata/sample


准备的test.data数据

hello tom
hello jack
hello tangch
hello gogog
hello cat
hel baby
hello andy
hello redis
hel jack


将数据test.data上传到指定的/testdata/sample文件目录下

fs -put test.data /testdata/sample


统计词汇

hadoop jar hadoop-mapreduce-examples-2.4.0.jar wordcount /testdata/sample /testdata/output


去到结果目录

hadoop fs -ls /testdata/output


查看统计结果

hadoop fs -cat /testdata/output/part-r-00000


例子2

计算圆周率pi

hadoop jar hadoop-mapreduce-examples-2.4.0.jar pi 5 5
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐