Pages

Friday, 3 February 2023

Exp 3:Installation of HADOOP in PSEUDO DISTRIBUTION MODE.

Title:
Installation of HADOOP in PSEUDO DISTRIBUTION MODE.

Objective:
Pseudo distribution is the distribution mode of operation of Hadoop and it runs on a single node ( a node is your machine).

Requirements:
Software Requirements:

  • Oracle Virtual Box
  • Ubuntu Desktop OS (64bit)
  • Hadoop-3.1.0
  • OpenJdk version-8
  • SSH

Hardware Requirements:

  • Minimum RAM required: 4GB (Suggested: 8GB)
  • Minimum Free Disk Space: 25GB
  • Minimum Processor i3 or above

Analysis:

Pseudo-Distributed mode stands between the standalone mode and fully distributed mode on a production level cluster. It is used to simulate the actual cluster. It simulated 2 node — a master and a slave by running JVM process. it gives you a fully-fledged test environment. HDFS is used for storage using some portion of your disk space and YARN needs to run to manage resources on this Hadoop installation.

Installation Procedure In UBUNTU:

1. open terminal

2. sudo apt update

Install OpenSSH on Ubuntu

3.sudo apt install openssh-server openssh-client -y

Enable Passwordless SSH for Hadoop User

4.ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa

/*Use the cat command to store the public key as authorized_keys in the ssh directory*/ 

5.cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

/*Set the permissions for your user with the chmod command*/

6.chmod 0600 ~/.ssh/authorized_keys

/*The new user is now able to SSH without needing to enter a password every time*/

7.ssh localhost

8.logout

Java Installation

9. sudo apt install openjdk-8-jdk

(java home : /usr/lib/jvm/Java-8-openjdk-amd64)

Installation of HADOOP

/* file extraction */

10. tar -zxvf hadoop-3.3.4.tar.gz

/* creatio of hadoop home directory */
11. sudo mkdir /usr/lib/hadoop3
 /* change ownership to hadoop3 */
12. sudo chown username /use/lib/hadoop3
 

/* Move extracted file to hadoop home directory */
13. sudo mv hadoop-3.3.4/* /usr/lib/hadoop3
 

14 cd /usr/lib/hadoop3
cd /home/username (change directory to ubuntu home)
pwd (present working directory)
Setting of paths
 

15. sudo gedit ~/.bashrc
( set the HADOOP_PREFIX & JAVA_HOME at the end of the file)
export HADOOP_PREFIX=/usr/lib/hadoop3
export PATH =$PATH:$HADOOP_PREFIX/bin
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH =$PATH:$JAVA_HOME/bin
 

/* execution of bash profile
16. exec bash

/* Reloading of bash profile
17. source ~/.bashrc
 

18 cd /usr/lib/hadoop3/etc/hadoop
 

19. ls (find hadoop-env.sh)
 

20. sudo gedit hadoop-env.sh (optional)
 

Edit the XML files in hadoop
21. cd /usr/lib/hadoop3/etc/hadoop
 

Configure All the Following files by using gedit
sudo gedit core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>

sudo gedit hdfs-site.xml

<configuration>
<property> 
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>

 

sudo gedit mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>

sudo gedit yarn-site.xml 
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>

<property>
<name>yarn.nodemanager.env-whitelist</name>
<value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADO
OP_YARN_HOME,HADOOP_MAPRED_HOME
</value>
</property>
</configuration>
 

RUNNING of HADOOP SERVICES
22. hadoop namenode -format
/* starting of the dfs services - Its starts Name Node, Data Node, Secondary Name
Node */
23. sbin/start-dfs.sh

/*Starting of Yarn Services - Its starts Resource manager and Node Manager */
24. sbin/start-yarn.sh
23. jps

Limitations:
Pseudo Distribution mode is the partial distribution mode of operation of Hadoop and it runs on a single node ( a node is your machine) where HDFS and YARN services will run in the individual JVMs but resides in the Same System.
 

Conclusion:
The Hadoop daemons run on a local machine, thus simulating a cluster on a small scale.Different Hadoop daemons run in different JVM instances, but on a single machine. HDFS is used instead of local FS. As far as pseudo-distributed setup is concerned, you need to set at least following 4 properties along with JAVA_HOME which are core-site.xml, hdfs-site.xml, mapred-site.xml and yarn-site.xml.

