Hadoop基础教程-第13章 源码编译(13.1 Zookeeper源码编译)

来源:互联网 发布:java junit jar 编辑:程序博客网 时间:2024/05/22 19:54

第13章 源码编译

13.1 Zookeeper源码编译


13.1.1 安装Ant

注意,不要下载最新版,下载指定版本
http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.4-bin.tar.gz

解压缩

[root@hadron ~]# cd apache-ant-1.9.4/[root@hadron apache-ant-1.9.4]# ll总用量 380drwxr-xr-x 2 root root   4096 4月  30 2014 bindrwxr-xr-x 3 root root   4096 4月  30 2014 etc-rw-r--r-- 1 root root  11253 4月  30 2014 fetch.xml-rw-r--r-- 1 root root   4445 4月  30 2014 get-m2.xml-rw-r--r-- 1 root root    126 4月  30 2014 INSTALL-rw-r--r-- 1 root root  92261 4月  30 2014 KEYSdrwxr-xr-x 2 root root   4096 4月  30 2014 lib-rw-r--r-- 1 root root  15289 4月  30 2014 LICENSEdrwxr-xr-x 8 root root   4096 4月  30 2014 manual-rw-r--r-- 1 root root    305 4月  30 2014 NOTICE-rw-r--r-- 1 root root   4119 4月  30 2014 README-rw-r--r-- 1 root root 225057 4月  30 2014 WHATSNEW[root@hadron apache-ant-1.9.4]#

13.1.2 下载Zookeeper源码

[root@hadron ~]# git clone https://github.com/apache/zookeeper.git正克隆到 'zookeeper'...remote: Counting objects: 35618, done.remote: Compressing objects: 100% (11/11), done.remote: Total 35618 (delta 0), reused 5 (delta 0), pack-reused 35606接收对象中: 100% (35618/35618), 28.06 MiB | 81.00 KiB/s, done.处理 delta 中: 100% (23152/23152), done.您在 /var/spool/mail/root 中有新邮件[root@hadron ~]# cd zookeeper/[root@hadron zookeeper]# ll总用量 160drwxr-xr-x 2 root root  4096 7月  26 09:45 bin-rw-r--r-- 1 root root 82419 7月  26 09:45 build.xmldrwxr-xr-x 2 root root  4096 7月  26 09:45 confdrwxr-xr-x 4 root root  4096 7月  26 09:45 docs-rw-r--r-- 1 root root  1709 7月  26 09:45 ivysettings.xml-rw-r--r-- 1 root root  4132 7月  26 09:45 ivy.xml-rw-r--r-- 1 root root 11358 7月  26 09:45 LICENSE.txt-rw-r--r-- 1 root root   170 7月  26 09:45 NOTICE.txt-rw-r--r-- 1 root root  1347 7月  26 09:45 README_packaging.txt-rw-r--r-- 1 root root  1636 7月  26 09:45 README.txtdrwxr-xr-x 7 root root  4096 7月  26 09:45 src-rw-r--r-- 1 root root 21462 7月  26 09:45 zk-merge-pr.py[root@hadron zookeeper]# 

13.1.3 查看文档

[root@hadron zookeeper]# cat README_packaging.txt README file for Packaging NotesRequirement-----------ant (recommended version 1.9.4 or later for concurrent JUnit test execution)gcc, cppunit and python-setuptools are required to build C and python bindings.On RHEL machine:yum install cppunityum install python-setuptoolsOn Ubuntu:apt-get --install cppunitapt-get --install python-setuptoolsPackage build command---------------------The ZooKeeper project publishes releases as tarballs.  For ZooKeeper packagesspecific to your OS (such as rpm and deb), consider using Apache Bigtop:http://bigtop.apache.org/Command to build tarball package: ant tarzookeeper-<version>.tar.gz tarball file structure layout  /bin                               - User executable  /sbin                              - System executable  /libexec                           - Configuration boot trap script  /lib                               - Library dependencies  /docs                              - Documents  /share/zookeeper                   - Project filesCommand to build tarball package with native components: ant package-native tarzookeeper-<version>-lib.tar.gz tarball file structure layout  /bin                               - User executable  /lib                               - Native libraries  /include/zookeeper                 - Native library headers

13.1.4 安装依赖工具

[root@hadron ~]# yum install -y cppunit[root@hadron ~]# yum install -y python-setuptools

13.1.5 开始编译

(1)初次编译

[root@hadron zookeeper]# /root/apache-ant-1.9.4/bin/ant tarBuildfile: /root/zookeeper/build.xmlinit:    [mkdir] Created dir: /root/zookeeper/build/classes    [mkdir] Created dir: /root/zookeeper/build/lib    [mkdir] Created dir: /root/zookeeper/build/package/lib    [mkdir] Created dir: /root/zookeeper/build/test/lib........check-cppunit-configure:create-cppunit-configure:     [exec] Can't exec "aclocal": 没有那个文件或目录 at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.     [exec] autoreconf: failed to run aclocal: 没有那个文件或目录BUILD FAILED/root/zookeeper/build.xml:1276: exec returned: 1Total time: 30 seconds[root@hadron zookeeper]# 

(2)解决缺失依赖

解决问题:Can’t exec “aclocal”: 没有那个文件或目录 at /usr/share/autoconf/Autom4te/FileUtils.pm line 326

[root@hadron ~]# yum install automake

(3)重新编译

[root@hadron zookeeper]# /root/apache-ant-1.9.4/bin/ant tarBuildfile: /root/zookeeper/build.xmlinit:.....................输出省略.....................compile:     [echo] contrib: queue    [javac] /root/zookeeper/src/recipes/build-recipes.xml:103: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds    [javac] Compiling 1 source file to /root/zookeeper/build/recipes/queue/classesjar:     [echo] recipes: queue      [jar] Building jar: /root/zookeeper/build/recipes/queue/zookeeper-3.6.0-SNAPSHOT-recipes-queue.jarzookeeperbuildrecipes.package:     [echo] recipes: queue    [mkdir] Created dir: /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue     [copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queuepackage:     [copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue    [mkdir] Created dir: /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue/test     [copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue/test    [mkdir] Created dir: /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue/src     [copy] Copying 16 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue/src     [copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT    [mkdir] Created dir: /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/dist-maven     [copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/dist-maven     [copy] Copying 2 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/dist-maven     [copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/dist-maven     [copy] Copying 9 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/bin     [copy] Copying 3 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/conf     [copy] Copying 350 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/docs     [copy] Copying 7 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT     [copy] Copying 1104 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/srctar:      [tar] Building tar: /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT.tar.gzBUILD SUCCESSFULTotal time: 1 minute 27 seconds您在 /var/spool/mail/root 中有新邮件[root@hadron zookeeper]# 

注意输出信息BUILD SUCCESSFUL,表示编译成功!
(4)查看tar包

[root@hadron zookeeper]# ll /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT.tar.gz-rw-r--r-- 1 root root 18418052 726 11:02 /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT.tar.gz[root@hadron zookeeper]#
原创粉丝点击