图解shell命令运行Hadoop1.2的WordCount例子

[b][color=green][size=x-large]在hadoop1.2.x的版本中,直接运行自带的WordCount的例子会报异常,这个原因是因为它路径的问题,所以,想要正常运行自带的例子,我们还是需要做一些准备工作的,当然你可以直接在eclipse中修改它的源码然后重新编译,再运行,这样一来比较麻烦,特别是对一些刚学习的朋友来说,在eclipse配置个hadoop也许都得折腾半天,所以本篇,散仙会介绍使用shell命令的改变它的编译路径,并重新打包,然后执行,作用跟eclipse改源码一样,但是步骤会很简洁。

下面散仙进入正题,在这之前,确保你的Hadoop的环境已经可以正常工作,如果不懂得怎么部署安装hadoop,那么没关系,可以参考散仙的前几篇博客进行部署。

[/size][/color][/b]
[b][color=green][size=x-large]总结一下,总共需要这5步来完成,如一下截图(散仙的hadoop是直接root的根目录下的)

第一步
[/size][/color][/b]

[img]http://dl2.iteye.com/upload/attachment/0090/8404/2286f6a9-aa17-314d-8856-023cef141090.jpg[/img]
[b][color=green][size=x-large]第二步[/size][/color][/b]

[img]http://dl2.iteye.com/upload/attachment/0090/8406/f58fe0bb-59c3-3c92-a1de-039d1808a652.jpg[/img]
[b][color=green][size=x-large]第三步[/size][/color][/b]

[img]http://dl2.iteye.com/upload/attachment/0090/8408/eacf5808-83c3-321c-a422-61da8c0c8475.jpg[/img]
[b][color=green][size=x-large]第四步[/size][/color][/b]

[img]http://dl2.iteye.com/upload/attachment/0090/8412/5686d333-e532-3bf6-9d3d-d642376d7d10.jpg[/img]
[b][color=green][size=x-large]第五步[/size][/color][/b]

[img]http://dl2.iteye.com/upload/attachment/0090/8414/4f276a07-8d3b-3488-94ca-9fa6ae15efa3.jpg[/img]
[b][color=olive][size=x-large]下面是散仙进行测试的文本文件,内容截图如下:[/size]
[/color][/b]

[img]http://dl2.iteye.com/upload/attachment/0090/8416/bd5e64e8-432c-34b4-9e81-6c612220d3bc.jpg[/img]
[b][color=olive][size=x-large]向HDFS上上传测试文件[/size]
[/color][/b]

[img]http://dl2.iteye.com/upload/attachment/0090/8418/50378987-4c65-39b9-93d7-78b983b267c2.jpg[/img]

[b][color=olive][size=x-large]向Hadoop提交作业[/size]
[/color][/b]
[img]http://dl2.iteye.com/upload/attachment/0090/8420/e0ed97ff-aac9-3846-9b71-5e8593045e34.jpg[/img]

[b][color=olive][size=x-large]查看输出效果[/size][/color][/b]

[img]http://dl2.iteye.com/upload/attachment/0090/8422/0a383439-56d3-37fa-9609-8b1feb1a599b.jpg[/img]

[b][color=olive][size=x-large]网页上的输出效果[/size][/color][/b]
[img]http://dl2.iteye.com/upload/attachment/0090/8424/89d400d9-76ff-3a25-a7c0-267afff0457a.jpg[/img]

[b][color=green][size=x-large]至此,我们已经可以完美运行WordCount的例子了,注意几点第一,编译的路径不要写错。第二,在上传文件进行测试时候,一定要关闭防火墙,否则会报异常的,关闭命令service iptables stop 。[/size][/color][/b]

你可能感兴趣的:(Hadoop)