准备工作
1、安装依赖库
在编译Hadoop之前,需要先安装一些依赖库,如gcc、make等,可以使用以下命令安装:
sudo yum groupinstall "Development Tools" sudo yum install wget unzip tar sudo yum install java-1.8.0-openjdk-devel
2、下载Hadoop源码包
从官网下载Hadoop 2.2.0的源码包,或者使用以下命令直接下载:
wget https://downloads.apache.org/hadoop/common/hadoop-2.2.0/hadoop-2.2.0.tar.gz
3、解压源码包
使用以下命令解压源码包:
tar -xzf hadoop-2.2.0.tar.gz
编译配置
1、配置环境变量
编辑~/.bashrc
文件,添加以下内容:
export HADOOP_HOME=/path/to/hadoop-2.2.0 export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
然后执行以下命令使配置生效:
source ~/.bashrc
2、配置编译选项
进入Hadoop源码目录,执行以下命令进行编译配置:
cd $HADOOP_HOME/build/hadoop-2.2.0/src/contrib/mapred/hadoop-streaming sh build_hadoop.sh --without-thrift --without-nifi --with-java-opt="-Xmx4g" --with-streaming --with-native-hadoop --num-cores=4 --make-target=make-distribution gpl-jdk6-amd64 contrib/streaming/hadoop-streaming-*.jar && cd $HADOOP_HOME/build/hadoop-2.2.0/src/contrib/mapred/hadoop-streaming && find . ! -name "*.svn" ! -name "*.git" ! -name "*.md5" ! -name "*.sha1" ! -name "*.sha512" | xargs rm -rf && find . ! -name "*.svn" ! -name "*.git" ! -name "*.md5" ! -name "*.sha1" ! -name "*.sha512" | xargs chmod a+x && find . ! -name "*.svn" ! -name "*.git" ! -name "*.md5" ! -name "*.sha1" ! -name "*.sha512" | xargs sudo chmod a+rx && find .! -name 'Makefile' | xargs sudo chmod a+rwx && find .! -name 'Makefile' | xargs sudo chmod a+rwX && find .! -name 'Makefile' | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xargs sudo chmod a+rwX && find * | xargs sudo chmod a+rwx && find * | xpath '/usr/local/bin' | xargs sudo chmod ugo+x && exit;
3、编译并打包Hadoop
执行以下命令进行编译并打包:
cd $HADOOP_HOME/build/hadoop-2.2.0/src/contrib/mapred/hadoop-streaming || exit; sh makedistcp || exit; cd $HADOOP_HOME/build/hadoop-2.2.0 || exit; sh build_hadoop || exit; cd $HADOOP_HOME || exit; tar zcvf hdfsnative-2.2.0-bin.tar.gz lib native etc conf share libexec share/man man8 man1 man5 bashrc logrotate scripts scripts/metastore scripts/hdfs scripts/mapred scripts/topologyscripts scripts/yarn scripts/historyserver scripts/jobhistoryserver scripts/tasktracker scripts/tasklogaggregator scripts/datanode scripts/secondarynamenode scripts/resourcemanager scripts/fairscheduler scripts/capacityscheduler scripts/yarnservice scriptlib/* testdocs jar testjars examples examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesext jar ext jarext examples ext examplesextjars bin logs tmp share tools classes core test release notes changelog README config docs jars tree site xml history logs images patches checksums downloads help info faq license community project support contributing contributing guide developer guide design guide api reference documentation releases downloads source code thirdparty thirdparty overview thirdparty licenses thirdparty integration thirdparty development thirdparty testing thirdparty bugzilla thirdparty mailing lists thirdparty wiki thirdparty forum thirdparty blog thirdparty documentation thirdparty news thirdparty resources thirdparty support thirdparty community thirdparty developers thirdparty contributors thirdparty designers thirdparty developers thirdparty testers thirdparty bug reporters thirdparty issue tracker thirdparty feedback thirdparty support thirdparty community thirdparty developers thirdparty contributors thirdparty designers thirdparty developers thirdparty testers thirdparty bug reporters thirdparty issue tracker thirdparty feedback thirdparty supportthirdparm files include lib conf etc share lib libexec share man man8 man1 man5 bashrc logrotate scripts scripts/metastore scripts/hdfs scripts/mapred scripts/topologyscripts scripts/yarn scripts/historyserver scripts/jobhistoryserver scripts/tasktracker scripts/tasklogaggregator scripts/datanode scripts/secondarynamenode scripts/resourcemanager scripts/fairscheduler scripts/capacityscheduler scripts/yarnservice scriptlib/* testdocs jars testjars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjarstestdocs jars testjar
原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/140920.html