前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Hadoop基础教程-第13章 源码编译(13.1 Zookeeper源码编译)

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

作者头像
程裕强
发布2018-01-02 16:36:14
8940
发布2018-01-02 16:36:14
举报

第13章 源码编译

13.1 Zookeeper源码编译

13.1.1 安装Ant

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

解压缩

代码语言:javascript
复制
[root@hadron ~]# cd apache-ant-1.9.4/
[root@hadron apache-ant-1.9.4]# ll
总用量 380
drwxr-xr-x 2 root root   4096 4月  30 2014 bin
drwxr-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 KEYS
drwxr-xr-x 2 root root   4096 4月  30 2014 lib
-rw-r--r-- 1 root root  15289 4月  30 2014 LICENSE
drwxr-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源码

代码语言:javascript
复制
[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
总用量 160
drwxr-xr-x 2 root root  4096 7月  26 09:45 bin
-rw-r--r-- 1 root root 82419 7月  26 09:45 build.xml
drwxr-xr-x 2 root root  4096 7月  26 09:45 conf
drwxr-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.txt
drwxr-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 查看文档

代码语言:javascript
复制
[root@hadron zookeeper]# cat README_packaging.txt 
README file for Packaging Notes

Requirement
-----------

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 cppunit
yum install python-setuptools

On Ubuntu:

apt-get --install cppunit
apt-get --install python-setuptools

Package build command
---------------------

The ZooKeeper project publishes releases as tarballs.  For ZooKeeper packages
specific to your OS (such as rpm and deb), consider using Apache Bigtop:

http://bigtop.apache.org/

Command to build tarball package: ant tar

zookeeper-<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 files

Command to build tarball package with native components: ant package-native tar

zookeeper-<version>-lib.tar.gz tarball file structure layout

  /bin                               - User executable
  /lib                               - Native libraries
  /include/zookeeper                 - Native library headers

13.1.4 安装依赖工具

代码语言:javascript
复制
[root@hadron ~]# yum install -y cppunit
[root@hadron ~]# yum install -y python-setuptools

13.1.5 开始编译

(1)初次编译

代码语言:javascript
复制
[root@hadron zookeeper]# /root/apache-ant-1.9.4/bin/ant tar
Buildfile: /root/zookeeper/build.xml

init:
    [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: 1

Total time: 30 seconds
[root@hadron zookeeper]# 

(2)解决缺失依赖

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

代码语言:javascript
复制
[root@hadron ~]# yum install automake

(3)重新编译

代码语言:javascript
复制
[root@hadron zookeeper]# /root/apache-ant-1.9.4/bin/ant tar
Buildfile: /root/zookeeper/build.xml

init:
.....................
输出省略
.....................

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/classes

jar:
     [echo] recipes: queue
      [jar] Building jar: /root/zookeeper/build/recipes/queue/zookeeper-3.6.0-SNAPSHOT-recipes-queue.jar

zookeeperbuildrecipes.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/queue

package:
     [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/src

tar:
      [tar] Building tar: /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT.tar.gz

BUILD SUCCESSFUL
Total time: 1 minute 27 seconds
您在 /var/spool/mail/root 中有新邮件
[root@hadron zookeeper]# 

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

代码语言:javascript
复制
[root@hadron zookeeper]# ll /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT.tar.gz
-rw-r--r-- 1 root root 18418052 7月  26 11:02 /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT.tar.gz
[root@hadron zookeeper]#
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-08-28 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 第13章 源码编译
  • 13.1 Zookeeper源码编译
    • 13.1.1 安装Ant
      • 13.1.2 下载Zookeeper源码
        • 13.1.3 查看文档
          • 13.1.4 安装依赖工具
            • 13.1.5 开始编译
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档