Hadoop2.2.0-64位编译
实验环境:Ubuntu12.04.3 x64
编译前需要安装:
JDK7u45\maven\Protoc\findbugs等等,需要保持联网状态
所有安装文件全部放在当前用户目录~。
install java(64位) 安装方法参见此文
other
sudo apt-get install g++ sudo apt-get install cmake sudo apt-get install zlib1g.dev //An Ant BuildException has occured: exec returned: 1 sudo apt-get install libssl-dev //openssl problem
install findbugs(需配置环境,见后文)
wget http://jaist.dl.sourceforge.net/project/findbugs/findbugs/2.0.3/findbugs-2.0.3.tar.gz sudo tar -zxvf findbugs-2.0.3.tar.gz -C /opt
install maven(需配置环境,见后文)
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz sudo tar zxvf apache-maven-3.1.1-bin.tar.gz -C /opt cd /opt/apache-maven-3.1.1/conf sudo gedit settings.xml
由于maven国外服务器可能连不上,先给maven配置一下国内镜像,在maven目录下,conf/settings.xml,在<mirrors></mirros>里添加:
<mirror> <id>nexus-osc</id> <mirrorOf>*</mirrorOf> <name>Nexusosc</name> <url>http://maven.oschina.net/content/groups/public/</url> </mirror>
同样,在<profiles></profiles>内新添加:
<profile> <id>jdk-1.7</id> <activation> <jdk>1.7</jdk> </activation> <repositories> <repository> <id>nexus</id> <name>local private nexus</name> <url>http://maven.oschina.net/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>local private nexus</name> <url>http://maven.oschina.net/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile>
install protobuf(编译安装,注意hadoop2.2.0要求protoc是2.5版本,在code.google上的protobuf-2.5.0.tar.gz格式的安装后为2.4.1,建议下载zip版)
cd ~ wget https://code.google.com/p/protobuf/downloads/detail?name=protobuf-2.5.0.zip&can=2&q= unzip protobuf-2.5.0.zip cd protobuf-2.5.0/ sudo ./configure --prefix=/usr sudo make clean //此命令为了避免出现cannot install `libprotoc.la' to a directory not ending in /opt/protoc/lib的错误 sudo make && make install
setup env
sudo gedit /etc/profile
#Java export JAVA_HOME=/usr/local/java/jdk1.7.0_45 export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib #$MAVEN export MAVEN_HOME=/opt/apache-maven-3.1.1 export PATH=$PATH:$MAVEN_HOME/bin #FINDBUGS export FINDBUGS_HOME=/opt/findbugs-2.0.3 export PATH=$FINDBUGS_HOME/bin:$PATH
source /etc/profile
compile
edit hadoop-2.2.0-src/pom.xml@line221 3.0->3.3
cd ~/hadoop-2.2.0-src/ mvn clean package -Pdist,native,docs -DskipTests -Dtar //编译中途出错修正后可从指定点开始继续编译,修改最后一个参数即可。如出现hadoop-hdfs/target/findbugsXml.xml does not exist则从该命令删除docs参数再运行mvn package -Pdist,native -DskipTests -Dtar -rf :hadoop-pipes
漫长等待吧~在虚拟机也就用了半个小时
[exec] $ tar cf hadoop-2.2.0.tar hadoop-2.2.0
[exec] $ gzip -f hadoop-2.2.0.tar
[exec]
[exec] Hadoop dist tar available at: /home/hadoop/hadoop-2.2.0-src/hadoop-dist/target/hadoop-2.2.0.tar.gz