Thursday, 2 February 2023

Exp2: Running a MapReduce WordCount Example in STANDALONE MODE.

Title:
Running a MapReduce WordCount Example in STANDALONE MODE.
 
Objective:
Standalone mode is the default mode of operation of Hadoop and it runs on a single node ( a node is your machine) can be used to run the Word count program.
 
Requirements:
software Requirements:
Oracle Virtual Box
Ubuntu Desktop OS (64bit)
Hadoop-3.1.0
OpenJdk version-8
 
Hardware Requirements:
Minimum RAM required: 4GB (Suggested: 8GB)
Minimum Free Disk Space: 25GB
Minimum Processor i3 or above

Analysis:
By default, Hadoop is configured to run in a non-distributed or standalone mode, as a single Java process. There are no daemons running and everything runs in a single JVM instance. HDFS is not used. We need to create a input directory and provided with a sample text file as input to count the number each word occurrences using MapReduce Program in StandAlone Mode.
 
Flow Chart of Map Reduce
To following diagram summarizes the flow of Map reduce algorithm
 
Algorithm:
1. The input data can be divided into n number of chunks depending upon the amount of
data and processing capacity of individual unit.
2. Next, it is passed to the mapper functions. Please note that all the chunks are processed
simultaneously at the same time, which embraces the parallel processing of data.
3. After that, shuffling happens which leads to aggregation of similar patterns.
4. Finally, reducers combine them all to get a consolidated output as per the logic.
5. This algorithm embraces scalability as depending on the size of the input data, we can keep increasing the number of the parallel processing units. 
 
 
Example:
What is MapReduce in Hadoop? Big Data Architecture 
 

Installation steps:

bda@bda-VirtualBox:~$ ls
Desktop    Downloads         hadoop-3.3.4         Music  output1   Public   Templates
Documents  examples.desktop  hadoop-3.3.4.tar.gz  out2   Pictures  sam.txt  Videos

bda@bda-VirtualBox:~$ cd /usr/lib/hadoop3/

bda@bda-VirtualBox:/usr/lib/hadoop3$ ls
bin  etc  include  lib  libexec  LICENSE-binary  licenses-binary  LICENSE.txt  NOTICE-binary  NOTICE.txt  README.txt  sbin  share

bda@bda-VirtualBox:/usr/lib/hadoop3$ cd bin/

bda@bda-VirtualBox:/usr/lib/hadoop3/bin$ ls
container-executor  hadoop  hadoop.cmd  hdfs  hdfs.cmd  mapred  mapred.cmd  oom-listener  test-container-executor  yarn  yarn.cmd

bda@bda-VirtualBox:/usr/lib/hadoop3/bin$ ./hadoop
                               Or
bda@bda-VirtualBox:/usr/lib/hadoop3$ bin/hadoop
bda@bda-VirtualBox:/usr/lib/hadoop3$ cd

bda@bda-VirtualBox:~$ ls
 
bda@bda-VirtualBox:~$ mkdir mapin
 
bda@bda-VirtualBox:~$ cd mapin
 
bda@bda-VirtualBox:~/mapin$ cat > input.txt
welcome to hadoop
class hadoop is
good hadoop is
bad
 
bda@bda-VirtualBox:~/mapin$ ls
input.txt
bda@bda-VirtualBox:~/mapin$ cat input.txt
welcome to hadoop
class hadoop is
good hadoop is
bad
 
bda@bda-VirtualBox:~$ cd /usr/lib/hadoop3/
bda@bda-VirtualBox:/usr/lib/hadoop3$ /usr/lib/hadoop3/bin/hadoop jar /usr/lib/hadoop3/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.3.4.jar grep ~/mapin/input.txt ~/mapout 'hadoop[.]*'
 
bda@bda-VirtualBox:/usr/lib/hadoop3$ cd
bda@bda-VirtualBox:~$ ls
Desktop    Downloads         hadoop-3.3.4         mapin   Music     Public   Templates
Documents  examples.desktop  hadoop-3.3.4.tar.gz  mapout  Pictures  sam.txt  Videos
 
