标签:kill str 路径 red ado artifact host nec 3.1
使用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]
修改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
标签:kill str 路径 red ado artifact host nec 3.1
原文地址:https://www.cnblogs.com/Merodach/p/9141336.html