Hadoop configuration under the HA mechanism

Source: Internet
Author: User
Tags failover

[Copyright: The author of this article is original, reproduced please indicate the source]
Article Source: http://www.cnblogs.com/sdksdk0/p/5585355.html
Juppé Id:sdksdk0
--------------------------------------------------

In one of my previous blogs, I've shared the basic configuration of Hadoop, address: http://blog.csdn.net/sdksdk0/article/details/51498775, but that's used with beginners to learn and test, Today with the share of this more complex than the last one, mainly add zookeeper and two Namenode configuration, while using this method, can solve the server's brain crack problem.


One, the HA mechanism of HDFs Namenode server one is active and one is standby. Using ZKFC (based on zookeeper failover control) via Qjournal (log management System)




How to prevent the brain crack phenomenon: When active animation, standby ZKFC will issue instructions SSH kill-9 Namenode return 0 (successful kill, return 1 kill failed) to notify the second Namenode to switch state. If no return code (timeout is not responding), start proweroff.sh (user-defined script) to the first Namenode power down, return 0 to perform normal, and then go to switch.


When the first machine loses power (referring to the active state of the Namenode and ZKFC are powered off), the 2nd ZKFC executes proweroff.sh.


Key words: 1, there are two namenode, respectively, are active and standby.


2, there are two ZKFC to monitor and manage the status of two Namenode


3. Metadata log edits is managed by a dedicated logging system--qjoournal


4, ZKFC and qjournal functions are dependent on the zookeeper services to achieve


5, ZKFC do a state switch when there are two mechanisms--ssh and shell scripts to prevent brain fissure.


Second, the configuration of Hadoop cluster open the installation directory of Hadoop, if it is not downloaded or the basis will not be used to see the article at the beginning of the link I provided, please first learn the basic configuration. I mainly use 5 virtual machines to simulate this whole cluster environment.


Host name IP address main features


UBUNTU1 192.168.44.128 Namenode ZKFC ResourceManager
UBUNTU2 192.168.44.131 Namenode ZKFC ResourceManager
Ubuntu3 192.168.44.132 DataNode, NodeManager, Journalnode, Quorumpeermain
Ubuntu4 192.168.44.133 DataNode, NodeManager, Journalnode, Quorumpeermain

Ubuntu5 192.168.44.134 DataNode, NodeManager, Journalnode, Quorumpeermain


We can configure the UBUNTU1 first, then the rest of the SCP to the other machines on it.

Core-site.xml


<configuration>    <property>        <name>fs.defaultFS</name>        <value>hdfs:// ns1/</value>    </property>    <!--specify Hadoop temp directory--    <property>        <name> hadoop.tmp.dir</name>        <value>/home/admin1/hadoop/HAhadoop/tmp/hadoop</value>    </ Property>    <!--Specify zookeeper address--    <property>        <name>ha.zookeeper.quorum</ name>        <value>ubuntu3:2181,ubuntu4:2181,ubuntu5:2181</value>        </property></ Configuration>


Hdfs-site.xml

<configuration><!--Specifies that HDFs Nameservice is ns1 and needs to be consistent with Core-site.xml--><property><name> dfs.nameservices</name><value>ns1</value></property><!--ns1 below There are two namenode, respectively nn1,nn2 --><property><name>dfs.ha.namenodes.ns1</name><value>nn1,nn2</value></ property><!--nn1 RPC Communication address--><property><name>dfs.namenode.rpc-address.ns1.nn1</name> <value>ubuntu1:9000</value></property><!--nn1 http communication address--><property><name> dfs.namenode.http-address.ns1.nn1</name><value>ubuntu1:50070</value></property><!-- RPC Communication address for NN2--&GT;&LT;PROPERTY&GT;&LT;NAME&GT;DFS.NAMENODE.RPC-ADDRESS.NS1.NN2&LT;/NAME&GT;&LT;VALUE&GT;UBUNTU2 :9000</value></property><!--nn2 http communication address--><property><name> dfs.namenode.http-address.ns1.nn2</name><value>ubuntu2:50070</value></property><!-- Specifies the metadata for the Namenode on Journalnode.Storage location--><property><name>dfs.namenode.shared.edits.dir</name><value>qjournal:// ubuntu3:8485;ubuntu4:8485;ubuntu5:8485/ns1</value></property><!--Specify the location where the Journalnode holds data on the local disk- ><property><name>dfs.journalnode.edits.dir</name><value>/home/admin1/hadoop/ hahadoop/journaldata</value></property><!--turn on namenode failure auto-switch--><property><name> dfs.ha.automatic-failover.enabled</name><value>true</value></property><!-- Configuration failure auto-switch Implementation mode--><property><name>dfs.client.failover.proxy.provider.ns1</name><value> org.apache.hadoop.hdfs.server.namenode.ha.configuredfailoverproxyprovider</value></property><!- -Configure the isolation mechanism method, multiple mechanisms are split by newline, that is, each mechanism take up one line--><property><name>dfs.ha.fencing.methods</name><value >sshfenceshell (/bin/true) </value></property><!--ssh-free login required when using sshfence isolation mechanism--><property ><name>dfs.ha.fencing.ssh.private-key-files</name><value>/home/admin1/.ssh/id_rsa</value></property><!-- Configuring the Sshfence isolation mechanism timeout period--><property><name>dfs.ha.fencing.ssh.connect-timeout</name><value >30000</value></property></configuration>



