HadoopHA【一】 hadoop配置文件详解

  • 配置 core-site.xml 文件

点击(此处)折叠或打开

  1. <configuration>

  2.     <property>
  3.         <name>fs.defaultFS</name>
  4.         <value>hdfs://hacluster</value>
  5.         <description> 集群的namenode节点的url </description>
  6.     </property>

  7.     <property>
  8.         <name>ha.zookeeper.quorum</name>
  9.         <value>1.hadoop.com:2181,2.hadoop.com:2181,3.hadoop.com:2181</value>
  10.         <description>zookeeper集群的地址和端口,最好保持基数个至少3台 </description>
  11.         
  12.     </property>

  13.     <property>
  14.         <name>io.file.buffer.size</name>
  15.         <value>131072</value>
  16.         <description></description>
  17.     </property>

  18.     <property>
  19.         <name>hadoop.tmp.dir</name>
  20.         <value>/usr/local/fqlhadoop/datas/hadoop/tmp-hadoop-${user.name}</value>
  21.         <description>执行namenode format之后,很多路径都依赖他,namenode节点该目录不可以删除</description>
  22.     </property>

  23. </configuration>


配置  hdfs-site.xml

点击(此处)折叠或打开

  1. <configuration>

  2.     <property>
  3.         <name>dfs.nameservices</name>
  4.         <value>hacluster</value>
  5.     </property>

  6.     <property>
  7.         <name>dfs.ha.namenodes.hacluster</name>
  8.         <value>n1,n2</value>
  9.     </property>

  10.     <property>
  11.         <name>dfs.namenode.rpc-address.hacluster.n1</name>
  12.         <value>1.hadoop.com:8020</value>
  13.     </property>

  14.     <property>
  15.         <name>dfs.namenode.rpc-address.hacluster.n2</name>
  16.         <value>2.hadoop.com:8020</value>
  17.         <description远程控制端口 在配置客户端访问时 会用到此端口 </description>
  18.     </property>

  19.     <property>
  20.         <name>dfs.namenode.http-address.hacluster.n1</name>
  21.         <value>1.hadoop.com:8090</value>
  22.     </property>

  23.     <property>
  24.         <name>dfs.namenode.http-address.hacluster.n2</name>
  25.         <value>2.hadoop.com:8090</value>
  26.         <description> 页面访问端口 </description>
  27.     </property>

  28.     <property>
  29.         <name>dfs.namenode.shared.edits.dir</name>
  30.         <value>qjournal://1.hadoop.com:8485;2.hadoop.com:8485;3.hadoop.com:8485/hacluster</value>
  31.         <description> journalnode共享文件集群 </description>
  32.     </property>

  33.     <property>
  34.         <name>dfs.client.failover.proxy.provider.hacluster</name>
  35.         <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
  36.         <description> 故障处理类 </description>
  37.     </property>
  38.                                                                                                                                                                                                                        
  39.     <property>
  40.         <name>dfs.ha.fencing.methods</name>
  41.         <value>sshfence(${user.name}:39000)</value>
  42.         <description> ssh方式进行故障切换 </description>
  43.     </property>
  44.                                                                                                                                                                                                                        
  45.     <property>
  46.         <name>dfs.ha.fencing.ssh.private-key-files</name>
  47.         <value>/home/${user.name}/.ssh/id_rsa</value>
  48.     </property>
  49.                                                                                                                                                                                                                        
  50.     <property>
  51.         <name>dfs.journalnode.edits.dir</name>
  52.         <value>/home/hacluster/hadoop/dfs.journalnode.edits.dir</value>
  53.     </property>

  54. <!-- auto configure failover -->

  55.     <property>
  56.         <name>dfs.ha.automatic-failover.enabled</name>
  57.         <value>true</value>
  58.         <description> 自动切换 开启 </description>
  59.     </property>
  60.                                                                                                                                                                                                                        
  61.     <property>
  62.         <name>dfs.replication</name>
  63.         <value>3</value>
  64.         <description> 备机数量 </description>
  65.     </property>
  66.                                                                                                                                                                                                                        
  67.     <property>
  68.         <name>dfs.namenode.name.dir</name>
  69.         <value>/home/hacluster/hadoop/dfs.namenode.name.dir</value>
  70.     </property>
  71.                                                                                                                                                                                                                        
  72.     <property>
  73.         <name>dfs.blocksize</name>
  74.         <value>67108864</value>
  75.     </property>
  76.                                                                                                                                                                                                                        
  77.     <property>
  78.         <name>dfs.namenode.handler.count</name>
  79.         <value>100</value>
  80.     </property>
  81.                                                                                                                                                                                                                        
  82.     <property>
  83.         <name>dfs.datanode.data.dir</name>
  84.         <value>/data1/hacluster/hadoop/datanode</value>
  85.         <description> datanode数据目录 </description>
  86.     </property>
  87.                                                                                                                                                                                                                        
  88. </configuration>

  • 配置 yarn-site.xml

点击(此处)折叠或打开

  1. <configuration>

  2. <!-- Site specific YARN configuration properties -->

  3.    <property>
  4.        <name>yarn.resourcemanager.scheduler.class</name>
  5.        <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler</value>
  6.     </property>

  7.     <property>
  8.         <name>yarn.resourcemanager.ha.enabled</name>
  9.         <value>true</value>
  10.         <description>开启resource manager HA</description>
  11.     </property>

  12.     <property>
  13.         <name>yarn.resourcemanager.cluster-id</name>
  14.         <value>cluster1</value>
  15.     </property>
  16.     <property>
  17.         <name>yarn.resourcemanager.ha.rm-ids</name>
  18.         <value>rm1,rm2</value>
  19.     </property>
  20.     <property>
  21.         <name>yarn.resourcemanager.hostname.rm1</name>
  22.         <value>1.hadoop.com</value>
  23.     </property>
  24.     <property>
  25.         <name>yarn.resourcemanager.hostname.rm2</name>
  26.         <value>2.hadoop.com</value>
  27.     </property>

  28.     <property>
  29.         <name>yarn.resourcemanager.zk-address</name>
  30.         <value>1.hadoop.com:2181,2.hadoop.com:2181,3.hadoop.com:2181</value>
  31.     </property>


  32. <!--
  33.     enable RM Restart feature.
  34. -->

  35.     <property>
  36.         <name>yarn.resourcemanager.recovery.enabled</name>
  37.         <value>true</value>
  38.         <description>开启自动恢复功能</description>
  39.     </property>

  40.     <property>
  41.         <name>yarn.resourcemanager.ha.automatic-failover.enabled</name>
  42.         <value>true</value>
  43.         <description>开启故障自动切换</description>
  44.     </property>
  45.     <property>
  46.         <name>yarn.resourcemanager.store.class</name>
  47.         <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
  48.     </property>

  49.     <property>
  50.         <name>yarn.resourcemanager.am.max-attempts</name>
  51.         <value>5</value>
  52.     </property>                                                                                                                                                                                                             
  53.                                                                                                                                                                                                                        
  54.     <property>                                                                                                                                                                                                         
  55.         <name>yarn.nodemanager.aux-services</name>                                                                                                                                                                     
  56.         <value>mapreduce_shuffle</value>                                                                                                                                                                               
  57.     </property>                                                                                                                                                                                                        
  58.                                                                                                                                                                                                                       
  59.                                                                                                                                                                                                                        
  60. </configuration> 




09-25 12:04