How much NameNode can be there in a single hadoop cluster? - hadoop

Hadoop cluster is a collection of racks. Do each rack contains one NameNode or only one NameNode is present for the entire cluster?

It depends on the configuration of racks as well as Name Node too. you can have 1 Name Node for entire cluster. If u are serious about the performance, then you can configure another Name Node for other set of racks. But 1 Name Node per Rack is not advisable. In Hadoop 1.x you can have only one name node(Only one Namespace) but in Hadoop 2.x we can have namespace federation where we can have multiple name nodes usually serving for particular metadata only.

In a typical Hadoop deployment, you would not have one NameNode per rack. Many smaller-scale deployments use one NameNode, with an optional Standby NameNode for automatic failover.
However, you can have more than one NameNode. Version 0.23 of Hadoop introduced federated NameNodes to allow for horizontal scaling. But, like I said, in many of the common use cases, you would have one NameNode per cluster (with optional Standby NameNode or Secondary NameNode).
See here for some more info.

One. You can have only a single name node in a cluster.
Detail -
In Yarn / Hadoop 2.0 they have come with a concept of active name node and standby name node. ( This is where most of the people get confused. They consider them to be 2 nodes in a cluster). But in this yarn architecture also there will be a single name node which will be receiving heartbeat and block report from data node. Which means there will be a single name node which will remain active.
While this stand by name node will receive a meta data file from active name node via journal node so that in case of name node failure it can take over.
Now in case if you are having a cluster of large number of nodes say 2000 node then in that case also you can have only one Active name node or you can have another approach of dividing your cluster in sub cluster now these sub cluster will also have one Active node per cluster but this will increase processing speed because now your name node to data nodes ratio is better
Conclusion - in any case you can have one node per cluster

Related

requirement of 3 journal nodes in HA hadoop setup

I am quite new to hadoop. As i am setting up a hadoop namenode ha using qoroum journal manager, i am a bit confused on the requirements. The official documentations on apache site says
Note: There must be at least 3 JournalNode daemons, since edit log modifications must be written to a majority of JNs.
what does this means? why do we need 3 journal-nodes instead of two?
As in hadoop1 we can have only one Namenode per cluster if somehow this namenode become unavailable whole cluster will become unavailable thus making it single point of failure.
To resolve this issue the obvious solution was to add more than one Namenode per cluster.
In haoop2 we can have two Namenode per cluster. At a time only one Namenode would be active and other would be in standby mode. To Make system HA both Namenode should be synchronised. To do so they introduced a concept journal nodes.
The purpose of this light weight demon is to sync every change in active Namenode to standby Namenodes.
Now what if this journal node would fail? .This would again became the same issue.journal node will become the Single point of failure. To avoid that they introduced a quorum concept like it was introduced in Zookeeper.
what Quorum means?
Quorum :- The literal meaning of quorum is 'minimum number of assembly/society member that must be present to make a meeting valid'.
On similar notes there must always be more than half of the total journal nodes to be healthy to keep everything running. e.g if you have 2 journal nodes in the system you would have to have to keep 'more than half' i.e more than 1 which is 2 Journal nodes healthy to keep everything running. which means you can't take any journal node failures in this case. To avoid this you must have odd number of journal nodes (i.e 3,5,7). But minimum 3 so that we can bear journal node failures.
I hope this helped

How to shard on user id with hdfs?

I'd like to use a hadoop/hdfs-based system, but I'm a bit concerned as I think I will want to have all data for one user on the same physical machine. Is there a way of accomplishing this in the hadoop-based universe?
During hdfs data write process, the datablock is written first in to node from which the client is accessing the cluster if the node is a datanode.
In order to solve your problem. The edge nodes will also be datanodes. Edge nodes are from where the user starts interacting to the cluster.
But using datanodes as edgenodes has some disadvantages. One of them include Data distribution. The data distribution will not be even and if the node fails, cluster re-balancing will be very costly.

Am I supposed to run `hdfs namenode -format` on all data nodes of a cluster?

I am setting up a Hadoop cluster. From what I understand, the minimum set up for a cluster of at least two workers is 4 machines:
A name node
A resource manager
Data node 1
Data node 2
I am confused by the hdfs namenode -format command, it looks like it's used to format the name node only, but its description (when running an empty hdfs command) states "format the DFS filesystem". Does that mean that I should run that command as part of the installation on all data nodes as well, or should it only be run on the name node?
You only need to format once. It tells the NameNode to do a format, which is mostly a metadata operation.
You don't necessarily need to do it on the node that the NameNode actually resides. Should be able to do it from anywhere.
You will also need Node Manager in your cluster on the datanodes for Map and Reduce Operations.
Secondary NameNode is also required for checkpointing.
NameNode format is done only once when you are installing cluster. It can be done from any node in cluster and it should be done only once.