bda@bda-VirtualBox:~$ cd mapout/
 
bda@bda-VirtualBox:~/mapout$ ls
part-r-00000  _SUCCESS
 
bda@bda-VirtualBox:~/mapout$ cat part-r-00000
3    hadoop

Output:



Limitations:
Standalone mode is the default mode of operation of Hadoop and it runs on a single node ( a node is your machine). HDFS and YARN doesn't run on standalone mode.

Conclusion:

Standalone Mode is the default operation of Hadoop Eco System where the hadoop services will run in the Single JVM. As in this experiment basic Java installation and extraction of the Hadoop files are sufficient to run the Hadoop services and Mapreduce wordcount Program.


Monday, 30 January 2023

Exp 1: Installation of HADOOP in STANDALONE MODE.

Local Mode or Stand alone Mode :

  • The default mode run by the Hadoop is the stand alone mode.
  • This mode is majorly used in case of debugging where HDFS will not be used.
  • In this mode both the input and the output can be used as local file system.
  • No Custom configuration required for mapred-site.xml, hdfs-site.xml and core-site.xml.
  • This mode is the fastest modes in Hadoop as the local file system is used for both the input and the output.

Installation of HADOOP in STANDALONE MODE:

Objective:

Standalone mode is the default mode of operation of Hadoop and it runs on a single node ( a node is your machine).

Software Requirements:
• Oracle Virtual Box 5.x
• Ubuntu Desktop OS 18.x(64bit)
• Hadoop-3.1.0
• OpenJdk version-8 Hardware Requirements:
• Minimum RAM required: 4GB (Suggested: 8GB)
• Minimum Free Disk Space: 25GB
• Minimum Processor i3 or above

Analysis:

By default, Hadoop is configured to run in a non-distributed or standalone mode, as a single Java process. There are no daemons running and everything runs in a single JVM instance. HDFS is not used. We don't have to do anything as far as configuration is concerned, except the JAVA_HOME. Just download the tar file and unzip it

Installation Procedure:

Java Installation

1. sudo apt install openjdk-8-jdk

(java home : /usr/lib/jvm/Java-8-openjdk-amd64)

/* Check the path of java */

bdsa@bdsa-VirtualBox:~$ readlink -f /usr/bin/javac
/usr/lib/jvm/java-8-openjdk-amd64

Installation of HADOOP

Download the Hadoop file from hadoop. apache.org

wget https://dlcdn.apache.org/hadoop/common/hadoop-3.3.4/hadoop-3.3.4.tar.gz





/* file extraction */

2. tar -zxvf hadoop-3.3.4.tar.gz


/* creation of hadoop home directory */

3. sudo mkdir /usr/lib/hadoop3


/* change ownership to hadoop3 */

4. sudo chown <username> /usr/lib/hadoop3

Note: Enter the given username  <username> in it 
for example:rk@rk-VirtualBox:~$ pwd
/home/rk
rk@rk-VirtualBox:~$ sudo chown rk /usr/lib/hadoop3

/* Move extracted file to hadoop home directory */

5. sudo mv hadoop-3.3.4/* /usr/lib/hadoop3

6. cd /usr/lib/hadoop3

cd /home/username (change directory to ubuntu home) 

pwd (present working directory)

/* Running Hadoop in standalone Mode from Hadoop Home Directory */

7.Set the path of java 

bdasa@bdasa-VirtualBox:/usr/lib/hadoop3$ readlink -f /usr/bin/javac

bdasa@bdasa-VirtualBox:/usr/lib/hadoop3$cd etc/

bdasa@bdasa-VirtualBox:/usr/lib/hadoop3/etc$ ls

hadoop

bdasa@bdasa-VirtualBox:/usr/lib/hadoop3/etc$ cd hadoop/

bdasa@bdasa-VirtualBox:/usr/lib/hadoop3/etc/hadoop$ ls

