前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >jar包在Hadoop集群上测试(MapReduce)

jar包在Hadoop集群上测试(MapReduce)

作者头像
栗筝i
发布2022-12-01 08:54:34
3230
发布2022-12-01 08:54:34
举报
文章被收录于专栏:迁移内容迁移内容

本片使用MapReduce——统计输出给定的文本文档每一个单词出现的总次数的案例进行,jar包在集群上测试

1、添加打包插件依赖

代码语言:javascript
复制
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.2</version>	//这里换成对应版本
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin </artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>com.lizhengi.mr.WordcountDriver</mainClass>  // 此处要换成自己工程的名字
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

2、更改WcDriver

代码语言:javascript
复制
FileInputFormat.setInputPaths(job, "/Users/marron27/test/input");
FileOutputFormat.setOutputPath(job, new Path("/Users/marron27/test/output"));

更改为

代码语言:javascript
复制
 FileInputFormat.setInputPaths(job, new Path(args[0]));
 FileOutputFormat.setOutputPath(job, new Path(args[1]));

3、将程序打成jar包,然后拷贝到Hadoop集群中

  • 选中maven工程
  • 选择Hadoop_API>>Lifecycle>>package
在这里插入图片描述
在这里插入图片描述

完成打包

4、修改不带依赖的jar包名称为wc.jar,并拷贝该jar包到Hadoop集群

  • mv Hadoop-API-1.0-SNAPSHOT.jar wc.jar
  • scp wc.jar root@Carlota1:/root/test/input

5、新建测试用例,并上传到HDFS

  • ssh root@Carlota1
  • hadoop fs -copyFromLocal hello.txt /demo/test/input

6、执行WordCount程序

  • hadoop jar wc.jar com.lizhengi.mapreduce.WcDriver /demo/test/input /demo/test/output
  • 这里我是遇到了一个卡在INFO mapreduce.Job: Running job: job_1595222530661_0003的问题,然后通过修改 mapred-site.xml解决
  • 执行结束后,下载结果到本地hadoop fs -copyToLocal /demo/test/output /root/test/output
  • cat /root/test/output part-r-00000
代码语言:javascript
复制
flume	2
hadoop	2
hdfs	1
hive	1
kafka	2
mapreduce	1
spark 	1
spring	1
take	2
tomcat		2
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-07-20,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档