你好,游客 登录 注册 搜索
背景:
阅读新闻

C++ Hadoop实战备忘

[日期:2013-03-05] 来源:Linux社区  作者:segen_jaa [字体:大 中 小]

3、运行编译文件

make

4、上传运行程序到hdfs

Hadoop fs -mkdir bin

hadoop fs -put wordcount bin

5、准备测试文件

sudo gedit myfile.txt

文件内容:1 2 3 4 5 6 7 8 9 10 11 12 13。

6、上传测试文件

hadoop fs -mkdir input

hadoop fs -put myfile.txt input

7、编写配置文件

sudo gedit job_config.xml

<?xml version="1.0"?>
<configuration>
<property>
 <name>mapred.job.name</name>
 <value>WordCount</value>
</property>

<property>
 <name>mapred.reduce.tasks</name>
 <value>10</value>
</property>

<property>
 <name>mapred.task.timeout</name>
 <value>180000</value>
</property>

<property>
 <name>hadoop.pipes.executable</name>
 <value>/user/hadoop/bin/wordcount</value>
 <description> Executable path is given as"path#executable-name"
                sothat the executable will havea symlink in working directory.
                This can be used for gdbdebugging etc.
 </description>
</property>

<property>
 <name>mapred.create.symlink</name>
 <value>yes</value>
</property>

<property>
 <name>hadoop.pipes.java.recordreader</name>
 <value>true</value>
</property>

<property>
 <name>hadoop.pipes.java.recordwriter</name>
 <value>true</value>
</property>
</configuration>

8、运行任务

hadoop fs -rmr output

hadoop pipes -conf job_config.xml -input input/myfile.txt -output output -program bin/wordcount

9、查看结果

hadoop fs -ls output

hadoop fs -cat output/part-00000

hadoop fs -cat output/part-00001

结果格式如下

    1 1
    12 1
    13 1
    2 1
    3 1
    4 1
    5 1

更多Hadoop相关信息见Hadoop 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=13

linux
相关资讯       Hadoop实战 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款