Showing posts with label Hadoop. Show all posts
Showing posts with label Hadoop. Show all posts

Spark vs Hadoop


Hadoop (MapReduce)



  • Uses disk-based batch processing
  • Slower due to frequent read/write to disk
  • More complex code (typically Java-based)
  • Good fault tolerance via HDFS replication
  • No native real-time processing (requires external tools like Apache Storm)
  • Machine learning via external tools like Apache Mahout
  • Best for: large-scale, cost-effective batch jobs




Apache Spark




  • Uses in-memory processing (much faster)
  • Supports batch, real-time, and streaming workloads
  • Easier to use with high-level APIs (Scala, Python, Java, R)
  • Efficient fault tolerance using RDD lineage
  • Built-in Spark Streaming and Structured Streaming
  • Includes MLlib for machine learning
  • Best for: fast, iterative tasks, real-time analytics, and machine learning



From Blogger iPhone client

Pig and using oozie - use cases

Apache Pig is a high-level platform for creating MapReduce programs used with Hadoop. It provides a scripting language called Pig Latin, which simplifies complex data transformations, processing, and analysis in Hadoop. Pig is well-suited for processing large data sets and performing ETL (Extract, Transform, Load) tasks.


Here’s a brief overview and some common use cases of using Apache Pig with Oozie.


Introduction to Pig



1. What is Pig?

• Apache Pig is a data flow language primarily used for analyzing large datasets in Hadoop. Pig scripts are written in a language called Pig Latin, which is similar to SQL but provides more flexibility.

• Pig simplifies data processing tasks with high-level abstractions and reduces the amount of code needed compared to traditional MapReduce.

2. Pig Architecture

• Pig scripts are converted into a series of MapReduce jobs that are executed on a Hadoop cluster.

• It has two modes of execution: Local Mode (where Pig runs on a single machine) and MapReduce Mode (where Pig interacts with HDFS on a Hadoop cluster).

3. Core Components of Pig Latin

• LOAD: Loads data from HDFS or other sources.

• FILTER: Filters data based on specified conditions.

• JOIN: Combines data from multiple datasets.

• GROUP: Groups data by one or more fields.

• FOREACH … GENERATE: Processes and transforms each record.

• STORE: Saves processed data back to HDFS.


Common Use Cases of Pig in Oozie Workflows


Using Pig with Oozie allows you to automate data processing tasks, making it ideal for ETL workflows and complex data transformations. Here are some use cases:


1. ETL (Extract, Transform, Load) Pipelines



• Use Case: Load raw data, transform it, and store the cleaned data.

• Example: You might have raw log data in HDFS that needs to be filtered, cleaned, and aggregated before storing it for analysis.

• Implementation: Use Pig to load the raw data, filter out irrelevant records, clean or format the data, and save the output. Schedule this as a recurring workflow in Oozie for continuous ETL processing.


2. Data Aggregation and Summarization



• Use Case: Aggregate large datasets to create summary reports.

• Example: A retail company may want to summarize daily transactions by aggregating sales data.

• Implementation: Use Pig to load transaction records, group by date or product category, calculate total sales, and save the results. With Oozie, you can automate the aggregation to run daily, weekly, or monthly.


3. Data Cleaning and Transformation



• Use Case: Preprocess raw data for machine learning or analytics.

• Example: Filter and clean sensor data by removing outliers or missing values.

• Implementation: Use Pig to load sensor data, apply transformations (such as filtering outliers), and save the cleaned data. Oozie can schedule this data cleaning process periodically or in response to new data arrival.


4. Data Join and Enrichment



• Use Case: Combine datasets to enrich data for analysis.

• Example: Joining customer data with transaction data to create a comprehensive dataset.

• Implementation: Use Pig to load both datasets, join them on a common key, and store the enriched dataset. With Oozie, you can set up workflows to run this job as soon as new data is available.


Example of Using Pig with Oozie


Here’s a basic example of integrating a Pig job into an Oozie workflow.


Step 1: Create a Pig Script (e.g., process_data.pig)


This Pig script filters and processes data from a sample HDFS file.


-- Load data from HDFS

data = LOAD '/user/hadoop/input_data' USING PigStorage(',') AS (id:int, name:chararray, age:int, salary:float);


-- Filter out records where age is less than 25

filtered_data = FILTER data BY age >= 25;


-- Group by age and calculate average salary

grouped_data = GROUP filtered_data BY age;

average_salary = FOREACH grouped_data GENERATE group AS age, AVG(filtered_data.salary) AS avg_salary;


-- Store the result back to HDFS

STORE average_salary INTO '/user/hadoop/output_data' USING PigStorage(',');


Step 2: Define the Oozie Workflow XML (e.g., workflow.xml)


This workflow includes a Pig action that references the Pig script.


