Pages

Sunday, 29 January 2023

How to install Hadoop 3.3.0 on ubuntu using shell script

Installing Hadoop:

Installation of Hadoop can be done in 3 different modes:

  1. Stand alone mode - Single Node Cluster
  2. Pseudo distributed mode - Single Node Cluster
  3. Distributed mode - Multi Node Cluster

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.

Pseudo-distributed Mode

  • The pseudo-distribute mode is also defined as a single-node cluster in which the NameNode and DataNode will exist in the same machine.
  • Configuration files such as mapred-site.xml, hdfs-site.xml and core-site.xml are required.
  • If all the Hadoop daemons will be executing on a single node then it is called pseudo-distributed mode. 
  • Both Master and Slave nodes are on the same machine.
  • A separate Java Virtual Machine (JVM) is created for all Hadoop components and these components communicate across network sockets. Due to this a fully functioning and optimized mini-cluster on a single host will produced effectively.

Fully-Distributed Mode

  • In this mode multiple nodes will executed so that it is called production mode of Hadoop. This is also called Multi-Node Cluster.
  • Data is distributed across several nodes on a Hadoop cluster.
  • In this mode Master and Slave services will be running on the separate nodes

Note: We need to run this shell script after once we access root access only 

How to install Hadoop 3.3.0 on ubuntu using shell script