capacity-scheduler.xml            kms-log4j.properties
configuration.xsl                 kms-site.xml
container-executor.cfg            log4j.properties
core-site.xml                     mapred-env.cmd
hadoop-env.cmd                    mapred-env.sh
hadoop-env.sh                     mapred-queues.xml.template
hadoop-metrics2.properties        mapred-site.xml
hadoop-policy.xml                 shellprofile.d
hadoop-user-functions.sh.example  ssl-client.xml.example
hdfs-rbf-site.xml                 ssl-server.xml.example
hdfs-site.xml                     user_ec_policies.xml.template
httpfs-env.sh                     workers
httpfs-log4j.properties           yarn-env.cmd
httpfs-site.xml                   yarn-env.sh
kms-acls.xml                      yarnservice-log4j.properties
kms-env.sh                        yarn-site.xml
bdasa@bdasa-VirtualBox:/usr/lib/hadoop3/etc/hadoop$ nano hadoop-env.sh 



8. bin/hadoop


Limitations:
Standalone mode is the default mode of operation of Hadoop and it runs on a single node ( a node is your machine). HDFS and YARN doesn't run on standalone mode.

Conclusion:
Standalone Mode is the default operation of Hadoop Eco System where the hadoop services will run in the Single JVM. As in this experiment basic Java installation and extraction of the Hadoop files are sufficient to run the Hadoop services.

Sunday, 29 January 2023

Comparing SQL Databases and Hadoop

FeatureSQL DatabasesHadoop
Data TypeWorks with structured data using a predefined schema, following the schema on write approach.
Handles structured, semi structured, and unstructured data using a schema on read approach.

Data VolumeBest suited for relatively smaller data volumes, typically in the gigabyte range.
Built to process massive datasets ranging from terabytes to petabytes.

ProcessingSupports real time data processing and Online Transaction Processing (OLTP).
Primarily designed for large scale batch processing and analytical workloads (OLAP).

ScalabilityScales vertically by upgrading existing hardware resources.
Scales horizontally by adding more low cost commodity servers to the cluster.

ConsistencyProvides strong consistency by strictly following ACID  [ A – Atomicity C – Consistency I – Isolation D – Durability  ] properties.
Follows an eventual consistency model to achieve high availability and fault tolerance.

Query LanguageUses standard, declarative SQL for querying and data manipulation.Relies on programming languages such as Java, Python, or Scala, with SQL like tools such as Hive available.

1. SCHEMA ON WRITE VS READ: 
Generally  in  a traditional database, during  data  load/migration from  one  database to another, it follows schema on Write  approach. This makes the data load process to get excited/ aborted and  results in rejection of records due to a difference in the structure of the source and target tables. 
Whereas in Hadoop system- all the data are stored in HDFS and  Data  are  centralized.  Hadoop  framework  is  mainly  used  for Data  Analytics process. Thus  it  supports  all  three  categories  of  data  i.e.  Structured,  semi-structured  and unstructured data and it enables Schema on reading approach

2. SCALABILITY & COST:
Hadoop  Framework  is  designed  to  process  a  large  volume  of  data. Whenever  the size of data increases, a number of additional resources like data node can be added to the cluster very easily than the traditional approaching of static memory allocation. Time and Budget  is  relatively  very  less  for  implementing  them  and  also  Hadoop  provides  Data Locality where the data is made available in the node that executed the job

3. FAULT TOLERANCE:
In  the  traditional RDBMS,  when  data  is  lost  due  to  corruption  or  any  network issue,  it takes  more  time,  cost  and resource  to get  back the lost data.  But,  Hadoop  has  a mechanism where the data has minimum three level of replication factor for the data that are stored in HDFS. If one of the data nodes that hold data gets failed, data can be easily pulled from other data nodes with high availability of data. Hence makes the data readily available to user irrespective of any failure. 

4. FUNCTIONAL PROGRAMMING:
Hadoop  supports  writing  functional  programming  in  languages  like java,scala,and python.For any application  that  requires  any  additional  functionality  can  be implemented  by  registering  UDF  (User  Defined  Functions)  in  the  HDFS.  
In  RDBMS, there is no possibility  of writing UDF and this increases the  complexity of  writing  SQL.
Moreover the data stored in HDFS can be accessed by  all the  ecosystem of Hadoop  like Hive,Pig,Sqoop  and  HBase. So,  if  the  UDF  is  written  it  can  be  used  by  any  of  the above mentioned  application.  

