由于2.4.0默認(rèn)配置的libhadoop是32位的,在64位的操作系統(tǒng)環(huán)境運(yùn)行過(guò)程中,會(huì)提示以下錯(cuò)誤:
創(chuàng)新互聯(lián)公司是一家專注于網(wǎng)站建設(shè)、做網(wǎng)站和綿陽(yáng)主機(jī)托管的網(wǎng)絡(luò)公司,有著豐富的建站經(jīng)驗(yàn)和案例。
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /opt/hadoop-2.2.0/lib/native/libhadoop.so.1.0.0 which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c
13/11/01 10:58:59 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
需要重新編譯Hadoop的代碼,得到適合的庫(kù)文件。按以下步驟執(zhí)行。
可以從Apache官方下載Hadoop 2.2.0的源代碼,或者在以下網(wǎng)址下載Hadoop 2.2.0的源代碼:
http://mirrors.cnnic.cn/apache/hadoop/common/hadoop-2.2.0/hadoop-2.2.0-src.tar.gz
本文采用的Ubuntu 12.04.3 LTS環(huán)境,先安裝編譯環(huán)境:
[plain] view plain copy print?
$ yum install
yum install gcc gcc-c++ kernel-devel
$ yum install g++ autoconf automake libtool cmake zlib1g-dev pkg-config libssl-dev
安裝 build-essential
yum groupinstall "Development Tools"
這時(shí)候需要用wget命令去網(wǎng)絡(luò)上下載資源包
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
然后重新安裝maven
安裝maven
yum -y install apache-maven
編譯過(guò)程需要使用protobuf,建議先行安裝。Ubuntu倉(cāng)庫(kù)默認(rèn)的protobuf是2.4.1版,需要最新的2.5版:
https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
下載解壓后,執(zhí)行:
[plain] view plain copy print?
$ tar xzvf protobuf-2.5.0.tar.gz
$ cd protobuf-2.5.0
$ ./configure --prefix=/usr
$ make
$ sudo make install
解壓進(jìn)入hadoop源碼目錄,執(zhí)行編譯:
[plain] view plain copy print?
$ tar xzvf hadoop-2.2.0-src.tar.gz
$ cd hadoop-2.2.0-src
$ mvn package -Pdist,native -DskipTests -Dtar
編譯過(guò)程中maven會(huì)自動(dòng)下載依賴。編譯完成后,系統(tǒng)會(huì)提示以下信息:
[plain] view plain copy print?
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------
[INFO] Total time: 15:39.705s
[INFO] Finished at: Fri Nov 01 14:36:17 CST 2013
[INFO] Final Memory: 135M/422M
然后在以下目錄可以獲取編譯完成的libhadoop:
[plain] view plain copy print?
hadoop-2.2.0-src/hadoop-dist/target/hadoop-2.2.0/lib
注:默認(rèn)源地址下,maven下載依賴時(shí)間極長(zhǎng),建議使用國(guó)內(nèi)源,參考《maven國(guó)內(nèi)鏡像配置》文檔。
然后將編譯的lib/native文件夾替換原本的即可。