#!/bin/bash
user()
 {
    uid=`id -u`
    if [ $uid -eq "0" ]; then
        echo " "
    else
        exit 
   fi
}
echo -n "Enter new group for hadoop user:"
read hdgroup
echo -n "Enter username for hadoop user:"
read hduser
echo "Adding user to group"
sudo addgroup $hdgroup
sudo adduser -ingroup $hdgroup $hduser
sleep 10
echo "$hdgroup is created and $hduser is assigned to the group"
updates_check() {
echo "checking for updates please wait..."
sudo apt-get update && apt-get upgrade -y && apt-get install ssh
}
java_version_check() {
echo "Checking for supported java version please wait..."
java_version=$(java -version 2>&1 > /dev/nul | grep version | awk '{print substr($3,4, length($3)-9);}'| tr -d ".")
if [ $java_version -eq "8" ];then
echo "system has 8 installed and supported for hadoop"
java_home=$(which java)
path=$(readlink -f $java_home | cut -c 1-33)
echo $path
else
java_installation_check
fi
}
java_installation_check() {
sudo apt-get remove java-common
echo "please wait.."
sudo apt install openjdk-8-jdk -y
java_version_check
}
ssh_keys_creation(){
sudo -u $hduser ssh-keygen -t rsa -P ""
sudo -u $hduser cat /home/$hduser/.ssh/id_rsa.pub >> /home/$hduser/.ssh/authorized_keys
sleep 10
echo "ssh Keys created"
}
hd_install() {
download() {
                wget http://archive.apache.org/dist/hadoop/core/hadoop-3.3.0/hadoop-3.3.0.tar.gz
                sleep 2
                tar xvfz hadoop-3.3.0.tar.gz
                sleep 2
                mv hadoop-3.3.0 /home/$hduser/hadoop
}
if [ -f "/home/$hduser/hadoop-3.3.0.tar.gz" ]; then
echo "Download Already exists... using the existing......."
sleep 2
tar xvfz hadoop-3.3.0.tar.gz
sleep 5
echo "Existing Dir deleted..."
rm -rf /home/$hduser/hadoop
sleep 5
mv hadoop-3.3.0 /home/$hduser/hadoop
else
download
fi 
chown -R $hduser:$hdgroup /home/$hduser/hadoop
#tmp folder for furthur process
sudo -u $hduser mkdir -p /home/$hduser/hadoop/app/hadoop/tmp
sudo -u $hduser chown -R $hduser:$hdgroup /home/$hduser/hadoop/app/hadoop/tmp
#namenode and datanode
sudo -u $hduser mkdir -p /home/$hduser/hadoop/hadoop_store/hdfs/namenode
sudo -u $hduser mkdir -p /home/$hduser/hadoop/hadoop_store/hdfs/datanode
#changing owner to name and data node
sudo -u $hduser chown -R $hduser:$hdgroup /home/$hduser/hadoop/hadoop_store
#permission to .bashrc,hadoop-env.sh,core-site.xml,mapred.site.xml,hdfs-site.xml,yarn-site.xml
sudo -u $hduser chmod o+w /home/$hduser/.bashrc
sudo -u $hduser chmod o+w /home/$hduser/hadoop/etc/hadoop/hadoop-env.sh
sudo -u $hduser chmod o+w /home/$hduser/hadoop/etc/hadoop/core-site.xml
sudo -u $hduser chmod o+w /home/$hduser/hadoop/etc/hadoop/mapred-site.xml
sudo -u $hduser chmod o+w /home/$hduser/hadoop/etc/hadoop/hdfs-site.xml
sudo -u $hduser chmod o+w /home/$hduser/hadoop/etc/hadoop/yarn-site.xml
 
echo "export JAVA_HOME=$path" >> /home/$hduser/hadoop/etc/hadoop/hadoop-env.sh

#bashrc
echo -e '\n\n #Hadoop Variable START \n export HADOOP_HOME=/home/'$hduser'/hadoop \n export HADOOP_INSTALL=$HADOOP_HOME \n export HADOOP_MAPRED_HOME=$HADOOP_HOME \n export HADOOP_COMMON_HOME=$HADOOP_HOME \n export HADOOP_HDFS_HOME=$HADOOP_HOME \n export YARN_HOME=$HADOOP_HOME \n export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native \n export PATH=$PATH:$HADOOP_HOME/sbin/:$HADOOP_HOME/bin \n export HADOOP_OPTS=-Djava.library.path=$HADOOP_HOME/lib/native \n #Hadoop Variable END\n\n' >> /home/$hduser/.bashrc
source /home/$hduser/.bashrc
#core-site.xml
sudo sed -i '/<configuration>/a <property>\n\t\t<name>hadoop.tmp.dir</name>\n\t\t<value>/home/'$hduser'/hadoop/app/hadoop/tmp</value>\n</property>\n<property>\n\t\t<name>fs.default.name</name>\n\t\t<value>hdfs://localhost:9000</value>\n</property>' /home/$hduser/hadoop/etc/hadoop/core-site.xml
#mapred-site.xml
sudo sed -i '/<configuration>/a <property>\n\t\t <name>mapreduce.framework.name</name>\n\t\t <value>yarn</value>\n</property>' /home/$hduser/hadoop/etc/hadoop/mapred-site.xml
#hdfs-site.xml
sudo sed -i '/<configuration>/a <property>\n\t\t<name>dfs.data.dir</name>\n\t\t<value>/home/'$hduser'/hadoop/dfsdata/namenode</value>\n</property>\n<property>\n\t\t<name>dfs.data.dir</name>\n\t\t<value>/home/'$hduser'/hadoop/dfsdata/datanode</value>\n</property>\n\t\t<property><name>dfs.replication</name>\n\t\t<value>1</value>\n</property>' /home/$hduser/hadoop/etc/hadoop/hdfs-site.xml
#yarn-site.xml
sudo sed -i '/<configuration>/a <property>\n\t\t<name>yarn.nodemanager.aux-services</name>\n\t\t<value>mapreduce_shuffle</value>\n</property>\n<property>\n\t\t<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>\n\t\t<value>org.apache.hadoop.mapred.ShuffleHandler</value>\n</property>\n\t\t<property><name>yarn.resourcemanager.hostname</name>\n\t\t<value>127.0.0.1</value>\n</property>\n\t\t<property>\n\t\t<name>yarn.acl.enable</name>\n\t\t<value>0</value>\n</property>\n\t\t<property>\n\t\t<name>yarn.nodemanager.env-whitelist</name>\n\t\t<value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PERPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOME</value>\n</property>' /home/$hduser/hadoop/etc/hadoop/yarn-site.xml
#revoking permissions
sudo -u $hduser chmod o-w /home/$hduser/hadoop/etc/hadoop/hadoop-env.sh
sudo -u $hduser chmod o-w /home/$hduser/hadoop/etc/hadoop/core-site.xml
sudo -u $hduser chmod o-w /home/$hduser/hadoop/etc/hadoop/mapred-site.xml
sudo -u $hduser chmod o-w /home/$hduser/hadoop/etc/hadoop/hdfs-site.xml
sudo -u $hduser chmod o-w /home/$hduser/hadoop/etc/hadoop/yarn-site.xml
#hadoop dir
sudo ls /home/$hduser/hadoop
#ssh
sudo -u hduser ssh localhost
}
user
updates_check
java_version_check
ssh_keys_creation
hd_install