5. OPTIMIZATION:
Hadoop  stores  data  in  HDFS  and  Process  though Map  Reduce with  huge optimization  techniques.  The  most  popular  techniques  used  for  handling  data  are  using partitioning and bucketing  of the  data  stored.  
Partitioning  is  an  approach  for  storing  the data in HDFS by splitting the data based on the column mentioned for partitioning. When the data is injected or loaded into HDFS, it identifies the partition column and pushes the data into the concerned partition directory.  So the query fetches the result set by directly fetching  the  data  from  the  partitioned  directory.  This  reduces  the  whole  table  scan, improves the response time and avoids latency. 
Another  approach  is  called  Bucketing  of  the  data.  This  enables  the  analyst  to easily distribute the data among the data nodes.  All nodes will have an equal number of data  distributed.  The  bucketing  column  is  selected  in  such  a  way  that  it  has  the  least number  of  cardinality.  These  approaches  are  not  available  in  the  Traditional  method  of SQL.

6. DATA TYPE:
In a traditional approach, the datatype supported are very limited. It supports only structured  data.  Thus  to  clean  and  format the  schema  of  data  itself  will  take  more  time. 
But,  Hadoop  supports  complex  data  type  like  Array,   Struct,  and  Map.  This  encourages using the different kinds of a dataset to be used for data load. For Ex: the XML data can be loaded by defining the data with XML elements containing complex data type.

7. DATA COMPRESSION:
There  are  very  less  inbuilt  compression  techniques  available  for  the  traditional database system. But for the Hadoop framework, there are many compression techniques like gzib, bzip2, LZO and snappy. 
The default compression mode is LZ4. Compression techniques  help  in  making  the  tables  to  occupy  very  less  space  increase  the  throughput and faster query execution.



Data in the Warehouse and Data in Hadoop

In our experience, traditional warehouses are mostly ideal for analyzing structured data from various systems and producing insights with known and relatively stable measurements. On the other hand, we feel a Hadoop-based platform is well suited to deal with semi structured and unstructured  data,  as  well  as  when  a  data  discovery  process  is  needed. That  isn’t  to  say  that Hadoop can’t be used for structured data that is readily available in a raw format. 

Business Intelligence (BI) :

BI enables an organization to gain insight into the performance of an enterprise by analyzing data generated by its business processes and information systems.

BI applies analytics to large amounts of data across the enterprise, which has typically been consolidated into an enterprise data warehouse to run analytical queries.

The output of BI can be surfaced to a dashboard that allows managers to access and analyze the results and potentially refine the analytic queries to further explore the data.

Tools used in Big Data Analytics

 


Processing Structured Data is something that your traditional database is already a structured  data,  by  definition  is  easy  to  enter,  store,  query  and  analyze.  It conforms nicely to a fixed schema model of neat columns and rows that can be manipulated by Structured Query Language (SQL) to establish relationships. 


As such, using Hadoop to process semi-structured and unstructured data is raw, complex,  and  pours  in  from  multiple  sources  such  as  emails,  text  documents,  videos,  photos, social media posts, Twitter feeds, sensors and click streams. 

Storing,  managing  and  analyzing  massive  volumes  of  semi-structured  and unstructured data is what Hadoop was purpose-built to do. Hadoop as a Service provides a scalable solution to meet ever-increasing data storage and processing demands that the data warehouse can no longer handle. With its unlimited scale and on-demand  access  to  compute  and  storage capacity.  Hadoop  as  a  Service  is  the  perfect  match for big data processing. 

Keeping  costs down is a concern for every business And  traditional  relational  databases  are  certainly  cost  effective.  If  you  are  considering adding Hadoop  to  your  data  warehouse,  it’s  important  to  make  sure  that  your  company’s  big  data demands are genuine and that the potential benefits to be realized  from implementing Hadoop will outweigh the costs.

Shorter time-to-insight necessitates interactive querying via the analysis of smaller data sets  in  near  or  real-time.  And  that’s  a task  that  the  data  warehouse  has  been  well  equipped  to handle. However, thanks to a powerful Hadoop processing engine called Spark, Hive,Hbase .. 

Friends-of-friends-Map Reduce program with count

Program to illustrate FOF Map Reduce: import java.io.IOException; import java.util.*; import org.apache.hadoop.conf.Configuration; import or...