Saturday, 2 January 2016

Hadoop: Single Node Installation

Step 1: Go to Hadoop website. and download latest Hadoop stable release.

After downloading, extract the tar file.

Step 2: Update following variables in either your ~/.bashrc (or) ~/.zshrc (or) ~/.profile.

export HADOOP_PREFIX="/Users/harikrishna_gurram/softwares/Hadoop/hadoop-2.6.0"

“HADOOP_PREFIX” is the directory location, where you unzipped Hadoop.

export HADOOP_HOME=$HADOOP_PREFIX
export HADOOP_COMMON_HOME=$HADOOP_PREFIX
export HADOOP_CONF_DIR=$HADOOP_PREFIX/etc/hadoop
export HADOOP_HDFS_HOME=$HADOOP_PREFIX
export HADOOP_MAPRED_HOME=$HADOOP_PREFIX
export HADOOP_YARN_HOME=$HADOOP_PREFIX

Step 3: Configure HDFS

HDFS stands for Hadoop Distributed File System. It comprises two components.

a.   Name Node: It holds all the meta data about Hadoop cluster. Meta data is related to the stored files in Hadoop cluster.
b.   Data Nodes: This is the place, where data actually stores.

HDFS configuration file is located in “$HADOOP_PREFIX/etc/hadoop/hdfs-site.xml”. By default this file is empty. It use the default configurations specified in following link.



To work with Hadoop on single node, we require only minimal configurations. So add following configurations to hdfs-site.xml.
<configuration>
 <property>
  <name>dfs.datanode.data.dir</name>
  <value>file:///Users/harikrishna_gurram/softwares/Hadoop/hadoop-2.6.0/hdfs/datanode</value>
  <description>Determines where on the local filesystem an DFS data node
   should store its blocks</description>
 </property>

 <property>
  <name>dfs.namenode.name.dir</name>
  <value>file:///Users/harikrishna_gurram/softwares/Hadoop/hadoop-2.6.0/hdfs/namenode</value>
  <description>Determines where on the local filesystem the DFS name
   node should store the name table(fsimage)</description>
 </property>

</configuration>

Note
Make sure to replace /Users/harikrishna_gurram/softwares/Hadoop/hadoop-2.6.0/ with whatever you set $HADOOP_PREFIX to.

Hadoop document says
Property
Description
dfs.datanode.data.dir
Determines where on the local filesystem an DFS data node should store its blocks. If this is a comma-delimited list of directories, then data will be stored in all named directories, typically on different devices. Directories that do not exist are ignored.
dfs.namenode.name.dir
Determines where on the local filesystem the DFS name node should store the name table(fsimage). If this is a comma-delimited list of directories then the name table is replicated in all of the directories, for redundancy.
  

Update “$HADOOP_PREFIX/etc/hadoop/core-site.xml” with following code, to know Hadoop modules where name node located.
<configuration>
 <property>
  <name>fs.defaultFS</name>
  <value>hdfs://localhost/</value>
  <description>NameNode URI</description>
 </property>
</configuration>


Step 4: Configure YARN
To configure YARN, you have to update “$HADOOP_PREFIX/etc/hadoop/yarn-site.xml” file. By default it is empty and use the default configurations specified in following link.


Add following configurations to yarn-site.xml.
<configuration>
 <property>
  <name>yarn.scheduler.minimum-allocation-mb</name>
  <value>128</value>
  <description>The minimum allocation for every container request at the
   Resource manager, in MBs</description>
 </property>
 <property>
  <name>yarn.scheduler.maximum-allocation-mb</name>
  <value>2048</value>
  <description>The maximum allocation for every container request at the
   Resourec Manager, in MBs.</description>
 </property>
 <property>
  <name>yarn.scheduler.minimum-allocation-vcores</name>
  <value>1</value>
  <description>The minimum allocation for every container request at the
   RM, in terms of virtual CPU cores</description>
 </property>
 <property>
  <name>yarn.scheduler.maximum-allocation-vcores</name>
  <value>2</value>
  <description>The maximum allocation for every container request at the
   RM, in terms of virtual CPU cores</description>
 </property>
 <property>
  <name>yarn.nodemanager.resource.memory-mb</name>
  <value>4096</value>
  <description>Amount of physical memory, in MB, that can be allocated
   for containers.</description>
 </property>
 <property>
  <name>yarn.nodemanager.resource.cpu-vcores</name>
  <value>4</value>
  <description>Number of vcores that can be allocated for containers.</description>
 </property>
</configuration>