After you installed the hadoop using above shell script now identity the path hadoop/bin and then type the following command 

hadoop namenode -format

After formatting the namenode ,now identity the path hadoop/sbin and then type the following command 

 ./start-all.sh

or

./start-dfs.sh
./start-yarn.sh

After starting all the 5 daemons on the said path hadoop/sbin now type the following command 

jps (Java Virtual Machine Process Status)





The pseudo-distribute mode is also defined as a single-node cluster in which the NameNode and DataNode will exist in the same machine.
 
Steps to Install hadoop:

1. sys032@sys032-PC:~$ ls
Desktop  jyo1  krishna  mkdir     Public  suraj095   Videos
jyo      knb   kumar    Pictures  snap    Templates
 
2.sys032@sys032-PC:~$ pwd
/home/sys032
 
3.sys032@sys032-PC:~$ sudo -s
[sudo] password for sys032:
 
4.root@sys032-PC:/home/sys032# ls
Desktop  jyo1  krishna  mkdir     Public  suraj095   Videos
jyo      knb   kumar    Pictures  snap    Templates
 
5.root@sys032-PC:/home/sys032# ls /home/
sys032
 
6.root@sys032-PC:/home/sys032# gedit hadoop.sh
 Paste the above given shell code
 
6.1 chmod +x hadoop.sh
 
6.2  ./hadoop.sh
 Enter username as hdoop with out password
 
7.root@sys032-PC:/home/sys032# ls /home
hdoop  sys032
 
8.root@sys032-PC:/home/sys032# su hdoop
 
9.hdoop@sys032-PC:/home/sys032$ ls
Desktop              jyo   krishna  Pictures  suraj095
hadoop-3.3.0.tar.gz  jyo1  kumar    Public    Templates
hadoop.sh            knb   mkdir    snap      Videos
 
10.hdoop@sys032-PC:/home/sys032$ cd ..
hdoop@sys032-PC:/home$ ls
hdoop  sys032
 
11.hdoop@sys032-PC:/home$ cd hdoop
hdoop@sys032-PC:~$ ls
hadoop
 
12.hdoop@sys032-PC:~$ cd hadoop
 
13.hdoop@sys032-PC:~/hadoop$ ls
app  hadoop_store  libexec          LICENSE.txt    README.txt
bin  include       LICENSE-binary   NOTICE-binary  sbin
etc  lib           licenses-binary  NOTICE.txt     share
 
14.hdoop@sys032-PC:~/hadoop$ cd bin
 
15.hdoop@sys032-PC:~/hadoop/bin$hadoop namenode -format
 
16. hdoop@sys032-PC:~/hadoop/bin$ cd ..
 
17. hdoop@sys032-PC:~/hadoop$ cd sbin
 
18. hdoop@sys032-PC:~/hadoop/sbin$ ls
 
19. hdoop@sys032-PC:~/hadoop/sbin$ jps
47868 Jps
 
20. hdoop@sys032-PC:~/hadoop/sbin$ ./start-all.sh

Thursday, 26 January 2023

Patterns For Big data Development

1. IT for IT Log Analytics:

Log analytics is a common use case for an inaugural Big Data project. We like to refer to all those logs and trace data that are generated by the operation of your IT solutions as data exhaust. IT  departments  need  logs  at  their  disposal,  and  today  they  just  can’t  store  enough  logs  and analyze them in a cost-efficient manner, so logs are typically kept for emergencies and discarded as soon as possible. Another reason why IT departments keep large amounts of data in logs is to look for rare problems. It is often the case that the most common problems are known and easy to  deal  with,  but  the  problem  that  happens "only once in a while is typically more difficult  to diagnose and prevent from occurring again".

The  nature  of  these  logs  is  semi  structured  and  raw,  so  they  aren’t  always  suited  for traditional database processing. In addition, log formats are constantly changing due to hardware and software upgrades.