Mapred-site.xml

  <configuration>                <!--Specify the MR Frame as yarn--               <property>                   <name> mapreduce.framework.name</name>                   <value>yarn</value>               </property>            </ Configuration>    

Yarn-site.xml

<configuration><!--Open RM high-availability--><property> <name>yarn.resourcemanager.ha.enabled</name > <value>true</value></property><!--Specify RM's cluster ID--><property> <name> yarn.resourcemanager.cluster-id</name> <value>yrc</value></property><!--Specify the name of RM-- ><property> <name>yarn.resourcemanager.ha.rm-ids</name> <value>rm1,rm2</value> </property><!--Specify the address of RM--><property> <name>yarn.resourcemanager.hostname.rm1</name > <value>ubuntu1</value></property><property> <name> Yarn.resourcemanager.hostname.rm2</name> <value>ubuntu2</value></property><!-- Specify ZK cluster address--><property> <name>yarn.resourcemanager.zk-address</name> &LT;VALUE&GT;UBUNTU3 :2181,ubuntu4:2181,ubuntu5:2181</value></property><property> <name> Yarn.nodemanager.aux-serviCes</name> <value>mapreduce_shuffle</value></property></configuration> 

Slaves

1 ubuntu32 ubuntu43 Ubuntu5



There is also a change in the host name. sudo vi/etc/hostname ubuntu1 and the contents of the hosts:


192.168.44.128 UBUNTU1
192.168.44.131 UBUNTU2
192.168.44.132 UBUNTU3
192.168.44.133 Ubuntu4
192.168.44.134 Ubuntu5



Note: Be sure to put the original two days 127.0.1.1 this one to delete, a hosts file, can not appear the same hostname and IP address of different situations, I started because of this because, tossing a long time, Datanode is not built up.

Third, the Hadoop process of starting Ha

1, start the Zookeeper cluster in the ubuntu3,4,5 input Open service: bin/zkserver.sh start View status: bin/zkserver.sh


2, start Journalnode respectively in the ubuntu3,4,5 input sbin/hadoop-daemon.sh start journalnode Run JPS command test, more Journalnode process


3. Format HDFs


Execute the command on UBUNTU1:
Bin/hdfs Namenode-format
#格式化后会在根据core the Hadoop.tmp.dir configuration in-site.xml to generate files, here I configure/hahadoop/tmp, and then copy/hahadoop/tmp to UBUNTU2.
  


Scp-r tmp/ubuntu2:/home/admin1/hadoop/hahadoop/



4, formatted ZKFC (can be executed on UBUNTU1) Bin/hdfs Zkfc-formatzk


5. Start HDFs (execute on UBUNTU1) sbin/start-dfs.sh


6. Start yarn (performed on UBUNTU1) sbin/start-yarn.sh


If it is started in ubuntu1, then the default browser window will be the same: UBUNTU2 is active, UBUNTU1 is a standby state,









This time if you go to ubuntu2 inside to kill this namenode process, UBUNTU1 will automatically switch to ACTIVE,UBUNTU2 will become unable to connect.




This enables the server to dynamically switch, so in case there is a namenode down, the remaining one will automatically switch. This use of the zookeeper switch is the HA mechanism mentioned earlier.

When the entire cluster is completed the effect will be this, if you use JPS to check:


This is shown on two Namenode nodes:




On the remaining 3 Datanode:




You can view it by visiting Ubuntu2:8088/cluster: The active node is 3



Here the entire cluster environment is set up, of course, if your computer configuration is not very high, you can choose to put datanode directly in the Namenode configuration can also.





Hadoop configuration under the HA mechanism

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.