namenode ha by zookeeper

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了namenode ha by zookeeper相关的知识,希望对你有一定的参考价值。

tickTime=2000

initLimit=10

syncLimit=5

clientPort=2181

dataDir=/home/tim/zkdata

server.1=tim-dn1:2888:3888

server.2=tim-dn2:2888:3888

server.3=tim-dn3:2888:3888




core-site.xml

<configuration>

   <!--

   <property>

      <name>fs.defaultFS</name>

      <value>hdfs://tim-nn:9000</value> 

   </property>

   -->

  <property>

  <name>fs.defaultFS</name>

  <value>hdfs://mycluster</value>

  </property>

</configuration>


hdfs-site.xml

[email protected]:~/hadoop/etc/hadoop$ cat hdfs-site.xml 

<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!--

  Licensed under the Apache License, Version 2.0 (the "License");

  you may not use this file except in compliance with the License.

  You may obtain a copy of the License at


    http://www.apache.org/licenses/LICENSE-2.0


  Unless required by applicable law or agreed to in writing, software

  distributed under the License is distributed on an "AS IS" BASIS,

  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  See the License for the specific language governing permissions and

  limitations under the License. See accompanying LICENSE file.

-->


<!-- Put site-specific property overrides in this file. -->


<configuration>

<property>

  <name>dfs.replication</name>

  <value>3</value>

</property>

<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>tim-nn:8020</value>

</property>

<property>

  <name>dfs.namenode.rpc-address.mycluster.nn2</name>

  <value>tim-2nn:8020</value>

</property>

<property>

  <name>dfs.namenode.http-address.mycluster.nn1</name>

  <value>tim-nn:50070</value>

</property>

<property>

  <name>dfs.namenode.http-address.mycluster.nn2</name>

  <value>tim-2nn:50070</value>

</property>

<property>

  <name>dfs.namenode.shared.edits.dir</name>

  <value>qjournal://tim-nn:8485;tim-2nn: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>

<property>

  <name>dfs.journalnode.edits.dir</name>

  <value>/home/tim/hadoop/journal</value>

</property>

</configuration>

停掉hdfs集群后

启用自动容灾
hdfs-site
 <property>
   <name>dfs.ha.automatic-failover.enabled</name>
   <value>true</value>
 </property>

his specifies that the cluster should be set up for automatic failover. In your core-site.xml file, add:

 <property>
   <name>ha.zookeeper.quorum</name>
   <value>zk1.example.com:2181,zk2.example.com:2181,zk3.example.com:2181</value>
 </property>



[email protected]:~/hadoop/etc/hadoop$ nano core-site.xml 


  GNU nano 2.5.3                                           File: core-site.xml                                                                                   Modified  


-->


<!-- Put site-specific property overrides in this file. -->


<configuration>

   <!--

   <property>

      <name>fs.defaultFS</name>

      <value>hdfs://tim-nn:9000</value> 

   </property>

   -->

  <property>

  <name>fs.defaultFS</name>

  <value>hdfs://mycluster</value>

  </property>

<property>

   <name>ha.zookeeper.quorum</name>

   <value>tim-dn1:2181,tim-dn2:2181,tim-dn3:2181</value>

 </property>

</configuration>




启动zk集群后

[email protected]:~$ hdfs zkfc -formatZK

用于在zk集群创建/hadoop-ha/mycluster目录

以上是关于namenode ha by zookeeper的主要内容,如果未能解决你的问题,请参考以下文章

zookeeper--实现NN和RM的HA

Hadoop双namenode配置搭建(HA)

hadoop+zookeeper+hive+HA集群部署笔记

七Hadoop3.3.1 HA 高可用集群QJM (基于Zookeeper,NameNode高可用+Yarn高可用)

3.配置HDFS HA

Hadoop HA——namenode无法启动问题解决