Log analytics is actually a pattern that IBM established after working with a number of companies, including some large financial services sector (FSS) companies. We’ve seen this use case come up with quite a few customers since for that reason, we’ll call this pattern IT for IT.  

NOTE: 
step 1: create a log file using notepad and save it
.LOG
22:25 27/10/2014
Today's last entry 

step 2: now double click the created  log file 
.LOG
22:25 27/10/2014
Today's last entry 
22:26 27/10/2014

2. The Fraud Detection Pattern: 

Fraud  detection  comes  up  a  lot  in  the  financial  services  and you’ll find it in any sort of claims or transaction based on online auctions,insurance-claims,environment etc.  


Traditionally, in fraud cases, samples and models are used to identify customers that characterize a certain kind of profile. In  our  customer  experiences,  we  estimate  that  only  20  percent  (or  maybe  less)  of  the available information that could be useful for fraud modeling is actually being used. You can use BigInsights to provide an elastic and cost-effective repository to establish the remaining 80 percent of the information is useful for fraud modeling.


Typically, fraud detection works after a transaction gets stored only to get pulled out of storage and analyzed.
 As we can see that 80 percent of the data is costeffective and efficient in using the BigInsights platform. Now, of course, once you have your fraud models built, you’ll want to put them into action to try and prevent the fraud in the first place. Recovery rates for fraud are dismal in all industries, so it’s best to prevent it versus discover it and try to recover the funds post-fraud. 

Think  about  fraud  in  health  care  markets  (health  insurance  fraud,  drug  fraud,  medical fraud, and so on) and the ability to get in front of insurer and government fraud schemes. when  the  Federal  Bureau  of Investigation (FBI) estimates that health care fraud costs U.S. taxpayers over $60 billion a year. Think  about  fraudulent  online  product  or  ticket  sales,  money  transfers,  swiped  banking  cards, and more you can see that the applicability of this usage pattern is extreme.








Note: 

1.Traditional fraud detection methods with out big data


2.Traditional fraud detection methods with  big data

3. Big Data and the Energy Sector: 

The energy sector provides many Big Data use case challenges in how to deal with the massive  volumes  of  sensor  data  from  remote  installations.  Many  companies  are  using  only  a fraction of the data being collected, because they lack the infrastructure to store or analyze the available scale of data. 

Take for example a typical oil drilling platform that can have 20,000 to 40,000 sensors on board.  All  of  these  sensors  are  streaming  data  about  the  health  of  the  oil  rig,  quality  of operations,  and  so  on.  Not  every  sensor  is  actively  broadcasting  at  all  times,  but  some  are reporting back many times per second. Now take a guess at what percentage of those sensors are actively utilized. 

The location chosen to install and operate a wind turbine can obviously greatly impact the amount of power generated by  the  unit,  as  well  as  how  long  it’s  able  to  remain  in  operation.  To  determine  the  optimal placement for a wind turbine, a large number of location-dependent factors must be considered, such  as  temperature,  precipitation,  wind  velocity,  humidity,  atmospheric  pressure,  and  more.    

4.The Social Media Pattern: 

The data produced by social media is very huge and if we see the report of Visual Capitalist then it shows that every internet minute:

701,389 logins on Facebook

150 million emails sent

$203,596 in sales on Amazon.com

120+ new Linkedin accounts

347,222 tweets on Twitter

2.4 million search queries on Google

2.78 million video views on YouTube

20.8 million messages on WhatsApp  

5. The Call Center Mantra: <This Call May Be Recorded for Quality Assurance Purposes>: 

Call center analytics is the collection, measurement, and reporting of performance metrics within a contact center. It tracks call data and agent performance handling inbound or outbound calls. Common types of analytics include handle time, call volume, customer satisfaction, and hold time.

In most cases, call center supervisors can access this data using specialized analytics tools. However, accessing this call center data analytics is often limited to supervisors and team leads. More modern contact centers provide this real-time data to agents so they can mind increasing call volumes.

However, with the right tools and strategy, call data helps you provide exceptional customer experience, boost brand loyalty, and improve efficiency across the board.

6. Risk:

The risks of Big Data are manifold, and organizations need to carefully plan for their use of Big Data solutions. These risks include strategic and business risks, such as operational impacts and cost overruns, as well as technical risks, such as data quality and security. 

