1、环境描述
Hadoop环境:VirtualBox5(三台),CentOS7,Hadoop2.7.1
开发环境:Windows7
2、详细配置
2.1、project结构一览
2.2、build.xml
<?xml version="1.0" encoding="UTF-8"?> <project name="wukong-practice-hadoop2" default="package" basedir="." > <property name="src.dir.main.java" location="src/main/java"/> <property name="src.dir.main.resources" location="src/main/resources"/> <property name="build.dir" location="build"/> <property name="build.dir.classes" location="build/classes"/> <property file="build.properties"/> <property name="jar.name" value="shell-0.1-snapshot.jar"/> <path id="classpath"> <!--<pathelement location="${build.dir.classes}"/>--> <path refid="hadoop-classpath"/> <path refid="hadoop-depend-classpath"/> </path> <path id="hadoop-classpath"> <fileset dir="${hadoop.dir}/share/hadoop/common"> <include name="**/*.jar"/> </fileset> <fileset dir="${hadoop.dir}/share/hadoop/hdfs"> <include name="**/*.jar"/> </fileset> <fileset dir="${hadoop.dir}/share/hadoop/mapreduce"> <include name="**/*.jar"/> </fileset> <fileset dir="${hadoop.dir}/share/hadoop/yarn"> <include name="**/*.jar"/> </fileset> </path> <path id="hadoop-depend-classpath"> <fileset dir="${hadoop.dir}/share/hadoop/common/lib"> <include name="**/*.jar"/> </fileset> <fileset dir="${hadoop.dir}/share/hadoop/hdfs/lib"> <include name="**/*.jar"/> </fileset> <fileset dir="${hadoop.dir}/share/hadoop/mapreduce/lib"> <include name="**/*.jar"/> </fileset> <fileset dir="${hadoop.dir}/share/hadoop/yarn/lib"> <include name="**/*.jar"/> </fileset> </path> <target name="info"> <echo>build wukong-practice-hadoop2....</echo> <echo>hadoop-path: ${hadoop.path}</echo> </target> <target name="clean"> <delete dir="${build.dir}/**"/> </target> <target name="compile" depends="clean"> <mkdir dir="${build.dir.classes}"/> <copy todir="${build.dir.classes}" verbose="true"> <fileset dir="${src.dir.main.resources}"> <exclude name="META-INF/**"/> </fileset> </copy> <javac srcdir="${src.dir.main.java}" destdir="${build.dir.classes}" source="1.7" target="1.7" encoding="${compile.encoding}" classpathref="classpath" includeantruntime="false"> <!--<classpath refid="classpath"/>--> </javac> </target> <target name="package" depends="compile"> <pathconvert property="jar.classpath" pathsep=" " refid="classpath"> <map from="${hadoop.dir}" to="${hadoop.dir.linux}"/> </pathconvert> <!--<pathconvert property="jar.classpath" pathsep=" "> <mapper> <chainedmapper> <flattenmapper/> <globmapper from="*" to="lib/*"/> </chainedmapper> </mapper> <path refid="classpath"/> </pathconvert>--> <jar destfile="${build.dir}/${jar.name}" basedir="${build.dir.classes}"> <!--manifest="${src.main.resources}/META-INF/MANIFEST.MF">--> <manifest> <attribute name="Main-Class" value="band.wukong.practice.hadoop2.Commander"/> <attribute name="Class-Path" value="${jar.classpath}"/> </manifest> </jar> </target> </project>
2.3、build.properties
version=0.1.0 compile.encoding=UTF-8 hadoop.dir=D:/Lab/lib/hadoop/hadoop-2.7.1 hadoop.dir.linux=/user/wukong/local/hadoop-2.7.1
2.4、看一眼生成的MANIFEST.MF
3、运行示例
时间: 2024-11-10 09:16:19