在集群中执行打包的程MapReduce序
程序员文章站
2022-05-28 11:03:46
...
目录
一、配置pom.xml
用maven打jar包,需要添加的打包插件依赖,<mainClass>需要改成自己的工程主类
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.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.atguigu.mr.wordcount.WordcountDriver</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
二、程序的打包
1.点击View——>Maven
2.在Lifecycle -> package上右键,点击Run Maven Build
3.Build Success
后在target文件夹下会生成一个jar包,将之上传至服务器即可部署
三、集群的测试
1.启动集群
2.把jar包和输入文件放在linux下某个位置
3.在hdfs中上传输入文件
[aaa@qq.com hadoop-2.7.3]# hdfs dfs -mkdir -p /user/atguigu/input
[aaa@qq.com hadoop-2.7.3]# hdfs dfs -put /user/atguigu/input/hello.txt /user/atguigu/input
3.执行命令
[aaa@qq.com hadoop-2.7.3]# hadoop jar wc.jar com.atguigu.mr.wordcount.WordcountDriver /user/atguigu/input /user/atguigu/output
4.查看结果
推荐阅读