Here are the five biggest risks of Big Data projects 

  • Security
  • Privacy
  • Costs
  • Bad Analytics
  • Bad Data

Monday, 9 January 2023

Patterns for Big Data Designs

These big data design patterns aim to reduce complexity, boost the performance of integration and improve the results of working with new and larger forms of data.the common big data design patterns based on various data layers such as data sources and ingestion layer, data storage layer and data access layer.

Data sources and ingestion layer:
Enterprise big data systems face a variety of data sources with non-relevant information (noise) alongside relevant (signal) data. Noise ratio is very high compared to signals, and so filtering the noise from the pertinent information, handling high volumes, and the velocity of data is significant. This is the responsibility of the ingestion layer. 
The common challenges in the ingestion layers are as follows:
  • Multiple data source load and prioritization
  • Ingested data indexing and tagging
  • Data validation and cleansing
  • Data transformation and compression
The above diagram depicts the building blocks of the ingestion layer and its various components. We need patterns to address the challenges of data sources to ingestion layer communication that takes care of performance, scalability, and availability requirements.
Multisource extractor
Multidestination
Protocol converter
Just-in-time (JIT) transformation
Real-time streaming pattern

Multisource extractor
An approach to ingesting multiple data types from multiple data sources efficiently is termed a Multisource extractor. Efficiency represents many factors, such as data velocity, data size, data frequency, and managing various data formats over an unreliable network, mixed network bandwidth, different technologies , and systems.

The multisource extractor system ensures high availability and distribution. It also confirms that the vast volume of data gets segregated into multiple batches across different nodes. The single node implementation is still helpful for lower volumes from a handful of clients, and of course, for a significant amount of data from multiple clients processed in batches. Partitioning into small volumes in clusters produces excellent results.

Data enrichers help to do initial data aggregation and data cleansing. Enrichers ensure file transfer reliability, validations, noise reduction, compression, and transformation from native formats to standard formats. Collection agent nodes represent intermediary cluster systems, which helps final data processing and data loading to the destination systems.The following are the benefits of the multisource extractor:
  • Provides reasonable speed for storing and consuming the data
  • Better data prioritization and processing
  • Drives improved business decisions
  • Decoupled and independent from data production to data consumption
  • Data semantics and detection of changed data
  • Scaleable and fault tolerance system
Multidestination pattern:
The multidestination pattern is considered as a better approach to overcome all of the challenges mentioned previously. This pattern is very similar to multisourcing until it is ready to integrate with multiple destinations (refer to the following diagram). The router publishes the improved data and then broadcasts it to the subscriber destinations (already registered with a publishing agent on the router). Enrichers can act as publishers as well as subscribers:
The following are the benefits of the multidestination pattern:
  • Highly scalable, flexible, fast, resilient to data failure, and cost-effective
  • Organization can start to ingest data into multiple data stores, including its existing RDBMS as well as NoSQL data stores
  • Allows you to use simple query language, such as Hive and Pig, along with traditional analytics
  • Provides the ability to partition the data for flexible access and decentralized processing
  • Possibility of decentralized computation in the data nodes
  • Due to replication on HDFS nodes, there are no data regrets
  • Self-reliant data nodes can add more nodes without any delay 
Protocol converter:
This is a mediatory approach to provide an abstraction for the incoming data of various systems. The protocol converter pattern provides an efficient way to ingest a variety of unstructured data from multiple data sources and different protocols.

The message exchanger handles synchronous and asynchronous messages from various protocol and handlers as represented in the following diagram. It performs various mediator functions, such as file handling, web services message handling, stream handling, serialization, and so on:
In the above protocol converter pattern, the ingestion layer holds responsibilities such as identifying the various channels of incoming events, determining incoming data structures, providing mediated service for multiple protocols into suitable sinks, providing one standard way of representing incoming messages, providing handlers to manage various request types, and providing abstraction from the incoming protocol layers.

Just-In-Time (JIT) transformation pattern:
The JIT transformation pattern is the best fit in situations where raw data needs to be preloaded in the data stores before the transformation and processing can happen. In this kind of business case, this pattern runs independent preprocessing batch jobs that clean, validate, corelate, and transform, and then store the transformed information into the same data store (HDFS/NoSQL); that is, it can coexist with the raw data:

