美文网首页
hadoop的三种运行模式的配置

hadoop的三种运行模式的配置

作者: 大熊的Yowai | 来源:发表于2020-05-03 23:55 被阅读0次

    伪分布式模式

    Hadoop-env.sh

    export JAVA_HOME=/home/yowai/Desktop/module/jdk
    

    Yarn-env.sh

    export JAVA_HOME=/home/yowai/Desktop/module/jdk
    

    Mapped-env.sh

    export JAVA_HOME=/home/yowai/Desktop/module/jdk
    

    Core-site.xml

    <property>
        <name>fs.defaultFs</name>
        <value>hdfs://slave1:9000</value>
    </property>
    
    <!-- 指定Hadoop运行时产生文件的存储目录 -->
    
    <property>
        <name>hadoop.tmp.dir</name>
        <value>/home/yowai/Desktop/module/hadoop/data/tmp</value>
    </property>
    

    Hdfs-site.xml

    <!-- 指定HDFS副本的数量 -->
    <property>
        <name>dfs.replication</name>
        <value>1</value>
    </property>
    
    

    Yarn-site.xml

    <!-- Reducer获取数据的方式 -->
    <property>
            <name>yarn.nodemanager.aux-services</name>
            <value>mapreduce_shuffle</value>
    </property>
    
    <!-- 指定YARN的ResourceManager的地址 -->
    <property>
    <name>yarn.resourcemanager.hostname</name>
    <value>slave1</value>
    </property>
    

    Mapred-site.xml

    <!-- 指定MR运行在YARN上 -->
    <property>
            <name>mapreduce.framework.name</name>
            <value>yarn</value>
    </property>
    

    Slaves

    slave1
    

    完全分布式

    集群规划

    slave1 slave2 slave3
    hdfs Namenode/Datanode Datanode Secondarynamenode/Datanode
    yarn Nodemanager Resourmanager/Nodemanager Nodemanager

    Hadoop-env.sh

    export JAVA_HOME=/home/yowai/Desktop/module/jdk
    

    Yarn-env.sh

    export JAVA_HOME=/home/yowai/Desktop/module/jdk
    

    Mapped-env.sh

    export JAVA_HOME=/home/yowai/Desktop/module/jdk
    

    Core-site.xml

    <property>
        <name>fs.defaultFs</name>
        <value>hdfs://slave1:9000</value>
    </property>
    
    <!-- 指定Hadoop运行时产生文件的存储目录 -->
    
    <property>
        <name>hadoop.tmp.dir</name>
        <value>/home/yowai/Desktop/module/hadoop/data/tmp</value>
    </property>
    

    Hdfs-site.xml

    <property>
        <name>dfs.replication</name>
      <value>3</value>
    </property>
    
    
    <!-- 指定Hadoop辅助名称节点主机配置 -->
    <property>
       <name>dfs.namenode.secondary.http-address</name>
       <value>slave3:50090</value>
    </property>
    

    Yarn-site.xml

    yarn历史服务

    <!-- Reducer获取数据的方式 -->
    <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
    </property>
    
    
    <!-- 指定YARN的ResourceManager的地址 -->
    <property>
        <name>yarn.resourcemanager.hostname</name>
        <value>slave2</value>
    </property>
    
    <!-- 日志聚集功能使能 -->
    <property>
    <name>yarn.log-aggregation-enable</name>
    <value>true</value>
    </property>
    
    <!-- 日志保留时间设置7天 -->
    <property>
    <name>yarn.log-aggregation.retain-seconds</name>
    <value>604800</value>
    </property>
    
    

    Mapred-site.xml

    <!-- 指定MR运行在YARN上 -->
    <property>
            <name>mapreduce.framework.name</name>
            <value>yarn</value>
    </property>
    
    <!-- 历史服务器端地址 -->
    <property>
    <name>mapreduce.jobhistory.address</name>
    <value>slave1:10020</value>
    </property>
    <!-- 历史服务器web端地址 -->
    <property>
        <name>mapreduce.jobhistory.webapp.address</name>
        <value>slave1:19888</value>
    </property>
    
    

    Slaves

    注意:该文件中添加的内容结尾不允许有空格,文件中不允许有空行。

    slave1
    slave2
    slave3
    

    高可用

    Core-site.xml

    <configuration>
        <!-- 指定HDFS中NameNode的地址 -->
    <property>
        <name>fs.defaultFS</name>
       <value>hdfs://slave1:9000</value>
    </property>
    
    <!-- 指定Hadoop运行时产生文件的存储目录 -->
    <property>
        <name>hadoop.tmp.dir</name>
        <value>/home/yowai/Desktop/module/hadoop/data/tmp</value>
    </property>
    
     <!--指定zookeeper地址-->
        <property>
            <name>ha.zookeeper.quorum</name>
            <value>slave1:2181,slave2:2181,slave3:2181</value>
        </property>
    </configuration>
    

    Hdfs-site.xml

    <configuration>
    
        <!-- 副本数 -->
        <property>
           <name>dfs.replication</name>
           <value>2</value>
        </property>
        <!-- 完全分布式集群名称 -->
        <property>
            <name>dfs.nameservices</name>
            <value>mycluster</value>
        </property>
    
        <!-- 集群中NameNode节点都有哪些 -->
        <property>
            <name>dfs.ha.namenodes.mycluster</name>
            <value>nn1,nn2</value>
        </property>
    
        <!-- nn1的RPC通信地址 -->
        <property>
            <name>dfs.namenode.rpc-address.mycluster.nn1</name>
            <value>slave1:9000</value>
        </property>
    
        <!-- nn2的RPC通信地址 -->
        <property>
            <name>dfs.namenode.rpc-address.mycluster.nn2</name>
            <value>slave2:9000</value>
        </property>
    
        <!-- nn1的http通信地址 -->
        <property>
            <name>dfs.namenode.http-address.mycluster.nn1</name>
            <value>slave1:50070</value>
        </property>
    
        <!-- nn2的http通信地址 -->
        <property>
            <name>dfs.namenode.http-address.mycluster.nn2</name>
            <value>slave2:50070</value>
        </property>
    
        <!-- 指定NameNode元数据在JournalNode上的存放位置 -->
        <property>
            <name>dfs.namenode.shared.edits.dir</name>
        <value>qjournal://slave1:8485;slave2:8485;slave3:8485/mycluster</value>
        </property>
    
        <!-- 配置隔离机制,即同一时刻只能有一台服务器对外响应 -->
        <property>
            <name>dfs.ha.fencing.methods</name>
            <value>sshfence</value>
        </property>
    
        <!-- 使用隔离机制时需要ssh无秘钥登录-->
        <property>
            <name>dfs.ha.fencing.ssh.private-key-files</name>
            <value>/home/yowai/.ssh/id_rsa</value>
        </property>
    
        <!-- 声明journalnode服务器存储目录-->
        <property>
            <name>dfs.journalnode.edits.dir</name>
            <value>/home/yowai/Desktop/module/hadoop/data/journalnode</value>
        </property>
    
        <!-- 关闭权限检查-->
        <property>
            <name>dfs.permissions.enable</name>
            <value>false</value>
        </property>
    
        <!-- 访问代理类:client,mycluster,active配置失败自动切换实现方式-->
        <property>
            <name>dfs.client.failover.proxy.provider.mycluster</name>
            <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
        </property>
    
        <!-- 开启NameNode故障时自动切换 -->
        <property>
            <name>dfs.ha.automatic-failover.enabled</name>
            <value>true</value>
        </property>
    
    </configuration>
    

    yarn-site

    <configuration>
    
    <!-- Site specific YARN configuration properties -->
    
    
        <property>
            <name>yarn.nodemanager.aux-services</name>
            <value>mapreduce_shuffle</value>
        </property>
    
        <!--启用resourcemanager ha-->
        <property>
            <name>yarn.resourcemanager.ha.enabled</name>
            <value>true</value>
        </property>
     
        <!--声明两台resourcemanager的地址-->
        <property>
            <name>yarn.resourcemanager.cluster-id</name>
            <value>cluster-yarn1</value>
        </property>
    
        <property>
            <name>yarn.resourcemanager.ha.rm-ids</name>
            <value>rm1,rm2</value>
        </property>
    
        <property>
            <name>yarn.resourcemanager.hostname.rm1</name>
            <value>slave1</value>
        </property>
    
        <property>
            <name>yarn.resourcemanager.hostname.rm2</name>
            <value>slave2</value>
        </property>
     
        <!--指定zookeeper集群的地址--> 
        <property>
            <name>yarn.resourcemanager.zk-address</name>
            <value>slave1:2181,slave2:2181,slave3:2181</value>
        </property>
    
        <!--启用自动恢复--> 
        <property>
            <name>yarn.resourcemanager.recovery.enabled</name>
            <value>true</value>
        </property>
     
        <!--指定resourcemanager的状态信息存储在zookeeper集群--> 
        <property>
            <name>yarn.resourcemanager.store.class</name>     
            <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
        </property>
    
    
        <!-- 日志聚集功能使能 -->
        <property>
        <name>yarn.log-aggregation-enable</name>
        <value>true</value>
        </property>
    
        <!-- 日志保留时间设置7天 -->
        <property>
        <name>yarn.log-aggregation.retain-seconds</name>
        <value>604800</value>
        </property>
    
    </configuration>
    

    相关文章

      网友评论

          本文标题:hadoop的三种运行模式的配置

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