As per Hadoop documentation
Property
Description
yarn.scheduler.minimum-allocation-mb
The minimum allocation for every container request at the RM, in MBs. Memory requests lower than this will throw a InvalidResourceRequestException.
yarn.scheduler.maximum-allocation-mb
The maximum allocation for every container request at the RM, in MBs. Memory requests higher than this will throw a InvalidResourceRequestException.
yarn.scheduler.minimum-allocation-vcores
The minimum allocation for every container request at the RM, in terms of virtual CPU cores. Requests lower than this will throw a InvalidResourceRequestException.
yarn.scheduler.maximum-allocation-vcores
The maximum allocation for every container request at the RM, in terms of virtual CPU cores. Requests higher than this will throw a InvalidResourceRequestException.
yarn.nodemanager.resource.memory-mb
Amount of physical memory, in MB, that can be allocated for containers.
yarn.nodemanager.resource.cpu-vcores
Number of vcores that can be allocated for containers. This is used by the RM scheduler when allocating resources for containers. This is not used to limit the number of physical cores used by YARN containers.

Note:
You can adjust above configurations depends on your computer hardware configuration.

Step 5: Add Hadoop bin, sbin  directories  path of Hadoop to your system path. For example, I unzipped Hadoop at “/Users/harikrishna_gurram/softwares/Hadoop/hadoop-2.6.0/”.

So i added following statement in ~/.profile file.

export PATH=$PATH:/Users/harikrishna_gurram/softwares/Hadoop/hadoop-2.6.0/bin:/Users/harikrishna_gurram/softwares/Hadoop/hadoop-2.6.0/sbin

Step 6: Open new terminal, Format name node directory (Do this only once).

$ hdfs namenode –format

Step 7: Start name node daemon
$ hadoop-daemon.sh start namenode

Step 8: Start data node daemon
$ hadoop-daemon.sh start datanode

Step 9: Start YARN daemons
Start Resource manager daemon.
$ yarn-daemon.sh start resourcemanager

Start nodemanager daemon
$ yarn-daemon.sh start nodemanager

Run “jps” command to check, whether all daemons are running or not.

$ jps
1583 ResourceManager
1200 NameNode
1717 Jps
1466 DataNode
1637 NodeManager

If any thing goes wrong, go through the error log and rectify it. Error log located at
“$HADOOP_PREFIX/logs/<daemon with problems>.log” for any errors.

Step 10: Test whether your set up is correct or not.

Run following command (Refer Debugging section, if you face any problems)

hadoop jar $HADOOP_PREFIX/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.6.0.jar org.apache.hadoop.yarn.applications.distributedshell.Client --jar $HADOOP_PREFIX/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.6.0.jar --shell_command date --num_containers 2 --master_memory 1024

Check for the jar names “hadoop-yarn-applications-distributedshell-2.6.0.jar” and “hadoop-yarn-applications-distributedshell-2.6.0.jar” update as per the hadoop version installed.

Hurray… You successfully install Hadoop. It is time to play around with Hadoop.

Debugging
1. If you saw “java.net.UnknownHostException” in error log, make sure that following statement is added in /etc/hosts, else add following statement.

127.0.0.1 localhost localhost

2. In MAC, you have to change the hostname to localhost after adding above snippet.

scutil --set HostName localhost

Above command set the host name to localhost.

scutil --get HostName

Above command get the localhost.

3. In mac, create a symbolic link to java like following.
sudo ln -s /usr/bin/java /bin/java.

Referred links






Previous                                                 Next                                                 Home

Introduction to Hadoop

What is Big Data?

Big data represents huge amount of data that is usually not possible to store in a single system.

 

For example, facebook.com generates 4 petabytes of data every day. It is impossible to store and process this huge data with the help of a singe compute.

 

Big data can be characterized with 4 V’s

a.   Volume

b.   Velocity

c.    Variety

d.   Veracity

 

Volume

Volume of the data is huge. For example, Data size is in terabytes, petabytes or more that a traditional systems can’t handle.

 

Velocity

Velocity represent the speed at which new data is getting generated. For example, facebook.com is generating 4 petabytes of data every day.

 

Variety

Data can be in different formats given below.

a.   Structured: RDBMS tables data.

b.   Semi structured: csv, json, xml data

c.    Unstructured: images, video, application log files etc.,

 

Veracity

Veracity represents the quality of the data. Most of the times, the data is messy, we need to pre-process the data, before getting some insights out of the it. For example, some of the columns in the data do not have a value.

 

Why traditional systems can’t handle big data?

Big data is huge in size, and the data is getting accumulated in the sizes of terabytes every day. We can’t store this huge data in a single system. Traditional systems which are not distributed in nature by default, needs vertical scaling (adding more CPUs, memory to the system) to handle this data. Since the data is getting generated day by day is huge, at some point of time, this vertical scaling will reach its upper limit and can’t solve the use case.

 

Big data is in different formats like structured, semi structured, and unstructured, RDBMS systems which require data to follow certain schema can’t store all the varieties of the data.