Please note that the data enricher of the multi-data source pattern is absent in this pattern and more than one batch job can run in parallel to transform the data as required in the big data storage, such as HDFS, Mongo DB, and so on.

Real-time streaming pattern:
The real-time streaming pattern suggests introducing an optimum number of event processing nodes to consume different input data from the various data sources and introducing listeners to process the generated events (from event processing nodes) in the event processing engine:
Event processing engines (event processors) have a sizeable in-memory capacity, and the event processors get triggered by a specific event. The trigger or alert is responsible for publishing the results of the in-memory big data analytics to the enterprise business process engines and, in turn, get redirected to various publishing channels (mobile, CIO dashboards, and so on).

Sunday, 8 January 2023

Importance of Big data

Big Data importance doesn’t revolve around the amount of data and company has. Its importance lies in the fact that how the company utilizes the gathered data.

Every company uses its collected data in its own way. The companies in the present market need to collect it and analyze it because:


1. Cost Savings:
Big Data tools like Apache Hadoop, Spark, etc. bring cost-saving benefits to businesses when they have to store large amounts of data. These tools help organizations in identifying more effective ways of doing business.

2. Time-Saving:
Real-time in-memory analytics helps companies to collect data from various sources. Tools like Hadoop help them to analyze data immediately thus helping in making quick decisions based on the learning.

3. Social Media Listening:
Companies can perform sentiment analysis using Big Data tools. These enable them to get feedback about their company, that is, who is saying what about the company.Companies can use Big data tools to improve their online presence.

4. Customer Acquisition and Retention
Customers are a vital asset on which any business depends on. No single business can achieve its success without building a robust customer base. But even with a solid customer base, the companies can’t ignore the competition in the market.
If we don’t know what our customers want then it will degrade companies’ success. It will result in the loss of client which creates an adverse effect on business growth.
Big data analytics helps businesses to identify customer related trends and patterns. Customer behavior analysis leads to a profitable business.

5. Understand the Marketing Insights:
Big Data analysis helps businesses to get a better understanding of market situations.
For example, analysis of customer purchasing behavior helps companies to identify the products sold most and thus produces those products accordingly. This helps companies to get ahead of their competitors.
 
Big data analytics shapes all business operations. It enables companies to fulfill customer expectations. Big data analytics helps in changing the company’s product line. It ensures powerful marketing campaigns.

6.Innovations:
Big data makes companies capable to innovate and redevelop their products.

Real-Time Benefits of Big Data
Big Data analytics has expanded its roots in all the fields. This results in the use of Big Data in a wide range of industries including Finance and Banking, Healthcare, Education, Government, Retail, Manufacturing, and many more.

There are many companies like Amazon, Netflix, Spotify, LinkedIn, Swiggy,etc which use big data analytics. Banking sectors make the maximum use of Big Data Analytics. Education sector is also using data analytics to enhance students’ performance as well as making teaching easier for instructors.

Thursday, 24 February 2022

Hive-Joins,Subqueries

Step-1:
create database joins;
show databases;

 

Step-2:
create two tables namely table 1 named as sales and table2 named as products. 


Step-3:
create two tables sales and product in the database named by join
sales table with two fields name and id 
product table with two fields pid and pname.

Table 1: sales

name sid
raju    2
rani    3
vani    5
kani    7
poni    9

Table 2: product

pid    pname
2    laptop
3    desktop    
6    headphones
7    mobile
8    ipad

syntax to create table sales :

create table sales(name string,id int)
row format delimited
fields terminated by '\t';

syntax to create table product:

create table product(pid int,pname string)
row format delimited
fields terminated by '\t';
 
Load both the tables as shown :

INNER JOIN or JOIN: 

The records common to the both tables will be retrieved by this inner-join the simplest kind of join is the inner join, where each match in the input table results in a row in the output
 
syntax: select table1.col1, table2.col2
from table2 join table1
on (table1.matching-col = table2.matching-col);
 
Example 1:
hive> select sales.name,product.pname
    > from product join sales
    > on(sales.sid = product.pid);

 

Example 2:
hive> select sales.*,product.*
    > from product JOIN sales
   > on(sales.sid = product.pid);
 

Example 3:
hive> select sales.*,product.*
    > from sales JOIN product
    > on(sales.sid = product.pid);