<workflow-app xmlns="uri:oozie:workflow:0.5" name="pig_workflow">


  <!-- Start node -->

  <start to="pig-node"/>


  <!-- Define Pig action -->

  <action name="pig-node">

    <pig>

      <job-tracker>${jobTracker}</job-tracker>

      <name-node>${nameNode}</name-node>

      <script>/user/hadoop/pig/process_data.pig</script>

      <param>input=/user/hadoop/input_data</param>

      <param>output=/user/hadoop/output_data</param>

    </pig>

    <ok to="end"/>

    <error to="kill"/>

  </action>


  <!-- Kill node for error handling -->

  <kill name="kill">

    <message>Workflow failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>

  </kill>


  <!-- End node -->

  <end name="end"/>


</workflow-app>


Step 3: Define the Properties File (e.g., job.properties)


This file contains configuration properties for the Oozie job.


nameNode=hdfs://namenode:8020

jobTracker=jobtracker:8032

oozie.wf.application.path=${nameNode}/user/hadoop/oozie/workflows/pig_workflow

input=/user/hadoop/input_data

output=/user/hadoop/output_data


Step 4: Upload and Run the Workflow


Upload the Pig script, workflow, and properties file to HDFS, and then submit the workflow to Oozie.


hadoop fs -mkdir -p /user/hadoop/oozie/workflows/pig_workflow

hadoop fs -put process_data.pig /user/hadoop/oozie/workflows/pig_workflow

hadoop fs -put workflow.xml /user/hadoop/oozie/workflows/pig_workflow

oozie job -oozie http://oozie-server:11000/oozie -config job.properties -run


Benefits of Using Pig with Oozie



• Automation: Oozie allows you to schedule and automate Pig jobs, making it ideal for regular ETL tasks.

• Error Handling: You can specify error nodes in Oozie workflows to handle job failures.

• Data Pipelines: Oozie workflows can include multiple actions, such as Hive or Spark, making it easy to create complex data processing pipelines that include Pig.


Apache Pig, combined with Oozie, is powerful for automating, managing, and scaling data processing workflows in a Hadoop environment.


From Blogger iPhone client

Cloudera Security Assessment

A Cloudera Security Assessment is a process of evaluating the security posture of a Cloudera environment. It involves identifying and assessing security risks, vulnerabilities, and misconfigurations. The goal of a Cloudera Security Assessment is to improve the security of the environment and reduce the risk of data breaches and other security incidents.

A Cloudera Security Assessment can be conducted by a third-party security firm or by internal security teams. The assessment typically includes the following steps:

  1. Gathering information: The first step is to gather information about the Cloudera environment, including the configuration of the systems, the security policies in place, and the data that is stored in the environment.
  2. Identifying risks: The next step is to identify security risks, vulnerabilities, and misconfigurations. This can be done by conducting a vulnerability scan, reviewing the security policies, and interviewing the system administrators.
  3. Evaluating risks: The identified risks are then evaluated to determine their severity and impact. This helps to prioritize the risks that need to be addressed first.
  4. Recommending remediations: The security assessment team will then recommend remediations for the identified risks. This may involve updating the security policies, changing the configuration of the systems, or implementing new security controls.
  5. Implementing remediations: The final step is to implement the recommended remediations. This may involve working with the system administrators to make the necessary changes.

A Cloudera Security Assessment is an important part of ensuring the security of a Cloudera environment. It can help to identify and address security risks before they can be exploited by attackers.

Here are some of the benefits of conducting a Cloudera Security Assessment:

  • Identify security risks: A Cloudera Security Assessment can help to identify security risks that may not be known to the organization.
  • Assess the security posture: A Cloudera Security Assessment can help to assess the overall security posture of the environment and identify areas that need improvement.
  • Recommend remediations: A Cloudera Security Assessment can recommend remediations for the identified risks.
  • Improve security: A Cloudera Security Assessment can help to improve the security of the environment and reduce the risk of data breaches and other security incidents.

If you are responsible for the security of a Cloudera environment, I recommend that you conduct a Cloudera Security Assessment on a regular basis. This will help to ensure that the environment is secure and that the risks are minimized.

Installing Apache Zeppelin on a Hadoop Cluster