Difference between Rack Awareness and Name node

I was going through Hadoop, I have doubt whether there is difference between Rack wareness and Name Node. Will Rack wareness and name node will remain on same box
As Aviral rightly said, the question has been quite vague. But just quoting for your understanding,
Namenode : The NameNode is the centerpiece of an HDFS file system. It keeps the directory tree of all files in the file system, and tracks where across the cluster the file data is kept. It does not store the data of these files itself.
Client applications talk to the NameNode whenever they wish to locate a file, or when they want to add/copy/move/delete a file. The NameNode responds the successful requests by returning a list of relevant DataNode servers where the data lives.
You can read in detail about this concept here.
Rack Awareness : In simple words rack awareness is the strategy namenode employs to choose the nearest datanode based on rack information. You can read details here
Further more, I would like to suggest this blog
Image credits Brad Hedlund
From Apache HDFS Users Guide
HDFS is the primary distributed storage used by Hadoop applications.
A HDFS cluster primarily consists of a NameNode that manages the file system metadata and DataNodes that store the actual data
Typically large Hadoop clusters are arranged in racks and network traffic between different nodes with in the same rack is much more desirable than network traffic across the racks. In addition NameNode tries to place replicas of block on multiple racks for improved fault tolerance.
From RackAwareness tutorial:
Hadoop components are rack-aware. For example, HDFS block placement will use rack awareness for fault tolerance by placing one block replica on a different rack. This provides data availability in the event of a network switch failure or partition within the cluster.
Let's see how Hadoop writes are implemented.
If the writer is on a datanode, the 1st replica is placed on the local machine, otherwise a random datanode.
The 2nd replica is placed on a datanode that is on a different rack.
The 3rd replica is placed on a datanode which is on a different node of the rack as the second replica.
Due to replication of data blocks on three different nodes across two different RACs, Hadoop read operations provides high availability of data blocks.
At least one replica is stored on different RAC. If one RAC is not accessible, still Hadoop can fetch data block from other RAC.

HDFS replication factor

When I'm uploading a file to HDFS, if I set the replication factor to 1 then the file splits gonna reside on one single machine or the splits would be distributed to multiple machines across the network ?
hadoop fs -D dfs.replication=1 -copyFromLocal file.txt /user/ablimit
According to the Hadoop : Definitive Guide
Hadoop’s default strategy is to place the first replica on the same node as the client (for
clients running outside the cluster, a node is chosen at random, although the system
tries not to pick nodes that are too full or too busy). The second replica is placed on a
different rack from the first (off-rack), chosen at random. The third replica is placed on
the same rack as the second, but on a different node chosen at random. Further replicas
are placed on random nodes on the cluster, although the system tries to avoid placing
too many replicas on the same rack.
This logic makes sense as it decreases the network chatter between the different nodes. But, the book was published in 2009 and there had been a lot of changes in the Hadoop framework.
I think it depends on, whether the client is same as a Hadoop node or not. If the client is a Hadoop node then all the splits will be on the same node. This doesn't provide any better read/write throughput in-spite of having multiple nodes in the cluster. If the client is not same as the Hadoop node, then the node is chosen at random for each split, so the splits are spread across the nodes in a cluster. Now, this provides a better read/write throughput.
One advantage of writing to multiple nodes is that even if one of the node goes down, a couple of splits might be down, but at least some data can be recovered somehow from the remaining splits.
If you set replication to be 1, then the file will be present only on the client node, that is the node from where you are uploading the file.
If your cluster is single node then when you upload a file it will be spilled according to the blocksize and it remains in single machine.
If your cluster is Multi node then when you upload a file it will be spilled according to the blocksize and it will be distributed to different datanode in your cluster via pipeline and NameNode will decide where the data should be moved in the cluster.
HDFS replication factor is used to make a copy of the data (i.e) if your replicator factor is 2 then all the data which you upload to HDFS will have a copy.
If you set replication factor is 1 it means that the single node cluster. It has only one client node http://commandstech.com/replication-factor-in-hadoop/. Where you can upload files then use in a single node or client node.

Resources