报如下错误:
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/hadoop/mapreduce/wordcount/WordCountDriver : Unsupported major.minor version 52.0原因是Windows环境用的jdk1.7,Linux环境用的jdk1.8。 解决方案:统一jdk版本。
缓存pd.txt小文件案例中,报找不到pd.txt文件 原因:大部分为路径书写错误。还有就是要检查pd.txt.txt的问题。还有个别电脑写相对路径找不到pd.txt,可以修改为绝对路径。报类型转换异常。 通常都是在驱动函数中设置Map输出和最终输出时编写错误。 Map输出的key如果没有排序,也会报类型转换异常。集群中运行wc.jar时出现了无法获得输入文件。 原因:WordCount案例的输入文件不能放用HDFS集群的根目录。出现了如下相关异常 Exception in thread "main" java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z at org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Native Method) at org.apache.hadoop.io.nativeio.NativeIO$Windows.access(NativeIO.java:609) at org.apache.hadoop.fs.FileUtil.canRead(FileUtil.java:977) java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:356) at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:371) at org.apache.hadoop.util.Shell.<clinit>(Shell.java:364)解决方案:拷贝hadoop.dll文件到Windows目录C:\Windows\System32。个别同学电脑还需要修改Hadoop源码。 方案二:创建如下包名,并将NativeIO.java拷贝到该包名下
自定义Outputformat时,注意在RecordWirter中的close方法必须关闭流资源。否则输出的文件内容中数据为空。 @Override public void close(TaskAttemptContext context) throws IOException, InterruptedException { if (atguigufos != null) { atguigufos.close(); } if (otherfos != null) { otherfos.close(); } }