Apache Zeppelin(https://zeppelin.incubator.apache.org/)  is a web-based notebook that enables interactive data analytics. You can make data-driven, interactive and collaborative documents with SQL, Scala and more.


This document describes the steps you can take to install Apache Zeppelin on a CentOS 7 Machine.


Steps

Note: Run all the commands as Root


Configure the Environment

Install Maven (If not already done)

cd /tmp/

wget https://archive.apache.org/dist/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz

tar xzf apache-maven-3.1.1-bin.tar.gz -C /usr/local

cd /usr/local

ln -s apache-maven-3.1.1 maven

Configure Maven (If not already done)

#Run the following

export M2_HOME=/usr/local/maven

export M2=${M2_HOME}/bin

export PATH=${M2}:${PATH}

Note: If you were to login as a different user or logout these settings will be whipped out so you won’t be able to run any mvn commands. To prevent this, you can append these export statements to the end of your ~/.bashrc file:


#append the export statements

vi ~/.bashrc

#apply the export statements

source ~/.bashrc


Install NodeJS


Note: Steps referenced from https://nodejs.org/en/download/package-manager/


curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -


yum install -y nodejs

Install Dependencies

Note: Used for Zeppelin Web App


yum install -y bzip2 fontconfig

Install Apache Zeppelin

Select the version you would like to install

View the available releases and select the latest:


https://github.com/apache/zeppelin/releases


Override the {APACHE_ZEPPELIN_VERSION} placeholder with the value you would like to use.



Download Apache Zeppelin

cd /opt/

wget https://github.com/apache/zeppelin/archive/{APACHE_ZEPPELIN_VERSION}.zip

unzip {APACHE_ZEPPELIN_VERSION}.zip

ln -s /opt/zeppelin-{APACHE_ZEPPELIN_VERSION-WITHOUT_V_INFRONT} /opt/zeppelin

rm {APACHE_ZEPPELIN_VERSION}.zip

Get Build Variable Values

Get Spark Version

Running the following command


spark-submit --version

Override the {SPARK_VERSION} placeholder with this value.


Example: 1.6.0


Get Hadoop Version

Running the following command


hadoop version

Override the {HADOOP_VERSION} placeholder with this value.


Example: 2.6.0-cdh5.9.0


Take the this value and get the major and minor version of Hadoop. Override the {SIMPLE_HADOOP_VERSION} placeholder with this value.


Example: 2.6


Build Apache Zeppelin

Update the bellow placeholders and run


cd /opt/zeppelin

mvn clean package -Pspark-{SPARK_VERSION} -Dhadoop.version={HADOOP_VERSION} -Phadoop-{SIMPLE_HADOOP_VERSION} -Pvendor-repo -DskipTests

Note: this process will take a while


 


Configure Apache Zeppelin

Base Zeppelin Configuration

Setup Conf

cd /opt/zeppelin/conf/

cp zeppelin-env.sh.template zeppelin-env.sh

cp zeppelin-site.xml.template zeppelin-site.xml

Setup Hive Conf

# note: verify that the path to your hive-site.xml is correct

ln -s /etc/hive/conf/hive-site.xml /opt/zeppelin/conf/

Edit zeppelin-env.sh

Uncomment export HADOOP_CONF_DIR

Set it to export HADOOP_CONF_DIR=“/etc/hadoop/conf”


Starting/Stopping Apache Zeppelin

Start Zeppelin

/opt/zeppelin/bin/zeppelin-daemon.sh start

Restart Zeppelin

/opt/zeppelin/bin/zeppelin-daemon.sh restart

Stop Zeppelin

/opt/zeppelin/bin/zeppelin-daemon.sh stop

Viewing Web UI

Once the zeppelin process is running you can view the WebUI by opening a web browser and navigating to:


http://{HOST}:8080/


Note: Network rules will need to allow this communication


Runtime Apache Zeppelin Configuration

Further configurations maybe needed for certain operations to work


Configure Hive in Zeppelin

Open the cloudera manager and get the public host name of the machine that has the HiveServer2 role. Identify this as HIVESERVER2_HOST

Open the Web UI and click the Interpreter tab

Change the Hive default.url option to: jdbc:hive2://{HIVESERVER2_HOST}:10000


Cloudera Vs Horton Works - Big Data

Cloudera and Hortonworks are two of the leading providers of Hadoop distributions. They both offer a wide range of features and capabilities, but there are some key differences between them.

Cloudera is a commercial company that offers a proprietary distribution of Hadoop. It includes a range of additional features and services, such as support, training, and consulting. Cloudera is a good choice for organizations that need a turnkey solution and that want the support of a commercial vendor.

Hortonworks is an open source company that offers a distribution of Hadoop that is certified by the Apache Software Foundation. It does not include any proprietary features or services. Hortonworks is a good choice for organizations that want to save money and that are comfortable managing their own Hadoop environment.

Here is a table summarizing the key differences between Cloudera and Hortonworks:

FeatureClouderaHortonworks
TypeCommercialOpen source
FeaturesIncludes proprietary features and servicesOnly includes open source features
SupportIncludes support, training, and consultingDoes not include support, training, or consulting
PriceMore expensiveLess expensive
ManagementManaged by ClouderaManaged by the organization

Ultimately, the best choice for you will depend on your specific needs and requirements. If you need a turnkey solution and that want the support of a commercial vendor, then Cloudera is a good choice. If you want to save money and that are comfortable managing your own Hadoop environment, then Hortonworks is a good choice.

Here are some additional things to consider when choosing between Cloudera and Hortonworks:

  • Your budget: Cloudera is more expensive than Hortonworks. If you are on a tight budget, then Hortonworks may be a better choice for you.
  • Your technical expertise: If you are not familiar with Hadoop, then you may want to choose Cloudera. It includes support, training, and consulting that can help you get started.
  • Your future plans: If you plan to use Hadoop for a variety of purposes, then Cloudera may be a better choice. It offers a wider range of features and capabilities than Hortonworks.