請先切換成 root 後執行
[root@localhost ~]# su root
[root@localhost ~]# vi Hadoop-2.2.0_Compile.sh
把下面框中內容全部貼上
[root@localhost ~]# chmod +x Hadoop-2.2.0_Compile.sh
[root@localhost ~]# ./Hadoop-2.2.0_Compile.sh
注意:請勿把下面程式直接貼到命令提示 (例如:[root@localhost ~]# ) 下直接執行,不然 if then ... else if 這類不是單一行命令的程式會執行錯誤。
Hadoop-2.2.0_Compile.sh 內容如下
#!/bin/bash echo -e "\033[31m" echo -e "Program : Hadoop-2.2.0_Compile.sh " echo -e "Hadoop 2.2.0 Compile Shell Script (CentOS 6.4 x86_64) " echo -e "by Shau-Rong Lu 2013-11-10 " echo -e "\033[0m" cd /usr/local/src yum -y install gcc gcc-c++ svn cmake git zlib zlib-devel openssl openssl-devel rsync java-1.7.0-openjdk.x86_64 java-1.7.0-openjdk-devel.x86_64 make wget export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64 #rpm -ivh jdk-7u45-linux-x64.rpm #if [ "$?" != "0" ]; then # echo "jdk-7u45-linux-x64.rpm does not exist!" # exit 1 #fi #export JAVA_HOME=/usr/java/jdk1.7.0_45 echo "********** Install Apache Maven 3.1.1 **********" cd /usr/local/src if [ ! -s apache-maven-3.1.1-bin.tar.gz ]; then wget http://ftp.tc.edu.tw/pub/Apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz fi tar zxvf apache-maven-3.1.1-bin.tar.gz -C /usr/local ln -s /usr/local/apache-maven-3.1.1/bin/mvn /usr/bin/mvn #read -n 1 -p "Press Enter to continue..." echo "********** Install FindBugs 2.0.2 **********" cd /usr/local/src if [ ! -s findbugs-2.0.2.tar.gz ]; then wget http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.2.tar.gz?download fi tar zxvf findbugs-2.0.2.tar.gz -C /usr/local/ ln -s /usr/local/findbugs-2.0.2/bin/findbugs /usr/bin/findbugs #read -n 1 -p "Press Enter to continue..." echo "********** Install Protoc 2.5.0 **********" cd /usr/local/src if [ ! -s protobuf-2.5.0.tar.gz ]; then wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz fi tar zxvf protobuf-2.5.0.tar.gz -C /usr/local/src cd /usr/local/src/protobuf-2.5.0 ./configure make make install ln -s /usr/local/bin/protoc /usr/bin/protoc #read -n 1 -p "Press Enter to continue..." echo "********** Compile Hadoop 2.2.0 **********" cd /usr/local/src if [ ! -s hadoop-2.2.0-src.tar.gz ]; then wget http://ftp.mirror.tw/pub/apache/hadoop/common/hadoop-2.2.0/hadoop-2.2.0-src.tar.gz fi tar zxvf hadoop-2.2.0-src.tar.gz -C /usr/local/src cd /usr/local/src/hadoop-2.2.0-src/ #read -n 1 -p "Press Enter to continue..." mvn package -Pdist,native -DskipTests -Dtar |
測試OK~
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24:10.876s
[INFO] Finished at: Sun Nov 10 20:23:38 CST 2013
[INFO] Final Memory: 131M/376M
[INFO] ------------------------------------------------------------------------
(完)
相關
[研究] Hadoop 2.2.0 編譯 (CentOS 6.4 x64)
http://shaurong.blogspot.tw/2013/11/hadoop-220-centos-64-x64.html
[研究] Hadoop 2.2.0 Single Cluster 安裝 (二)(CentOS 6.4 x64)
http://shaurong.blogspot.tw/2013/11/hadoop-220-single-cluster-centos-64-x64_7.html
[研究] Hadoop 2.2.0 Single Cluster 安裝 (一)(CentOS 6.4 x64)
http://shaurong.blogspot.tw/2013/11/hadoop-220-single-cluster-centos-64-x64.html
[研究] Hadoop 1.2.1 (rpm)安裝 (CentOS 6.4 x64)
http://shaurong.blogspot.tw/2013/10/hadoop-121-rpm-centos-64-x64.html
[研究] Hadoop 1.2.1 (bin)安裝 (CentOS 6.4 x64)
http://shaurong.blogspot.tw/2013/07/hadoop-112-centos-64-x64.html
[研究] Hadoop 1.2.1 安裝 (CentOS 6.4 x64)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=80035
[研究] 雲端軟體 Hadoop 1.0.0 安裝 (CentOS 6.2 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=21166
[研究] 雲端軟體 Hadoop 0.20.2 安裝 (CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=18513
[研究] 雲端軟體 Hadoop 0.20.2 安裝 (CentOS 5.4 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=17974
if [ ! -s protobuf-2.5.0.tar.gz ]; then
回覆刪除wget http://ftp.mirror.tw/pub/apache/hadoop/common/hadoop-2.2.0/hadoop-2.2.0-src.tar.gz
fi
應該是
if [ ! -s hadoop-2.2.0-src.tar.gz ]; then
wget http://ftp.mirror.tw/pub/apache/hadoop/common/hadoop-2.2.0/hadoop-2.2.0-src.tar.gz
fi
感謝 :)
刪除整個script 有需要修正的地方有兩個
回覆刪除1. yum install 的部份,需要再多增加 wget , make
2. hadoop-2.2.0-src.tar.gz 的下載判斷
修正這兩處後,就可以在剛裝完CentOS_mini_x86_64 的環境下,成功編譯
修改了,敝人 CentOS 安裝不是預設的最小安裝,所以有些套件已經被 yum 安裝了,有問題歡迎提出,感謝 :)
刪除