一、core-site.xml

<configuration>
 <property>
   <name>fs.defaultFS</name>
   <value>hdfs://mycluster</value>
 </property>

<!-- 指定 hadoop 執行時產生檔案的儲存目錄 -->
 <property>
   <name>hadoop.tmp.dir</name>
   <value>/home/hadoop/install/hadoop-2.7.2/data/tmp</value>
 </property>

 <property>
   <name>ha.zookeeper.quorum</name>
   <value>hadoop01:2181,hadoop02:2181,hadoop03:2181</value>
 </property>
</configuration>

二、hadoop-env.sh

export JAVA_HOME=/home/hadoop/install/jdk1.8.0_152/

三、hdfs-site.xml

<configuration>
 <property>
   <name>dfs.replication</name>
   <value>3</value>
 </property>

 <property>
   <name>dfs.hosts</name>
   <value>/usr/local/hadoop-2.7.2/etc/hadoop/dfs.hosts</value>
 </property>
 <property>
   <name>dfs.hosts.exclude</name>
   <value>/usr/local/hadoop-2.7.2/etc/hadoop/dfs.hosts.exclude</value>
 </property>

<!--ha配置-->
 <property>
   <name>dfs.nameservices</name>
   <value>mycluster</value>
 </property>
 <property>
   <name>dfs.ha.namenodes.mycluster</name>
   <value>nn1,nn2</value>
 </property>
 <property>
   <name>dfs.namenode.rpc-address.mycluster.nn1</name>
   <value>hadoop01:8020</value>
 </property>
 <property>
   <name>dfs.namenode.rpc-address.mycluster.nn2</name>
   <value>hadoop02:8020</value>
 </property>
 <property>
   <name>dfs.namenode.http-address.mycluster.nn1</name>
   <value>hadoop01:50070</value>
 </property>
 <property>
   <name>dfs.namenode.http-address.mycluster.nn2</name>
   <value>hadoop02:50070</value>
 </property>
 <property>
   <name>dfs.namenode.shared.edits.dir</name>
   <value>qjournal://hadoop01:8485;hadoop02:8485;hadoop03:8485/mycluster</value>
 </property>

 <property>
   <name>dfs.client.failover.proxy.provider.mycluster</name>
   <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
 </property>

 <property>
   <name>dfs.ha.fencing.methods</name>
   <value>
	 sshfence
	 shell(/bin/true)
   </value>  
 </property>

 <property>
   <name>dfs.ha.fencing.ssh.private-key-files</name>
   <value>/root/.ssh/id_rsa</value>
 </property>
	
 <property>
   <name>dfs.journalnode.edits.dir</name>
   <value>/usr/local/hadoop-2.7.2/journalnode</value>
 </property>

<!--zk配置-->
<!-- 關閉許可權檢查-->
 <property>
   <name>dfs.permissions.enable</name>
   <value>false</value>
 </property>
 <property>
   <name>dfs.ha.automatic-failover.enabled</name>
   <value>true</value>
 </property>
</configuration>

四、slaves

hadoop01
hadoop02
hadoop03

五、yarn-env.sh

export JAVA_HOME=/home/hadoop/install/jdk1.8.0_152/

六、yarn-site.xml

<configuration>
<!-- reducer 獲取資料的方式 -->
 <property>
   <name>yarn.nodemanager.aux-services</name>
   <value>mapreduce_shuffle</value>
 </property>

 <property>
   <name>yarn.resourcemanager.ha.enabled</name>
   <value>true</value>
 </property>
 <property>
   <name>yarn.resourcemanager.cluster-id</name>
   <value>cluster1</value>
 </property>
 <property>
   <name>yarn.resourcemanager.ha.rm-ids</name>
   <value>rm1,rm2</value>
 </property>
 <property>
   <name>yarn.resourcemanager.hostname.rm1</name>
   <value>hadoop01</value>
 </property>
 <property>
   <name>yarn.resourcemanager.hostname.rm2</name>
   <value>hadoop03</value>
 </property>
 <property>
   <name>yarn.resourcemanager.webapp.address.rm1</name>
   <value>hadoop01:8088</value>
 </property>
 <property>
   <name>yarn.resourcemanager.webapp.address.rm2</name>
   <value>hadoop03:8088</value>
 </property>
 <property>
   <name>yarn.resourcemanager.zk-address</name>
   <value>hadoop01:2181,hadoop02:2181,hadoop03: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>
</configuration>

七、mapred-env.sh

export JAVA_HOME=/home/hadoop/install/jdk1.8.0_152/

八、mapred-site.xml

<configuration>
<!-- 指定 mr 執行在 yarn 上 -->
  <property>
     <name>mapreduce.framework.name</name>
     <value>yarn</value>
  </property>
</configuration>

:本人的另一篇部落格叢集的配置檔案,是非高可用的!!!