Docker中编译Hadoop

1.安装Docker

参考链接:https://docs.docker.com/docker-for-mac/install/

2.创建/运行docker

2.1拉取指定版本的镜像:

docker pull centos:6.8

2.2查看本地的镜像:

  docker images
  REPOSITORY          TAG                 IMAGE ID            CREATED            SIZE
  centos              6.8                 e54faac158ff        3 days ago          195MB

2.3创建新的容器

docker create --name hadoopbase centos:6.8 (也可以使用docker run 命令)

2.4查看现有的容器:docker ps -a

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS            NAMES
05501c020235        centos:6.8          "/bin/bash"         15 hours ago        Up 4 hours                           hadoopbase

2.5启动容器:

   docker start hadoopbase

2.6进入容器:

  docker exec -it hadoopbase  bash

2.7进入docker之后,下载相关的软件(由于docker镜像基本上都是最小化的,需要自己安装需要的软件,例如 yum install wget):

软件 版本 下载路径
jdk 1.8_181 http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz?AuthParam=1539399760_7c4fbd18cf9c338bfd7394a95b08ca56
maven 3.5.4 https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
protobuf 2.5.0 https://github.com/protocolbuffers/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
snappy 1.1.1 http://pkgs.fedoraproject.org/repo/pkgs/snappy/snappy-1.1.1.tar.gz/8887e3b7253b22a31f5486bca3cbc1c2/snappy-1.1.1.tar.gz
findbugs 3.0.1 http://prdownloads.sourceforge.net/findbugs/findbugs-3.0.1.tar.gz?download
hadoop 2.7.3 http://archive.apache.org/dist/hadoop/core/hadoop-2.7.3/hadoop-2.7.3-src.tar.gz

2.8安装jdk、maven.

 a.解压文件:
    tar -zxvf jdk-8u181-linux-x64.tar.gz / tar -zxvf apache-maven-3.5.4-bin.tar.gz
 b.配置环境变量 
    vi /etc/profile
    export JAVA_HOME=/usr/local/jdk1.8.0_181
    export MAVEN_HOME=/usr/local/apache-maven-3.5.4
    export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
c.生效文件 
    source /etc/profile
d.验证
    mvn -v / java -version

2.9安装 protobuf/snappy

a.解压文件
     tar -zxvf  protobuf-2.5.0.tar.gz / tar -zxvf snappy-1.1.1.tar.gz
b.编译
     ./configure
c.安装
     make && make install

2.10安装其他包

yum install svn autoconf automake libtool cmake ncurses-devel openssl-devel gcc*

2.11编译Hadoop

a.解压Hadoop文件
tar -zxvf hadoop-2.7.3-src.tar.gz
b.运行mvn命令:
mvn clean package -Pdist,native -DskipTests -Dtar或mvn package -Pdist,native -DskipTests -Dtar
c.在命令运行完之后,可以在hadoop-dist/target 中看到hadoop-2.7.3.tar.gz 文件,即证明编译成功

2.12编译错误参考文件:

https://github.com/apache/hadoop/blob/trunk/BUILDING.txt
http://blog.sina.com.cn/s/blog_605f5b4f0101e8o2.html
https://www.cnblogs.com/shenh062326/p/3562491.html

你可能感兴趣的:(Docker中编译Hadoop)