Hadoop-0.20.2的PiEstimator问题

直接运行Hadoop-0.20.2的PiEstimator.java的话,会报"java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result." 的错误,原因是算出的Pi值没有设定小数位数(Pi是无理数)。


解决方法:

1、去https://issues.apache.org/jira/browse/MAPREDUCE-1880下载m1880_20100619_0.20.patch


2、为hadoop-0.20.2打上这个补丁

[root@master:/opt/hadoop-0.20.2]# patch -p0 < ../hadoopPatch/m1880_20100619_0.20.patch


3、修改$HADOOP_HOME/build.xml

     将line904和line908的两句注释掉,修改成如下所示:

<target name="forrest.check" unless="forrest.home" depends="java5.check">

<!--fail message="'forrest.home' is not defined. Please pass -Dforrest.home=&lt;base of Apache Forrest installation&gt; to Ant on the command-line." /-->

</target>


<target name="java5.check" unless="java5.home">

<!--fail message="'java5.home' is not defined.  Forrest requires Java 5.  Please pass -Djava5.home=&lt;base of Java 5 distribution&gt; to Ant on the command-line." /-->

</target>


4、重新build

[root@master:/opt/hadoop-0.20.2]# ant package

5、将build目录下的hadoop-0.20.3-dev-examples.jar重命名为hadoop-0.20.2-examples.jar替换所有节的$HADOOP_HOME下原有的hadoop-0.20.2-examples.jar

6、重启Hadoop集群

7、运行pi应用
[root@master:/opt/hadoop-0.20.2]# hadoop jar hadoop-0.20.2-examples.jar pi 9 10
后面两数字随便设,9代表map数目,10代表每个map的样本数。

你可能感兴趣的:(hadoop,piestimator)