Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Hadoop High Reliability HA Cluster

2025-04-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

An overview of the simple hdfs high availability architecture diagram

In hadoop2.x, it usually consists of two NameNode, one in the active state and the other in the standby state. Active NameNode provides services, while Standby NameNode does not provide services, but only synchronizes the status of active namenode so that it can quickly switch if it fails.

Hadoop2.x officially provides two HDFS HA solutions, one is NFS, the other is QJM. Here the landlord uses a simple QJM. In this scheme, a set of JournalNode metadata information is synchronized between the active and standby NameNode. As long as a piece of data is successfully written to most JournalNode, the write is considered successful. Usually an odd number of JournalNode is configured (I have 3).

A zookeeper cluster is also configured for ZKFC (DFSZKFailoverController) failover. When the Active NameNode is down, the Standby NameNode is automatically switched to the standby state. There is still a problem in previous versions of hadoop2.4, that is, there is only one ResourceManager with a single point of failure. This problem has been solved since 2.4. there are two ResourceManager, one is Active, the other is Standby, and the status is coordinated by zookeeper. The owner of the HA configuration building of yarn will give the configuration file. Due to the impact of the environment, the high availability of yarn will not be built here.

Main steps

Prepare 6 Linux machines

Install JDK, configure hostname, modify IP address, turn off firewall

Configure SSH login-free

Install zookeeper cluster

Zookeeper, hadoop environment variable configuration

Core profile modification

Start the zookeeper cluster

Start journalnode

Format file system, format zk

Start hdfs, start yarn

Prepare cluster planning in advance

Hostname IP installation software process hadoop01192.168.8.101jdk, hadoopNameNode, DFSZKFailoverController (zkfc) hadoop02192.168.8.102jdk, hadoopNameNode, DFSZKFailoverController (zkfc) hadoop03192.168.8.103jdk, hadoopResourceManagerhadoop04192.168.8.104jdk, hadoop, zookeeperDataNode, NodeManager, JournalNode, QuorumPeerMainhadoop05192.168.8.105jdk, hadoop, zookeeperDataNode, NodeManager, JournalNode, QuorumPeerMainhadoop06192.168.8.106jdk, hadoop, zookeeperDataNode, NodeManager, JournalNode, QuorumPeerMainLinux environment

1. Due to the limitations of the main machine hardware environment, only 6 centos7 systems are prepared here.

two。 Modify the IP. If you use VM to build a cluster like the landlord, use only-host mode.

Vim / etc/sysconfig/network-scripts/ifcfg-ens3

TYPE= "Ethernet" BOOTPROTO= "static" DEFROUTE= "yes" PEERDNS= "yes" PEERROUTES= "yes" IPV4_FAILURE_FATAL= "no" IPV6INIT= "yes" IPV6_AUTOCONF= "yes" IPV6_DEFROUTE= "yes" IPV6_PEERDNS= "yes" IPV6_PEERROUTES= "yes" IPV6_FAILURE_FATAL= "no" IPV6_ADDR_GEN_MODE= "stable-privacy" NAME= "ens33" UUID= "7f13c30b-0943-49e9-b25d-8aa8cab95e20" DEVICE= "ens33" ONBOOT= "yes" IPADDR= "192.168.101" IPADDR= "255.255.255.0" NETMASK= "192.168.8.1"

3. Modify the mapping relationship between hostname and IP

1 vim / etc/host2 3 192.168.8.101 hadoop014 192.168.8.102 hadoop025 192.168.8.103 hadoop036 192.168.8.104 hadoop047 192.168.8.105 hadoop058 192.168.8.106 hadoop06

4. Turn off the firewall

1 systemctl stop firewalld.service / / stop firewall2 systemctl disable firewalld.service / / disable firewall boot

5. Modify hostname

1 hostnamectl set-hostname hadoop012 hostnamectl set-hostname hadoop023 hostnamectl set-hostname hadoop034 hostnamectl set-hostname hadoop045 hostnamectl set-hostname hadoop056 hostnamectl set-hostname hadoop06

6.ssh login-free

Generate public key and private key

Ssh-keygen-t rsa / / always enter

Send the public key to another machine

Ssh-coyp-id hadoop01ssh-coyp-id hadoop02ssh-coyp-id hadoop03ssh-coyp-id hadoop04ssh-coyp-id hadoop05ssh-coyp-id hadoop06

7. Install JDK and configure environment variables

Hadoop01,hadoop02,hadoop03

1 export JAVA_HOME=/usr/jdk1.7.0_602 export HADOOP_HOME=/home/hadoop/hadoop-2.7.33 export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

Hadoop04,hadoop05,hadoop06 (including zookeeper)

1 export JAVA_HOME=/usr/jdk1.7.0_602 export HADOOP_HOME=/home/hadoop/hadoop-2.7.33 export ZOOKEEPER_HOME=/home/hadoop/zookeeper-3.4.104 export PATH=$PATH:$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbinzookeeper cluster installation

1. Upload zk installation package

Upload to / home/hadoop

two。 Decompression

Tar-zxvf zookeeper-3.4.10.tar.gz

3. Configuration (first configured on a node)

In the conf directory, change the zoo_sample.cfg file to zoo.cfg

Mv zoo_sample.cfg zoo.cfg

Modify configuration file (zoo.cfg)

1 dataDir=/home/hadoop/zookeeper-3.4.10/data 2 server.1=hadoop04:2888:38883 server.2=hadoop05:2888:38884 server.3=hadoop06:2888:3888

