使用git管理属于自己的hadoop源代码

基本工具安装

  • 申请github账号
    去github官网申请账号:
    https://github.com/
    比如,申请了一个这样的账号:test
  • 本地安装git工具
brew install git
  • 配置git
    • 生成使用git用户的ssh公私钥(由于我使用hadoop用户进行hadoop源码编译所以是生成hadoop用户的公钥)
    	ssh-****** -t rsa -C "youremail" 
    
    成功后在用户主目录下会生成.ssh目录,其中包含3个文件:
    [[email protected] .ssh]$ ll
    -rw-------. 1 hadoop hadoop 1197 1月  18 12:49 authorized_keys
    -rw-------. 1 hadoop hadoop 1679 1月  18 12:40 id_rsa
    -rw-------. 1 hadoop hadoop  391 1月  18 12:40 id_rsa.pub
    -rw-------. 1 hadoop hadoop 1061 1月  19 00:20 、known_hosts
    
    • 登录github账号后,访问个人账号设置栏目,具体为如下链接,把生成的公钥拷贝进来。
      https://github.com/settings/keys
      hadoop源码分析 编译hadoop源码
    • 配置本地git
    git config --global user.name “test”
    git config --global user.email "[email protected]"
    git init
    ssh -T [email protected]					(测试是否可以配置OK)
    

    hadoop源码下载

    • 下载hadoop-3.2.0源码
      在GitHub官网搜索hadoop
      hadoop源码分析 编译hadoop源码
    • 进入hadoop源码目录后,将源码fork到自己的账号下。
      https://github.com/apache/hadoop
      hadoop源码分析 编译hadoop源码
    • 选择hadoop-3.2.0这个branch,查看3.2.0源码。
      hadoop源码分析 编译hadoop源码
    • 将hadoop-3.2.0源码git clone到本地。
      mkdir gitLocalRepo
      cd gitLocalRepo/
      git clone -b branch-3.2.0 https://github.com/test/hadoop.git		(test是自己在github的工程目录)
    
    完毕后会在gitLocalRepo下看到创建的hadoop源码目录,有如下文件。
    hadoop源码分析 编译hadoop源码
    至此,hadoop-3.2.0源码准备完毕。

编译hadoop源码

安装编译工具

-阅读BUILDING.txt文件中,得到需要安装如下工具。

----------------------------------------------------------------------------------
Requirements:

* Unix System
* JDK 1.8
* Maven 3.3 or later
* ProtocolBuffer 2.5.0
* CMake 3.1 or newer (if compiling native code)
* Zlib devel (if compiling native code)
* Cyrus SASL devel (if compiling native code)
* One of the compilers that support thread_local storage: GCC 4.8.1 or later, Visual Studio,
  Clang (community version), Clang (version for iOS 9 and later) (if compiling native code)
* openssl devel (if compiling native hadoop-pipes and to get the best HDFS encryption performance)
* Linux FUSE (Filesystem in Userspace) version 2.6 or above (if compiling fuse_dfs)
* Jansson C XML parsing library ( if compiling libwebhdfs )
* Doxygen ( if compiling libhdfspp and generating the documents )
* Internet connection for first build (to fetch all Maven and Hadoop dependencies)
* python (for releasedocs)
* bats (for shell code testing)
* Node.js / bower / Ember-cli (for YARN UI v2 building)
----------------------------------------------------------------------------------

根据要求,安装好以上工具后开始编译hadoop源码

编译

以上准备工作做完之后,切换到源码根目录(即~/gitLocalRepo/hadoop),执行编译打包命令:

mvn package -Pdist,native,docs -DskipTests -Dtar

这个过程,时间会比较久。

相关文章:

猜你喜欢
相关资源
相似解决方案