What is Hadoop?
a. Hadoop is open-source software for reliable, scalable, distributed computing.
b. Hadoop is a framework to manage and process big data
c. Hadoop is a software to address big data usecases

What is Distributed Computing?
In Distributed computing, a network of systems connects and communicates together to achieve a task. In distributed computing, a problem can be divided as many tasks, each task assigned to a computer in distributed network. 
 
Since Big data size is in petabytes or more, we can store this huge data on cluster of machines. We can add any number of nodes to the cluster in future depends on the need.

What is Distributed program?
A computer program that runs in a distributed environment is called distributed program.

Why Distributed Computing?
Today world is overwhelmed by huge and huge amount of data. This data is coming from many resources like social networking sites, stock markets, sensor networks, vehicle GPS traces, online transactions and spatial data. Is it possible to store and analyze all this data in a single machine? Definitely No, it is not possible.

In distributed computing, a distributed program can utilize the processing capability, memory, other hardware resources of all computers connected in distributed network. So we can solve this huge and huge data problem in distributed computing.

Hadoop core components:
a.   HDFS: It is Hadoop distributed file system. Data is divided into chunks and stored across the systems in a cluster (Cluster is a collection of computes).
b.   MapReduce: Programming model to process the data stored in HDFS.
c. YARN: stands for Yet Another Resource Negotiator, handles resource management part in Hadoop.



References

https://kinsta.com/blog/facebook-statistics/

Previous                                                 Next                                                 Home

Hadoop Tutorial


      Introduction to Hadoop
      HDFS Architecture
            Rack awareness in Hadoop HDFS
            What is block reporting in Hadoop hdfs?
            What is an edge node in Hadoop?
      Hadoop installation modes
            Hadoop: Single Node Installation
            Setup Hadoop using cloudera quick start vm
                   Full screen mode is not working in virtual machine
                  How to copy clip board content between a VirtualBox and my system
                  How to create a shared folder between VirtualBox and my computer?
      Hadoop File system commands
            HDFS: Print list of all the commands
            HDFS: What is the hdfs home directory for cloudera quick vm
            Cannot create directory, Name node is in safe mode
            copyFromLocal: copy multiple files from local system to HDFS
                   Copy folder content from local file system to hdfs
            cat : display contents of a file
            appendToFile
            checksum
            copyToLocal: Copy file from hdfs to local system
                   Copy folder from hdfs to local system
            count: count number of files, direcotories, content size in a folder
            cp: copy files from one HDFS locaiton to other HDFS location
            df : Display free space
            du: du: displays amount of space used by files
                   Get brief summary of the space consumed by a directory or file
            expunge: Empty the trash
            get: copy files from HDFS to local system
                   Copy folder from hdfs to local system
            help: Get help about any hdfs command
            ls: lists all files
                   print the files by created time stamp
                   Print files by their size
                   print files size in human readable form
                   recursively print content of a directory
                   print file paths only
            mkdir: Create Directory
                  Create parent directories along the path
            moveFromLocal: move file from local system to HDFS
            mv: move files from one HDFS location to other HDFS locaiton
            put: copy multiple files from local system to HDFS.
            rm: Remove files
                   remove a directory recursively
            rmdir: remove empty directory
            stat: Print stats about a file
            tail: Get last kilobyte of the file
            text: output file in Text format
            touchz: create a file of zero length
            usage: help for a command
            Working with file permissions
            fsck: print hdfc file blocks, and their location
      HDFS: snapshots
            How to get Snapshots Difference Report
      getmerge: Concatenate all files in source directory
      Access control list (ACL)
      setrep: Change replication factor of a file
      How to get the replication factor of a hdfs file?
      HDFS: Extended attributes
      HDFS Web Interface
      Get statistics of HDFS
      Safemode of Namenode
      Checkpoint Node
      HDFS: Java program to read data
            HDFS: Java program to write data
            HDFS: java program to create directory
            HDFS: Java querying file system
            HDFS: Java listing files
      globbing
      HDFS: Java program to delete a file
      Quick guide to Hadoop MapReduce
            MapReduce: word count application
            Map Reduce: count number of lines in a file
            Map Reduce: count number of characters in a file
            What is the role of partitioning in Hadoop MapReduce?
                  Custom Partitioner
            What is shuffling in MapReduce?
            What is sorting phase in MapReduce?
            MapReduce counters
            Map Reduce job configuration
            Hadoop Input formats
            MapReduce: InputSplit
            RecordReader
            What is Map Only Job in Hadoop?
            How to configure number of reducers to a MapReduce job?
      What is the behaviour, when I keep on adding the same file to a HDFS folder?
      How to overwrite an existing file in HDFS?
Previous                                                 Next                                                 Home