写好MapReduce线下代码后,生成 example-mr-1.2.jar包上传并解压运行,如下:
[root@bigdata01 ~]# hadoop jar example-mr-1.2.jar
Exception in thread “main” java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: D:%5Cinput
认真看了报错后,发现,错误来自MAIN方法中的本地路径无法读取,查看代码后,发现WordCountClient文件中:
FileInputFormat.addInputPath(job, new Path(“D:\input”));
FileOutputFormat.setOutputPath(job, new Path(“D:\output”));
里面的代码被我写到了本地路径,所以hadoop无法读取,于是修改如下:
FileInputFormat.addInputPath(job, new Path("/wordcount/input"));
FileOutputFormat.setOutputPath(job, new Path("/wordcount/output"));
恢复后重新打开maven建包,然后上传输入:
hadoop jar example-mr-1.2.jar;
这次果然成功!