hadoop 提交程序并监控运行
程序編寫及打包
使用maven導入第三方jar
pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>hadoop-study</groupId><artifactId>HadoopTest</artifactId><version>4.0</version><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><hadoop.version>2.7.5</hadoop.version></properties><dependencies><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-client</artifactId><version>${hadoop.version}</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.11</version><scope>test</scope></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-minicluster</artifactId><version>${hadoop.version}</version><scope>test</scope></dependency></dependencies><build><finalName>word-count</finalName><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.1</version><configuration><source>1.6</source><target>1.6</target></configuration></plugin><plugin><groupId>org.apache.maven.plugin</groupId><artifactId>maven-jar-plugin</artifactId><version>2.5</version><configuration><outputDirectory>${basedir}</outputDirectory></configuration></plugin></plugins></build> </project>導入本地配置文件測試運行
在Idea 里選擇ProjectStructure 添加hadoop配置路徑并把它設為resource,可以進行build和run
打包文件提交運行
在Idea 里選擇ProjectStructure 刪除hadoop配置路徑
在Idea 里選擇ProjectStructure/Artifact,添加jar/from modules with dependencies,選擇主類
hadoop jar HadoopTest.jar [args]
監視job運行狀態
修改hadoop配置文件
<!--mapred-site.xml--> <configuration><property><name>mapreduce.framework.name</name><value>yarn</value></property> </configuration> <!--yarn-site.xml--> <configuration> <property><name>yarn.nodemanager.aux-services</name><value>mapreduce_shuffle</value> </property> <property><name>yarn.resourcemanager.hostname</name><value>master</value> </property><property><name>yarn.resourcemanager.address</name><value>master:8032</value></property><property><name>yarn.resourcemanager.scheduler.address</name><value>master:8030</value></property><property><name>yarn.resourcemanager.resource-tracker.address</name><value>master:8031</value></property> </configuration>常用網址和命令
查看任務: hadoop job -list
殺死任務: hadoop job -kill jobid
任務頁面:http://master:8088
常見問題
Class not found
在IDE編譯的時候發生,可能是沒有導入需要的依賴包
解決辦法:使用maven配置依賴環境
當手動運行class 文件時發生,可能是沒有設置hadoopclasspath
解決辦法:export $HADOOP_CLASSPATH=CLASSPATH:".",或者是打包成jar運行
在任務頁面無法看到job
原因:hadoop需要另外配置mapreduce的運行時環境,默認是local,需配置成yarn
解決辦法:在mapred-site.xml中添加mapreduce.framework.name配置
retrying connecting 0.0.0.0
原因:沒設置yarn.resourcemanger的主機ip,或者設置錯文件
解決辦法: 在yarn-site.xml 上添加yarn.resourcemanger.hoatname等信息
map卡在0%
原因:需要在yarn里面配置附屬服務為mapreduce
解決辦法:在yarn-site.xml 上添加yarn.nodemanager.aux-services
參考文章:https://blog.csdn.net/tangtang5156/article/details/40867759
轉載于:https://www.cnblogs.com/Merodach/p/9141336.html
總結
以上是生活随笔為你收集整理的hadoop 提交程序并监控运行的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: win7桌面图标不显示解决方法(win7
- 下一篇: 极光推送服务端API(定时推送任务,推送