1.源碼編譯
1.1源碼下載下傳
首先,建立源碼儲存目錄
[[email protected] ~]$ mkdir -p src
擷取源碼的兩種方式
1)Hypertable官網(http://www.hypertable.com)下載下傳tar包并解壓。
cd ~/src
tar zxvf<path_to>/hypertable-<version>-src.tar.gz
2)從git倉庫擷取
cd ~/src
git clone git://github.com/hypertable/hypertable.git
确認hypertable source tree is
~/src/hypertable
1.2安裝編譯環境
參考[HowToBuild](http://code.google.com/p/hypertable/wiki/HowToBuild),注意選擇對應的系統平台和版本,本文選擇CentOS6.0 64-bit。編譯時注意以下兩點:
1) Ceph和kfs無需安裝;
2) Jdk版本必須大于或等于1.6.0。
也可通過執行腳本:~/src/hypertable/bin/src-utils/htbuild --install dev_env,來安裝編譯環境,此方法要求編譯機器連接配接到Internet。
1.3 編譯配置
類似linux下源碼編譯的操作,即
cd ~/src/hypertable
cmake CMakeLists.txt
//注意-D前有空格
Cmake -DCMAKE_INSTALL_PREFIX=/home/jack/installdir
-DCMAKE_BUILD_TYPE=Release
-DPACKAGE_OS_SPECIFIC=1
-DVERSION_ADD_COMMIT_SUFFIX=1
CMakeLists.txt
更多的配置,參考如下,需要在cmake之後添加參數
1)指定安裝路徑($prefix e.g. /home/jack/installdir)
cmake -DCMAKE_INSTALL_PREFIX=$prefix CMakeLists.txt
2)指定編譯類型(預設是Debug)
cmake-DCMAKE_BUILD_TYPE=ReleaseCMakeLists.txt
3)指定hypertable版本字尾(e.g. 0.9.7.15.d4ada73)
cmake-DVERSION_ADD_COMMIT_SUFFIX=1 CMakeLists.txt
4) 指定特定的作業系統(e.g. hypertable-0.9.7.15.d4ada73-linux-x86_64)
cmake -DPACKAGE_OS_SPECIFIC=1 CMakeLists.txt
1.4編譯二進制
編輯 ~/.bash_profile檔案,在檔案後添加:export LD_LIBRARY_PATH=/usr/lib:/usr/lib64:/usr/local/lib:usr/local/lib64
source ~/.bash_profile
make (or make -jnumber_of_cpu_or_cores_plus_1 for faster compile)
make install
安裝成功後,目錄樹如:/home/jack/installdir/0.9.7.x
本文中,生成目錄樹為/home/jack/installdir/0.9.7.8.tarball
2.制作二進制包
2.1 手動打包
cd ~/installdir
mv 0.9.7.8.tarball 0.9.7.8
mkdir –p hypertable-0.9.7.8 -linux-x86_64/opt/hypertable
mv 0.9.7.8 hypertable-0.9.7.8-linux-x86_64/opt/hypertable/
tar –cjvf hypertable-0.9.7.8-linux-x86_64.tar.bz2 hypertable-0.9.7.8-linux-x86_64
2.2 自動打包
2.2.1修改腳本檔案
編輯~/src/hypertable/bin/src-utils/htpkg檔案
修改srcdir和thriftdir,指定為實際使用的路徑
#srcdir=$HOME/Source/hypertable
#thriftdir=/usr/src/thrift
srcdir=/home/jack/src/hypertable
thriftdir=/home/jack/Downloads/thrift-0.8.0
2.2.2執行指令
./htpkg–help檢視指令幫助
如果安裝2.1 編輯了srcdir和thriftdir則運作指令為
sudo ./htpkg RPM TBZ2
否則要指定參數,如下:
sudo ./htpkg --build Release --srcdir/home/jack/src/hypertable
--thriftdir/home/jack/Downloads/thrift-0.8.0RPM TBZ2
注意:參數後不用=,直接空格跟Path
指令成功執行完畢,在目前目錄下生成*.tar.bz2 二進制包
以上是README.md 種提供的方法,注意在運作指令前
執行以下操作:sudorm -rfCMakeFiles CMakeCache.txt cmake_install.cmakeMakefile
另外,這樣執行時,容易出現的錯誤,就是提示Find*.cmake頭檔案或庫檔案路徑錯誤資訊,
該類型的檔案存放在~/src/hypertable/cmake/ 目錄下。如果在安裝編譯環境時安裝的軟體路徑找不到,可以根據提示,修改對應的Find*.cmake檔案
3.編譯環境搭建及編譯過程中遇到的問題
3.1 缺少perl MakeMaker的錯誤
錯誤資訊節選如下:
Can't locate ExtUtils/MakeMaker.pm in @INC
make[3]: Leaving directory `/root/src/htbuild-dir/thrift/lib/rb'
Making all in perl
make[3]: Entering directory `/root/src/htbuild-dir/thrift/lib/perl'
Making all in test
make[4]: Entering directory `/root/src/htbuild-dir/thrift/lib/perl/test'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/src/htbuild-dir/thrift/lib/perl/test'
make[4]: Entering directory `/root/src/htbuild-dir/thrift/lib/perl'
/usr/bin/perl Makefile.PL MAKEFILE=Makefile-perl.mk INSTALLDIRS=
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 20.
BEGIN failed--compilation aborted at Makefile.PL line 20.
make[4]: *** [Makefile-perl.mk] 錯誤 2
make[4]: Leaving directory `/root/src/htbuild-dir/thrift/lib/perl'
make[3]: *** [all-recursive] 錯誤 1
make[3]: Leaving directory `/root/src/htbuild-dir/thrift/lib/perl'
make[2]: *** [all-recursive] 錯誤 1
make[2]: Leaving directory `/root/src/htbuild-dir/thrift/lib'
make[1]: *** [all-recursive] 錯誤 1
make[1]: Leaving directory `/root/src/htbuild-dir/thrift'
make: *** [all] 錯誤 2
解決方法
//安裝MakeMaker:
yum -y install perl-ExtUtils-MakeMaker-Coverage.noarch
rpm -qa|grep -i makemake --color=auto perl-ExtUtils-MakeMaker-6.55-136.el6.x86_64 perl-ExtUtils-MakeMaker-Coverage-0.05-8.el6.noarch
3.2 由libedit引起的錯誤
錯誤資訊節選如下:
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build
gmake[1]: Entering directory `/root/build/CMakeFiles/CMakeTmp/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /root/build/CMakeFiles/CMakeTmp/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec.dir/CheckEditline.cc.o
/usr/bin/c++ -o CMakeFiles/cmTryCompileExec.dir/CheckEditline.cc.o -c /root/src/hypertable/cmake/CheckEditline.cc
In file included from /root/src/hypertable/cmake/CheckEditline.cc:20:
/usr/include/editline/readline.h:91: 錯誤:expected initializer before ‘*’ token
/usr/include/editline/readline.h:92: 錯誤:expected initializer before ‘*’ token
/usr/include/editline/readline.h:121: 錯誤:‘FILE’在此作用域中尚未聲明
/usr/include/editline/readline.h:121: 錯誤:expected primary-expression before ‘)’ token
/root/src/hypertable/cmake/CheckEditline.cc: In function ‘int main()’:
/root/src/hypertable/cmake/CheckEditline.cc:25: 錯誤:‘el_wset’在此作用域中尚未聲明
/root/src/hypertable/cmake/CheckEditline.cc:27: 錯誤:‘el_wgets’在此作用域中尚未聲明
gmake[1]: *** [CMakeFiles/cmTryCompileExec.dir/CheckEditline.cc.o] 錯誤 1
gmake[1]: Leaving directory `/root/build/CMakeFiles/CMakeTmp/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec/fast] 錯誤 2
解決方法
rpm -e libedit --nodeps
#wget http://www.thrysoee.dk/editline/libedit-20121213-3.0.tar.gz
./configure --enable-widec
make
make install
cd /usr/lib64/
ln -sf /usr/local/lib/libedit.so .
3.3 由于libboost_thread名稱不一緻引起的錯誤
錯誤資訊節選如下:
Linking CXX executable container_test
CMakeFiles/container_test.dir/tests/container_test.cc.o: In function `boost::thread_group::join_all()':
container_test.cc:(.text._ZN5boost12thread_group8join_allEv[boost::thread_group::join_all()]+0xd2): undefined reference to `boost::thread::join_noexcept()'
CMakeFiles/container_test.dir/tests/container_test.cc.o: In function `void Hypertable::parallel_run<boost::_bi::bind_t<void, void (*)(int), boost::_bi::list1<boost::_bi::value<int> > > >(boost::_bi::bind_t<void, void (*)(int), boost::_bi::list1<boost::_bi::value<int> > >, unsigned long, bool)':
解決方法
進入libboost_thread所在的目錄,執行以下指令:
ln -sf libboost_thread.so libboost_thread-mt.so
3.4 java版本過低引起的問題
錯誤資訊節選如下:
[javac] 182 problems (5 errors, 177 warnings)
BUILD FAILED
/root/src/forht/thrift-0.8.0/lib/java/build.xml:95: Compile failed; see the compiler error output for details.
解決方法
更換高版本的jdk,如:jdk1.6.0_34
3.5 編譯ruby或者執行gem時出現“ERROR: RDoc documentation generator not installed: no such file to load -- rdoc/rdoc”
錯誤資訊節選如下:
ERROR: While executing gem ... (Gem::DocumentError)
ERROR: RDoc documentation generator not installed: no such file to load -- rdoc/rdoc
解決方法
執行sudo yum intall ruby-rdoc; sudo gem install rdoc
3.6 執行thrift編譯的make指令時出現“rake aborted”錯誤
錯誤資訊如下圖:
解決方法
這是一個已知的thrift下ruby的bug。
如果不需要支援ruby的話,可以先執行“./configure --without-ruby”,再執行make指令即可。