Ubuntu系统下eclipse配置mapreduce插件常见错误和解决办法汇总

在上篇文章中eclipse已经能访问HDFS目录( blog.csdn.net/gamer_gyt/article/details/47209623),但并不能进行Mapreduce编程,在这里小编将常见错误和处理办法进行总结,希望对大家有所帮助

错误1ERROR [main] util.Shell (Shell.java:getWinUtilsPath(303)) - Failed to locate the winutils binary in the hadoop binary path  
java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.

解决办法:

eg:我解压的目录是D:\hadoop-2.6.0

在系统的环境变量界面添加HADOOP_HOME,并在系统变量PATH中添加如图:

然后eclipse中选择Windows->Prefenences设置如图:

错误2:Unable to load native-hadoop library for your platform... using builtin-java classes where applicable

错误3:Exception in thread "main" java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z

上面两个问题是缺少组件,解决办法:

下载hadoop-common-2.2.0-bin-master

将里边bin 目录替换 本地hadoop里边的bin目录

 

错误:4:

 

15/08/03 10:15:43 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
15/08/03 10:15:43 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
15/08/03 10:15:55 INFO ipc.Client: Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)
15/08/03 10:15:57 INFO ipc.Client: Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 1 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)
15/08/03 10:15:59 INFO ipc.Client: Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 2 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)

解决办法:

将集群配置文件中core-site.xml  localhost改为你主节点IP

然后加入在yarn-site.xml中加入

<property>
<name>yarn.resourcemanager.address</name>
<value>127.0.0.1:8032</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address</name>
<value>127.0.0.1:8030</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address</name>
<value>127.0.0.1:8031</value>
</property>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>127.0.0.1</value>
</property>

注意127.0.0.1改为你的ip

 

特别注意的是,修改后,集群要重新启动,且把里边的修改的文件重新copy一份到程序的src目录下,在eclipse中刷新

错误5:

Exit code: 1
Exception message: /bin/bash: 第 0 行: fg: 无任务控制

Stack trace: ExitCodeException exitCode=1: /bin/bash: 第 0 行: fg: 无任务控制

解决办法参考网上给的教程:http://www.aboutyun.com/thread-8498-1-1.html 并未解决

真正的办法是:

 

在客户端配置文件中添加如下属性:

    <property>
        <name>mapreduce.app-submission.cross-platform</name>
        <value>true</value>
    </property>

注意:必须添加到Hadoop程序读取的客户端本地配置文件中,添加到客户端Hadoop安装路径中的“core-site.xml”,“mapred-site.xml”等文件中不起作用

错误6:

正确放置完jar插件之后,eclipse中不能显示mapreduce

解决办法:检查jar插件的位置注意如果是从ubuntu自带的软件中心安装elcipse的话,则安装目录为:/usr/share/eclipse/dropins/sdk/plugins/不是在/usr/share/eclipse/plugin,进入eclipse目录,执行sudo chmod 777 * -R,重启eclipse           这一步特别重要网上好多资料都不是这样写的,所以配置一直不成功。

 

推荐一篇不错的博客:http://www.aboutyun.com/thread-8311-1-1.html


搜索与推荐Wiki

扫一扫 关注微信公众号!号主 专注于搜索和推荐系统,尝试使用算法去更好的服务于用户,包括但不局限于机器学习,深度学习,强化学习,自然语言理解,知识图谱,还不定时分享技术,资料,思考等文章!


                             【技术服务】,详情点击查看:https://mp.weixin.qq.com/s/PtX9ukKRBmazAWARprGIAg 


外包服务

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用MapReduceHadoop的销售数据排序系统的代码: Mapper类: ``` public class SalesMapper extends Mapper<LongWritable, Text, IntWritable, Text> { private Text salesData = new Text(); private IntWritable salesValue = new IntWritable(); public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { String[] data = value.toString().split(","); salesData.set(value); if (data.length == 2) { try { salesValue.set(Integer.parseInt(data[1])); } catch (NumberFormatException e) { salesValue.set(0); } context.write(salesValue, salesData); } } } ``` Reducer类: ``` public class SalesReducer extends Reducer<IntWritable, Text, Text, IntWritable> { public void reduce(IntWritable key, Iterable<Text> values, Context context) throws IOException, InterruptedException { for (Text value : values) { context.write(value, key); } } } ``` Driver类: ``` public class SalesSort { public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); Job job = Job.getInstance(conf, "Sales Sort"); job.setJarByClass(SalesSort.class); job.setMapperClass(SalesMapper.class); job.setReducerClass(SalesReducer.class); job.setOutputKeyClass(IntWritable.class); job.setOutputValueClass(Text.class); FileInputFormat.addInputPath(job, new Path(args[0])); FileOutputFormat.setOutputPath(job, new Path(args[1])); System.exit(job.waitForCompletion(true) ? 0 : 1); } } ``` 在Eclipse中,创建一个新的Java项目,并将上述代码复制到相应的类文件中。然后,创建一个新的Run Configuration,将SalesSort作为主类,并设置输入和输出文件的路径。最后,运行该程序即可。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值