怎么在CentOS下重新编译hadoop源码
这篇文章主要介绍“怎么在CentOS下重新编译hadoop源码”,在日常操作中,相信很多人在怎么在CentOS下重新编译hadoop源码问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么在CentOS下重新编译hadoop源码”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
目前成都创新互联公司已为千余家的企业提供了网站建设、域名、雅安服务器托管、绵阳服务器托管、企业网站设计、茂名网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
网上找了Unable to load native-hadoop library for your platform... using builtin-java classes where applicabl警告的原因,说的是由于hadoop一些本地库里编译时用到的C库与本机上的版本不同造成的,在本机环境下重新编译hadoop即可。
不过这个警告对hadoop使用影响不大。
然而作为一个有强迫症的程序员尝试了一些方法后无果,只能自己编译源码
切换到root用户
下载Ant Maven ProtocolBuffer findbugs CMake 的tar包放到/hadoop目录下
我用的版本是:
[hadoop@vm1 Downloads]$ ls apache-ant-1.9.5.tar.gz findbugs-2.0.2.tar.gz jdk-8u45-linux-x64.gz apache-maven-3.0.5.tar.gz hadoop-2.7.0-src.tar.gz protobuf-2.5.0 cmake-2.8.6 hadoop-2.7.0.tar.gz protobuf-2.5.0.tar.gz cmake-2.8.6.tar.gz jdk-7u79-linux-x64.gz
yum -y install lzo-devel zlib-devel gcc autoconf automake libtool tar zxf protobuf-2.5.0.tar.gz cd protobuf-2.5.0 ./configure
这时候因为protobuf需要c++支持,如果机器没装c++会出现如下错误:
checking whether to enable maintainer-specific portions of Makefiles... yes checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking for g++... no checking for c++... no checking for gpp... no checking for aCC... no checking for CC... no checking for cxx... no checking for cc++... no checking for cl.exe... no checking for FCC... no checking for KCC... no checking for RCC... no checking for xlC_r... no checking for xlC... no checking whether we are using the GNU C++ compiler... no checking whether g++ accepts -g... no checking dependency style of g++... none checking how to run the C++ preprocessor... /lib/cpp configure: error: in `/hadoop/protobuf-2.5.0': configure: error: C++ preprocessor "/lib/cpp" fails sanity check See `config.log' for more details
----------------------------------------------------------------------------------------
这时候需要
yum install glibc-headers yum install gcc-c++
然后再到protobuf文件夹下执行./configure
这下好了。那么goon
make make check make install tar apache-ant-1.9.2-bin.tar.gz mv apache-ant-1.9.2 /hadoop/app/ant192 tar apache-maven-3.0.5-bin.tar.gz mv apache-maven-3.0.5 /hadoop/maven305 tar zxf findbugs-2.0.2.tar.gz mv findbugs-2.0.2 /hadoop/findbugs202 tar zxf cmake-2.8.6.tar.gz cd cmake-2.8.6 ./bootstrap; make; make install cd .. tar zxf hadoop-2.7.0-src.tar.gz mv hadoop-2.7.0-src /hadoop/hadoop270_src chown -R hadoop:hadoop /hadoop/hadoop270_src vi /etc/profile export ANT_HOME=/hadoop/ant192 export MAVEN_HOME=/hadoop/maven305 export FINDBUGS_HOME=/hadoop/findbugs202 export PATH=${ANT_HOME}/bin:${MAVEN_HOME}/bin:${FINDBUGS_HOME}/bin:$PATH source /etc/profile su - hadoop cd /hadoop/hadoop270_src mvn clean package -DskipTests -Pdist,native,docs -Dtar
如果是第一次配置maven这一步会有点久,最好配置下maven的镜像地址
编译最后可能出现这个错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (make) on project hadoop-pipes: An Ant BuildException has occured: exec returned: 1 [ERROR] around Ant part ...... @ 5:124 in /home/hadoop/app/hadoop270_src/hadoop-tools/hadoop-pipes/target/antrun/build-main.xml
是zlib1g-dev 和 libssl-dev没有安装, 编译本地库需要这2个库的支持
解决方法:
yum install openssl-devel
然后重新:
mvn clean package -DskipTests -Pdist,native,docs -Dtar
注意:在jdk1.8环境下,可能出现错误:
[WARNING] The requested profile "native" could not be activated because it does not exist. [WARNING] The requested profile "docs" could not be activated because it does not exist. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (dist) on project hadoop-dist: An Ant BuildException has occured: exec returned: 1 [ERROR] around Ant part ...... @ 38:100 in /home/hadoop/app/hadoop270_src/hadoop-dist/target/antrun/build-main.xml
解决方法:将1.8换成1.7
那么编译成功:
[INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 25:22.002s [INFO] Finished at: Tue Jul 07 21:20:38 PDT 2015 [INFO] Final Memory: 131M/405M [INFO] ------------------------------------------------------------------------ [hadoop@vm1 hadoop270_src]$ ls BUILDING.txt hadoop-dist hadoop-project NOTICE.txt dev-support hadoop-hdfs-project hadoop-project-dist pom.xml hadoop-assemblies hadoop-mapreduce-project hadoop-tools README.txt hadoop-client hadoop-maven-plugins hadoop-yarn-project hadoop-common-project hadoop-minicluster LICENSE.txt [hadoop@vm1 hadoop270_src]$ cd hadoop-dist/ [hadoop@vm1 hadoop-dist]$ ls pom.xml target [hadoop@vm1 hadoop-dist]$ cd target/ [hadoop@vm1 target]$ ls antrun hadoop-2.7.0 hadoop-dist-2.7.0-javadoc.jar test-dir dist-layout-stitching.sh hadoop-2.7.0.tar.gz javadoc-bundle-options dist-tar-stitching.sh hadoop-dist-2.7.0.jar maven-archiver [hadoop@vm1 target]$ pwd /hadoop/app/hadoop270_src/hadoop-dist/target
用自己编译好的hadoop包配置好相应环境,启动hdfs已经没有(Unable to load native-hadoop library for your platform... using builtin-java classes where applicabl)警告:
[hadoop@vm1 hadoop-2.7.0]$ ./sbin/start-dfs.sh Starting namenodes on [vm1] vm1: starting namenode, logging to /home/hadoop/app/hadoop-2.7.0/logs/hadoop-hadoop-namenode-vm1.out vm1: starting datanode, logging to /home/hadoop/app/hadoop-2.7.0/logs/hadoop-hadoop-datanode-vm1.out Starting secondary namenodes [0.0.0.0] 0.0.0.0: starting secondarynamenode, logging to /home/hadoop/app/hadoop-2.7.0/logs/hadoop-hadoop-secondarynamenode-vm1.out [hadoop@vm1 hadoop-2.7.0]$ ./sbin/start-yarn.sh starting yarn daemons starting resourcemanager, logging to /home/hadoop/app/hadoop-2.7.0/logs/yarn-hadoop-resourcemanager-vm1.out vm1: starting nodemanager, logging to /home/hadoop/app/hadoop-2.7.0/logs/yarn-hadoop-nodemanager-vm1.out [hadoop@vm1 hadoop-2.7.0]$ jps 3251 NodeManager 3540 Jps 3145 ResourceManager 2699 NameNode 2828 DataNode 2991 SecondaryNameNode
到此,关于“怎么在CentOS下重新编译hadoop源码”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!
网站题目:怎么在CentOS下重新编译hadoop源码
文章源于:http://cdiso.cn/article/goosji.html