yum安装CDH5.5 Hadoop集群(4)

#查看nn1状态
$ sudo -u hdfs hdfs haadmin -getServiceState bd-ops-test-74
active
 
#查看nn2状态
$ sudo -u hdfs hdfs haadmin -getServiceState bd-ops-test-75
standby

执行手动切换:

sudo -u hdfs hdfs haadmin -failover bd-ops-test-74 bd-ops-test-75

再次访问 :50070/ 和 :50070/ 查看谁是 active namenode,谁是 standyby namenode。

5、安装和配置YARN(HA模式)
根据文章开头的节点规划,74、75 为resourcemanager节点,74,、75、76、77 为nodemanager节点,historyserver 装在 76 节点上。

5.1 安装服务
在74,75安装:

yum install hadoop-yarn hadoop-yarn-resourcemanager -y

在74-77安装:

yum install hadoop-yarn hadoop-yarn-nodemanager hadoop-mapreduce -y

在76安装:

yum install hadoop-mapreduce-historyserver hadoop-yarn-proxyserver -y

5.2修改配置文件
要想使用YARN,需要在 /etc/hadoop/conf/mapred-site.xml 中做如下配置:

<property>
    <name>mapreduce.framework.name</name>
    <value>yarn</value>
</property>

修改/etc/hadoop/conf/yarn-site.xml,配置resourcemanager的节点名称、一些服务的端口号以及ha的配置:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="https://www.linuxidc.com/configuration.xsl"?>
 
<configuration>
    <!-- RM Manager Configd -->
    <property>
        <name>yarn.resourcemanager.connect.retry-interval.ms</name>
        <value>2000</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.ha.enabled</name>
        <value>true</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.ha.automatic-failover.enabled</name>
        <value>true</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.ha.automatic-failover.embedded</name>
        <value>true</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.cluster-id</name>
        <value>yarn-rm-cluster</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.ha.rm-ids</name>
        <value>bd-ops-test-74,bd-ops-test-75</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.ha.id</name>
        <value>bd-ops-test-74</value>
    </property>
 
    <!--
            <property>
        <name>yarn.resourcemanager.scheduler.class</name>
        <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>
    </property>
    -->
 
    <!--scheduler capacity -->
    <property>
        <name>yarn.resourcemanager.scheduler.class</name>
        <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.recovery.enabled</name>
        <value>true</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.store.class</name>
        <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.zk-address</name>
        <value>bd-ops-test-75:2181,bd-ops-test-76:2181,bd-ops-test-77:2181</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.zk.state-store.address</name>
        <value>bd-ops-test-75:2181,bd-ops-test-76:2181,bd-ops-test-77:2181</value>
    </property>
 
    <property>
        <name>yarn.app.mapreduce.am.scheduler.connection.wait.interval-ms</name>
        <value>5000</value>
    </property>
 
    <!-- RM1 Configs-->
    <property>
        <name>yarn.resourcemanager.address.bd-ops-test-74</name>
        <value>bd-ops-test-74:23140</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.scheduler.address.bd-ops-test-74</name>
        <value>bd-ops-test-74:23130</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.webapp.https.address.bd-ops-test-74</name>
        <value>bd-ops-test-74:23189</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.webapp.address.bd-ops-test-74</name>
        <value>bd-ops-test-74:23188</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.resource-tracker.address.bd-ops-test-74</name>
        <value>bd-ops-test-74:23125</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.admin.address.bd-ops-test-74</name>
        <value>bd-ops-test-74:23141</value>
    </property>
 
 
    <!-- RM2 Configs -->
    <property>
        <name>yarn.resourcemanager.address.bd-ops-test-75</name>
        <value>bd-ops-test-75:23140</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.scheduler.address.bd-ops-test-75</name>
        <value>bd-ops-test-75:23130</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.webapp.https.address.bd-ops-test-75</name>
        <value>bd-ops-test-75:23189</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.webapp.address.bd-ops-test-75</name>
        <value>bd-ops-test-75:23188</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.resource-tracker.address.bd-ops-test-75</name>
        <value>bd-ops-test-75:23125</value>
    </property>
 
    <property>
        <name>yarn.resourcemanager.admin.address.bd-ops-test-75</name>
        <value>bd-ops-test-75:23141</value>
    </property>
 
    <!-- Node Manager Configs -->
    <property>
        <name>yarn.nodemanager.resource.memory-mb</name>
        <value>61440</value>
    </property>
 
    <property>
        <name>yarn.nodemanager.resource.cpu-vcores</name>
        <value>24</value>
    </property>
 
    <property>
        <name>yarn.log-aggregation.retain-seconds</name>
        <value>86400</value>
    </property>
 
    <property>
        <name>yarn.log-aggregation.retain-check-interval-seconds</name>
        <value>8640</value>
    </property>
 
    <property>
        <name>yarn.nodemanager.localizer.address</name>
        <value>0.0.0.0:23344</value>
    </property>
 
    <property>
        <name>yarn.nodemanager.webapp.address</name>
        <value>0.0.0.0:23999</value>
    </property>
   
    <property>
        <name>yarn.web-proxy.address</name>
        <value>0.0.0.0:8080</value>
    </property>
 
    <property>
        <name>mapreduce.shuffle.port</name>
        <value>23080</value>
    </property>
 
    <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
    </property>
 
    <property>
        <name>yarn.nodemanager.aux-services.mapreduce_shuffle.class</name>
        <value>org.apache.hadoop.mapred.ShuffleHandler</value>
    </property>
 
    <property>
        <name>yarn.log-aggregation-enable</name>
        <value>true</value>
    </property>
 
    <property>
        <name>yarn.nodemanager.local-dirs</name>
        <value>file:///opt/hadoop/data1/yarn/dn,file:///opt/hadoop/data2/yarn/dn,file:///opt/hadoop/data3/yarn/dn</value>
    </property>
 
    <property>
        <name>yarn.nodemanager.log-dirs</name>
        <value>file:///opt/hadoop/data1/yarn/logs,file:///opt/hadoop/data2/yarn/logs,file:///opt/hadoop/data3/yarn/logs</value>
    </property>
 
    <!--
            <property>
        <name>yarn.nodemanager.disk-health-checker.min-healthy-disks</name>
        <value>0</value>
    </property>
 
    <property>
        <name>yarn.nodemanager.disk-health-checker.enable</name>
        <value>false</value>
    </property>
    -->
 
    <property>
        <name>yarn.nodemanager.remote-app-log-dir</name>
        <value>hdfs://bd-ops-test:8020/yarn/apps</value>
    </property>
 
    <property>
        <name>yarn.application.classpath</name>
        <value>
                $HADOOP_CONF_DIR,
                $HADOOP_COMMON_HOME/*,$HADOOP_COMMON_HOME/lib/*,
                $HADOOP_HDFS_HOME/*,$HADOOP_HDFS_HOME/lib/*,
                $HADOOP_MAPRED_HOME/*,$HADOOP_MAPRED_HOME/lib/*,
                $HADOOP_YARN_HOME/*,$HADOOP_YARN_HOME/lib/*
        </value>
    </property>
 
    <property>
        <name>yarn.web-proxy.address</name>
        <value>172.16.57.76:41202</value>
    </property>
    <property>
        <name>yarn.log.server.url</name>
        <value>:19888/jobhistory/logs</value>
    </property>
</configuration>

在 /etc/hadoop/conf/mapred-site.xml 中配置 MapReduce History Server:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/739836c3dc4f0e7caf4694fe154de230.html