问题:
输入
$bin/hadoop fs -mkdir hdfsInput
报错:
mkdir:'hdfsInput':No such file or directory
解决办法:使用绝对路径
后面最好都使用绝对路径,这样准确
$bin/hadoop fs -mkdir /hdfsInput
操作过程:
1.在本地创建两个文件file1 和file2
$echo "Hello world Bye world" >> ~/input file1
$echo "Hello world Bye world" >> ~/input file2
2.在HDFS上建立一个目录 hdfsInput
$bin/hadoop fs -mkdir /hdfsInput
3.将file1 和file2 拷贝到hdfsInput目录下
$bin/hadoop fs -put /home/hadoop/input/* /hdfsInput
4.执行wordcount
$bin/hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0.jar wordcount /hdfsInput /hdfsOut
5.查看结果
$bin/hadoop fs -ls /hdfsOut
6.查看输出文件内容
$bin/hadoop fs -cat /hdfsOut/part-r-00000