jar包在Hadoop集群上测试(MapReduce)
生活随笔
收集整理的這篇文章主要介紹了
jar包在Hadoop集群上测试(MapReduce)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
本片使用MapReduce——統計輸出給定的文本文檔每一個單詞出現的總次數的案例進行,jar包在集群上測試
1、添加打包插件依賴
<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
將
FileInputFormat.setInputPaths(job, "/Users/marron27/test/input"); FileOutputFormat.setOutputPath(job, new Path("/Users/marron27/test/output"));更改為
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
總結
以上是生活随笔為你收集整理的jar包在Hadoop集群上测试(MapReduce)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JDK源码解析之 java.lang.T
- 下一篇: Nginx(一):概念基础