Create a myid file in (dataDir=/home/hadoop/zookeeper-3.4.10/data) with N in server.N (2 in server.2)

1 echo "5" > myid

4. Copy the configured zk to another node

1 scp-r / home/hadoop/zookeeper-3.4.5/ hadoop05:/home/hadoop2 scp-r / home/hadoop/zookeeper-3.4.5/ hadoop06:/home/hadoop

Note: be sure to modify the contents of myid on other nodes

In hadoop05, the content of myid should be changed to 2 (echo "6" > myid)

In hadoop06, the content of myid should be changed to 3 (echo "7" > myid)

5. Start the cluster

Start zookeeper on hadoop04,hadoop05,hadoop06 respectively

1 zkServer.sh starthadoop2.7.3 cluster installation

1. Decompression

1 tar-zxvf hadoop-2.7.3.tar.gz

two。 Configure core-site.xml

12 3 4 fs.defaultFS 5 hdfs://ns1 6 7 8 9 hadoop.tmp.dir10 / home/hadoop/hadoop-2.7.3/tmp11 12 13 14 ha.zookeeper.quorum15 hadoop04:2181,hadoop05:2181,hadoop06:218116 17

3. Configure hdf-site.xml

1 2 3 4 dfs.nameservices 5 ns1 6 7 8 9 dfs.ha.namenodes.ns110 nn1 Nn211 12 13 14 dfs.namenode.rpc-address.ns1.nn115 hadoop01:900016 17 18 19 dfs.namenode.http-address.ns1.nn120 hadoop01:5007021 22 23 24 dfs.namenode.rpc-address.ns1.nn225 hadoop02:900026 27 28 29 dfs.namenode.http-address.ns1.nn230 Hadoop02:5007031 32 33 34 dfs.namenode.shared.edits.dir35 qjournal://hadoop04:8485 Hadoop05:8485 Hadoop06:8485/ns136 37 38 39 dfs.journalnode.edits.dir40 file:/home/hadoop/hadoop-2.7.3/journal41 42 43 44 dfs.ha.automatic-failover.enabled45 true46 47 48 49 dfs.client.failover.proxy.provider.ns150 org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider51 52 53 54 dfs.ha.fencing.methods55 56 sshfence57 shell (/ bin/true) 58 59 60 61 62 dfs.ha.fencing.ssh.private-key-files63 / home/hadoop/.ssh/id_rsa64 65 66 67 dfs.ha.fencing.ssh.connect-timeout68 3000069 70

4. Configure mapred-site.xml

1 2 3 4 mapreduce.framework.name5 yarn6 7

5. Configure yarn-site.xml

12 3 4 5 6 yarn.resourcemanager.hostname.rm1 7 hadoop03 8 9 10 yarn.nodemanager.aux-services11 mapreduce_shuffle12 13

6. Configure slaves

1 hadoop042 hadoop053 hadoop06

7. Copy the configured hadoop to another node

Scp-r / home/hadoop/hadoop-2.7.3 hadoop02:/home/hadoopscp-r / home/hadoop/hadoop-2.7.3 hadoop03:/home/hadoopscp-r / home/hadoop/hadoop-2.7.3 hadoop04:/home/hadoopscp-r / home/hadoop/hadoop-2.7.3 hadoop05:/home/hadoopscp-r / home/hadoop/hadoop-2.7.3 hadoop06:/home/hadoop start

1. Start the zookeeper cluster (start zookeeper on hadoop04,hadoop05,hadoop06 respectively)

1 zkServer.sh start

two。 View zookeeper status

1 zkServer.sh status

Contains one leader and two follower

3. Start journalnode (execute on hadoop04,hadoop05,hadoop06 respectively)

Hadoop-daemon.sh start journalnode

Run the jps command to verify that there are many JournalNode processes on the hadoop04,hadoop05,hadoop06

4. Format HDFS

Execute the command on hadoop01:

1 hdfs namenode-format

Check whether it is successful to see if the terminal knows to print:

After formatting, a file is generated based on the hadoop.tmp.dir configuration in core-site.xml, where the main configuration is / home/hadoop/hadoop-2.7.3/tmp, and then / home/hadoop/hadoop-2.7.3/tmp is copied to / home/hadoop/hadoop-2.7.3/ in ihadoop02.

1 scp-r tmp/ hadoop02:/hadoop/hadoop-2.7.3/

5. Format ZK (just execute on hadoop01)

1 hdfs zkfc-formatZK

The effect is as follows (the front can not be cut down a bit, only the latter part is intercepted):

6. Start HDFS (execute on hadoop01)

1 start-dfs.sh

7. Start YARN (execute on hadoop03)

1 start-yarn.sh verification

Now that the hadoop-2.7.3 cluster is fully configured, let's verify it:

Browsers access http://192.168.8.101:50070 NameNode 'hadoop01:9000' (active)

Http://192.168.8.102:50070 NameNode 'hadoop02:9000' (standby)

Browsers access resourceManager: http://192.168.8.103:8088

We can simulate the NameNode (active) outage to verify whether the HA of the HDFS is valid. After the NameNode (active) downtime, the NameNode (standby) will change to the active state, and the landlord is not demonstrating here.

Conclusion

The documents given on the official website are still relatively detailed, and the landlord also extracted the QJM solution of the official website to build. In addition, yarn's HA website also gives the specific configuration, interested students can have a try.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report