美文网首页我爱编程
使用docker-compose搭建hadoop分布式集群

使用docker-compose搭建hadoop分布式集群

作者: 彩虹之梦 | 来源:发表于2018-03-09 14:41 被阅读0次

    参考文档:

    http://blog.csdn.net/wenwenxiong/article/details/78973755
    https://github.com/big-data-europe/docker-hadoop

    前置条件:

    安装好docker和docker-compose

    新建配置文件

    vim docker-compose.yml

    在配置文件中加入以下配置:

    version: "2"
    
    services:
      namenode:
        image: bde2020/hadoop-namenode:1.1.0-hadoop2.7.1-java8
        container_name: namenode
        volumes:
          - hadoop_namenode:/hadoop/dfs/name
        environment:
          - CLUSTER_NAME=test
        env_file:
          - ./hadoop.env
        ports:
          - "9999:50070"
      
      resourcemanager:
        image: bde2020/hadoop-resourcemanager:1.1.0-hadoop2.7.1-java8
        container_name: resourcemanager
        depends_on:
          - namenode
          - datanode1
          - datanode2
        env_file:
          - ./hadoop.env
        ports:
          - "8088:8088"
      historyserver:
        image: bde2020/hadoop-historyserver:1.1.0-hadoop2.7.1-java8
        container_name: historyserver
        depends_on:
          - namenode
          - datanode1
          - datanode2
        volumes:
          - hadoop_historyserver:/hadoop/yarn/timeline
        env_file:
          - ./hadoop.env
        ports:
          - "8188:8188"
      
      nodemanager1:
        image: bde2020/hadoop-nodemanager:1.1.0-hadoop2.7.1-java8
        container_name: nodemanager1
        depends_on:
          - namenode
          - datanode1
          - datanode2
        env_file:
          - ./hadoop.env
        ports:
          - "8042:8042"
      
      datanode1:
        image: bde2020/hadoop-datanode:1.1.0-hadoop2.7.1-java8
        container_name: datanode1
        depends_on:
          - namenode
        volumes:
          - hadoop_datanode1:/hadoop/dfs/data
        env_file:
          - ./hadoop.env
      
      datanode2:
        image: bde2020/hadoop-datanode:1.1.0-hadoop2.7.1-java8
        container_name: datanode2
        depends_on:
          - namenode
        volumes:
          - hadoop_datanode2:/hadoop/dfs/data
        env_file:
          - ./hadoop.env
      
      datanode3:
        image: bde2020/hadoop-datanode:1.1.0-hadoop2.7.1-java8
        container_name: datanode3
        depends_on:
          - namenode
        volumes:
          - hadoop_datanode3:/hadoop/dfs/data
        env_file:
          - ./hadoop.env
    
    volumes:
      hadoop_namenode:
      hadoop_datanode1:
      hadoop_datanode2:
      hadoop_datanode3:
      hadoop_historyserver:
    

    在当前目录新建文件:hadoop.env

    vi hadoop.env

    加入以下配置:

    CORE_CONF_fs_defaultFS=hdfs://namenode:8020
    CORE_CONF_hadoop_http_staticuser_user=root
    CORE_CONF_hadoop_proxyuser_hue_hosts=*
    CORE_CONF_hadoop_proxyuser_hue_groups=*
    
    HDFS_CONF_dfs_webhdfs_enabled=true
    HDFS_CONF_dfs_permissions_enabled=false
    
    YARN_CONF_yarn_log___aggregation___enable=true
    YARN_CONF_yarn_resourcemanager_recovery_enabled=true
    YARN_CONF_yarn_resourcemanager_store_class=org.apache.hadoop.yarn.server.resourcemanager.recovery.FileSystemRMStateStore
    YARN_CONF_yarn_resourcemanager_fs_state___store_uri=/rmstate
    YARN_CONF_yarn_nodemanager_remote___app___log___dir=/app-logs
    YARN_CONF_yarn_log_server_url=http://historyserver:8188/applicationhistory/logs/
    YARN_CONF_yarn_timeline___service_enabled=true
    YARN_CONF_yarn_timeline___service_generic___application___history_enabled=true
    YARN_CONF_yarn_resourcemanager_system___metrics___publisher_enabled=true
    YARN_CONF_yarn_resourcemanager_hostname=resourcemanager
    YARN_CONF_yarn_timeline___service_hostname=historyserver
    YARN_CONF_yarn_resourcemanager_address=resourcemanager:8032
    YARN_CONF_yarn_resourcemanager_scheduler_address=resourcemanager:8030
    YARN_CONF_yarn_resourcemanager_resource___tracker_address=resourcemanager:8031
    

    构建启动容器

    docker-compose up -d

    访问:访问时使用容器的IP替换下面域名

    Namenode: http://namenode:50070/dfshealth.html#tab-overview
    History server: http://historyserver:8188/applicationhistory
    Datanode: http://datanode:50075/
    Nodemanager: http://nodemanager:8042/node
    Resource manager: http://resourcemanager:8088/
    
    image.png image.png

    相关文章

      网友评论

        本文标题:使用docker-compose搭建hadoop分布式集群

        本文链接:https://www.haomeiwen.com/subject/dqbpfftx.html