Example 4:
hive> select sales.*,product.*
    > from sales INNER JOIN product
    > on(sales.sid = product.pid);


LEFT OUTER JOIN:
This type of join returns all rows from the left table even if there is no matching row in the right table.Table returns all rows from the left table and matching rows from right table, unmatched right tables records will be null
 
syntax: select table1.col1,table2.col2
from table1 LEFT OUTER JOIN table2
on(table1.matching-col = table2.matching-col);

Example :
hive> select sales.*,product.*
    > from sales LEFT OUTER JOIN product
    > on(sales.sid = product.pid);
RIGHT OUTER JOIN:
It returns all rows from the right table even if there is no matching row in the left table. Table returns all rows from the right table and matching rows from left table,unmatched left table records will be null
 
syntax: select table1.col1,table2.col2
from table1 right outer join table2
on(table1.matching-col=table2.matching-col);
 
Example:
hive> select sales.*,product.*
    > from sales RIGHT OUTER JOIN product
    > on(sales.sid = product.pid);

FULL OUTER JOIN :

It returns all rows from the both tables that fulfill the join  condition the unmatched rows from both tables will be returned as a null

syntax: select table 1.col1,table1.col2,table2.col1,table2.col2
from table1 full outer join table2 
on(table1.matching-col = table2.matching-col);
 
Example:
hive> select sales.*,product.*
    > from sales FULL OUTER JOIN product
    > on(sales.sid = product.pid);


SUBQUERIES:
 
Step 1: 
hive> create table std(sno int, sname string, scity string)
    > row format delimited
    > fields terminated by '\t';
 
hive> desc std;
OK
sno                     int                                        
sname                   string                                     
scity                   string                                     
Time taken: 0.042 seconds, Fetched: 3 row(s)
 
hive> load data local inpath '/home/hduser/Desktop/std' into table std;
Loading data to table joins.std
OK
Time taken: 0.714 seconds
 
hive> select * from std;
OK
11    raju    vsp
22    rani    hyd
33    vani    vzm
44    kani    rjm
55    poni    ban
 

Step 2:
hive> create table dept(dno string, dname string, sno int)
    > row format delimited
    > fields terminated by '\t';
OK
Time taken: 0.079 seconds
 
hive> desc dept;
OK
dno                     string                                     
dname                   string                                     
sno                     int                                        
Time taken: 0.041 seconds, Fetched: 3 row(s)
 
hive> load data local inpath '/home/hduser/Desktop/dept' into table dept;
Loading data to table joins.dept
OK
Time taken: 0.198 seconds
 
hive> select * from dept;
OK
d1    cse    11
d2    it    22
d3    ece    33
d4    mpc    44
d5    msc    55
Time taken: 0.138 seconds, Fetched: 5 row(s)
 

Step 3:
hive> select dno from dept where dname='mpc';
OK
d4
Time taken: 0.177 seconds, Fetched: 1 row(s)
 
hive> select dno,sno from dept where dname='mpc';
OK
d4    44
Time taken: 0.113 seconds, Fetched: 1 row(s)
 
hive> select sname from std where sno=(select sno from dept where dname='mpc');



hive> select sname,scity from std where sno=(select sno from dept where dname='mpc');


Monday, 21 February 2022

Data warehouse vs Data Mining

What is Big Data Analytics?
Basically, Big Data Analytics is largely used by companies to facilitate their growth and development. This majorly involves applying various data mining algorithms on the given set of data, which will then aid them in better decision making. There are multiple tools for processing Big Data such as Hadoop, Pig, Hive, Cassandra, Spark, Kafka, etc. depending upon the requirement of the organization.

What is Data warehouse?
A data warehouse is a technique for collecting and managing data from varied sources to provide meaningful business insights.

Data Warehouse is electronic storage of a large amount of information by a business which is designed for query and analysis instead of transaction processing. It is a process of transforming data into information and making it available to users for analysis.


What Is Data Mining?
Data mining is looking for hidden, valid, and potentially useful patterns in huge data sets. Data Mining is all about discovering unsuspected/ previously unknown relationships amongst the data.

It is a multi-disciplinary skill that uses machine learning, statistics, AI and database technology.

The insights extracted via Data mining can be used for marketing, fraud detection, and scientific discovery, etc.





Friday, 28 January 2022

Big Data Technology - Syllabus & Model Paper for B.Tech

Big Data Technology
Syllabus for B.Tech

COURSE OBJECTIVES:
1. Understand the Big Data Platform and its Use cases
2. Provide an overview of Apache Hadoop
3. Provide HDFS Concepts and Interfacing with HDFS
4. Understand Map Reduce Jobs

COURSE OUTCOMES:
At the end of the course student will be able to
CO1: Understand concept of Big Data and Hadoop Eco System
CO2: Configure various Hadoop services in distributed environment
CO3: Analyze unstructured data using Map Reduce
CO4: Understand various advanced Map Reduce tasks for analyzing the data
CO5: Solve various real times problems using Hadoop and HBase

UNIT-I
Introduction to Big Data: Big Data-definition, Characteristics of Big Data (Volume,
Variety, Velocity, Veracity, Validity), Importance of Big Data, Data in the Warehouse and Data in Hadoop, Algorithms using map reduce, Matrix-Vector Multiplication by Map Reduce. Introduction to Hadoop: Hadoop- definition, understanding distributed systems and Hadoop, Comparing SQL databases and Hadoop

UNIT-II
Hadoop Architecture: History of Hadoop, building blocks of Hadoop, NameNode,
DataNode, Secondary NameNode, JobTracker and Task Tracker, YARN. Understanding MapReduce, Word count program using traditional method and conventional methods Components of Hadoop -Working with files in HDFS, Reading and writing the Hadoop Distributed File system –The Design of HDFS, HDFS Concepts, The Command-Line Interface, Hadoop commands , Hadoop Filesystem

UNIT-III
MapReduce: Hadoop EcoSystem – Moving Data in and out of Hadoop – Understanding inputs and outputs of MapReduce . Anatomy of a MapReduce program, A Weather Dataset, Analyzing the Data with UnixTools, Analyzing the Data with Hadoop, Scaling Out, Hadoop Streaming, Hadoop Pipes, Hadoop Archives, Getting the patent data set, constructing the basic template of a Map Reduce program

UNIT-IV
MapReduce Advanced Programming: Advanced MapReduce - Chaining Map Reduce jobs,joining data from different sources, creating a Bloom filter, passing job-specific parameters to your tasks, probing for task-specific information, partitioning into multiple output files, inputting from and outputting to a database, keeping all output in sorted order.

UNIT-V
Graph Representation in Map Reduce: Modeling data and solving problems with graphs, Shortest Path Algorithm, Friends-of-Friends Algorithm, PageRank Algorithm, Bloom Filter, Zookeeper – how it helps in monitoring a cluster, HBase uses Zookeeper and how to Build Applications with Zookeeper.

TEXT BOOKS:
1. Dirk deRoos, Chris Eaton, George Lapis, Paul Zikopoulos, Tom Deutsch “UnderstandingBigData Analytics for Enterprise Class Hadoop and Streaming Data”, 1st Edition, TMH,2012.
2. Hadoop: The Definitive Guide by Tom White, 3rd Edition, O’reilly

REFERENCE BOOKS:
1. Hadoop in Action by Chuck Lam, MANNING Publ.
2. Hadoop in Practice by Alex Holmes, MANNING Publishers
3. Mining of massive datasets, AnandRajaraman, Jeffrey D Ullman, Wiley Publications.
4. Boris lublinsky, Kevin t. Smith, Alexey Yakubovich, “Professional Hadoop
Solutions”,Wiley,ISBN:9788126551071,2015.
5. Big Data Black Book ( Covers Hadoop 2, Map Reduce, Hive, Yarn, Pig & amp; Data Visualization ) - Dream Tech Publications
6. Chris Eaton, Dirk deroos et al. , “Understanding Big data ”, McGraw Hill, 2012.
7. Tom White, “HADOOP: The definitive Guide” , O Reilly 2012.
8. Vignesh Prajapati, “Big Data Analytics with R and Haoop”, Packet Publishing 2013.
9. Tom Plunkett, Brian Macdonald et al, “Oracle Big Data Handbook”, Oracle Press,
2014.
10. Jy Liebowitz, “Big Data and Business analytics”, CRC press, 2013.

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...