Hita Juneja
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # UE22AM251B Big Data Lab 3 Monitoring Hadoop health and performance. ## Assignment Objectives and Outcomes * **Understanding Hadoop and MapReduce:** Gain a deep understanding of Hadoop, the Hadoop Distributed File System (HDFS), and the MapReduce programming model. Understand how Hadoop distributes and processes large datasets. * **Performance Metrics:** Learn about key performance metrics and factors that affect the performance of MapReduce jobs, such as job execution time, data locality, resource utilization, and network latency. * **Log Analysis:** Understand how to analyze log files generated by Hadoop daemons, including the JobTracker, TaskTracker, NameNode, and DataNode logs. Extract valuable information to identify performance bottlenecks and issues. ## Software/Languages to be used 1. Hadoop ```v3.3.6``` ## Tasks Overview Collect and analyze HDFS metrics for monitoring and performance analysis from both the NameNode, DataNodes and resource managers. HDFS emits metrics from two sources, the NameNode and the DataNodes, and for the most part each metric type must be collected at the point of origination. Both the NameNode and DataNodes emit metrics over an HTTP interface as well as via JMX. You will need to run 3 map reduce jobs concurrently, and monitor the performance of the datanodes and namenodes on ```localhost:8088``` and ```localhost:9870```. :::info Hostnames and ports for Hadoop JPS processes are not fixed, they may vary, but they are all noted and visible on terminal when running the map reduce task (hadoop jar command) and exposed at the endpoint```http://hostname:port``` ::: The NameNode offers a summary of health and performance metrics through an easy-to-use web UI. By default, the UI is accessible via port 9870, so point a web browser at: [```http://namenodehost:9870```](http://localhost:9870). The same metrics are accesible at the jmx endpoint, which is required to be submitted ([```http://namenodehost:9870/jmx```](http://localhost:9870/jmx)). A high-level overview of the health of your DataNodes is available in the NameNode dashboard, under the Datanodes tab: [```localhost:9870/dfshealth.html#tab-overview```](localhost:9870/dfshealth.html#tab-overview) The same metrics are accesible at the jmx endpoint, which is required to be submitted ([```http://datanodehost:9864/jmx```](http://datanodehost:9864/jmx)) ## Task Specifications You have to code a wordcount mapper and reducer to count the frequency of each word in the text file given [here](https://drive.google.com/file/d/1rH6x144b59hd8pZDJ43G0mMXu872vjZY/view?usp=sharing). This map reduce job is to be run concurrently(on 3 separate terminals) to separate hdfs output directories. ### Task 1 Open up namenode host and datanode hosts to observe memory and performance metrics. Run 3 MapReduce jobs parallely, refresh each of the pages and observe changes in job status, disk and resource usage. * Localhost:8088 (Resource manager dashboard) ![Screenshot 2023-12-28 at 10.33.31 AM](https://hackmd.io/_uploads/HJNc_LjD6.png) * Localhost:9870 (Namenode dashboard) ![Screenshot from 2023-11-04 13-39-10.png](https://hackmd.io/_uploads/H1NShOmma.png) <br /> * Navigate to ```Datanodes``` ![Screenshot from 2023-11-04 13-44-28.png](https://hackmd.io/_uploads/BJX9aO7m6.png) <br /> The same metrics can be collected via a jmx endpoint, like so: ``` curl "http://<namenodehost>:<namenodeport>/jmx" > srn_task1_namenode.json curl "http://<datanodehost>:<datanodeport>/jmx" > srn_task1_datanode.json ``` ### Task 2 This task involves intentionally limiting java heap memory, attempting to run all 3 jobs as done in the same manner as task 1 and recording stats. The aim here is the intentionally play around and affect some aspects of Hadoop daemon behavior, so that the same jobs that were successful in task 1, turn out failed, and to look for how the performance metrics reflect that. You can limit or decrease the overall heap size allocated to any map reduce task by adding the following property to ```mapred-site.xml``` in ```hadoop-3.3.6/etc/hadoop``` directory. :::info <b>Add the following property under the configuration tag in /etc/hadoop/mapred-site.xml ``` <property> <name>mapred.child.java.opts</name> <value>-Xmx64m</value> </property> ``` Or/And alternatively, you can set the same in ```hadoop-env.sh``` script in in ```hadoop-3.3.6/etc/hadoop``` directory. Uncomment the HADOOP_CLIENT_OPTS variable and set the memory limit, like so: ``` export HADOOP_CLIENT_OPTS="-Xmx64m $HADOOP_CLIENT_OPTS" ``` </b> ::: Now stop all hadoop daemon processes, format tmp directories and restart hadoop in ```sbin```: ``` ./stop-all.sh && sudo rm -rf ~/dfsdata/ && sudo rm -rf ~/tmpdata/ && hdfs namenode -format start-all.sh ``` Run the task 1 jobs in the same manner, open up the dashboards. ![Screenshot 2023-12-28 at 10.11.19 AM](https://hackmd.io/_uploads/SJYNePswp.png) ![Screenshot 2023-12-28 at 10.12.45 AM](https://hackmd.io/_uploads/SJBSgDsDa.png) Collect the same metrics via a jmx endpoint, like so: ``` curl "http://<namenodehost>:<namenodeport>/jmx" > srn_task2_namenode.json curl "http://<datanodehost>:<datanodeport>/jmx" > srn_task2_datanode.json ``` :::info Compare your JMX Json output files from both tasks side by side, and look for drastic differences in key value pairs such as ```MemHeapUsedM```, ```TotalCompilationTime```, ```TotalReadTime```, ```SystemLoadAverage```, ```GcTimeMillis```, ```SystemCpuLoad```, ```ProcessCpuLoad```. If a value is 0, or x times more than it's task 1's counterpart, that should indicate an unsuccessful job's behaviour in terms of it's performance. ::: ## Submission Guidelines You will need to make the following changes to your mapper.py and reducer.py scripts to run them on the portal. Include the following shebang on the first line of your code ` #!/usr/bin/env python3 ` Convert your files to executables ` chmod +x mapper*.py reducer*.py ` Convert line breaks in DOS format to Unix format (this is necessary if you are coding on Windows - your code will not run on our portal otherwise) ` dos2unix mapper*.py reducer*.py ` ## Tasks Deliverables Submit mapper, reducer, all your JMX Json output files (NameNode and DataNode) for both the tasks, in the specified naming format. >srn_mapper.py srn_reducer.py srn_task1_namenode.json srn_task1_datanode.json srn_task2_namenode.json srn_task2_datanode.json > ## Helpful Commands ### Running the MapReduce Job without Hadoop A MapReduce job can also be run without Hadoop. Although slower, this utility helps you debug faster and helps you isolate Hadoop errors from code errors. ``` cat path_to_dataset | python3 mapper.py [command line arguments] | sort -k 1,1 | python3 reducer.py [command line arguments] > output.txt ``` ## HDFS Operations The ```HDFS``` supports all file operations and is greatly similar to the file system commands available on Linux. You can access ```HDFS``` on command line using ```hdfs dfs``` and use the ```-``` prefix before the filesystem command to execute general Linux file system commands. #### Starting Hadoop Navigate to the hadoop folder and execute the following commands. start-all.shis a shell script that is used to start all the processes that hadoop requires. ``` cd cd hadoop-3.3.3/sbin/ ./start-all.sh ``` Type jps to find all the Java Processes started by the shell script. You should see a total of 6 processes, including the jps process. Note that the order of the items and the process IDs will be different. ``` 2994 DataNode 3219 SecondaryNameNode 3927 Jps 3431 ResourceManager 2856 NameNode 3566 NodeManager ``` #### Loading a file into HDFS A file can be loaded into ```HDFS``` using the following command. ```hdfs dfs -put path_to_file /hdfs_directory_path``` #### Listing files on HDFS Files can be listed on HDFS using ```hdfs dfs -ls /hdfs_directory_path``` Similarly, ```HDFS``` also supports ```-mkdir```, ```-rm``` and more. ### Running a MapReduce Job A MapReduce job can be run using the following command ``` hadoop jar path-to-streaming-jar-file \ -input path_to_input_file_on_hdfs \ -output path_to_output_folder_on_hdfs \ -mapper absolute_path_to_mapper.py command_line_arguments \ -reducer absolute_path_to_reducer.py command_line_arguments ``` Path to jar file example: hadoop jar /home/USER/hadoop-3.3.6/share/hadoop/tools/lib/hadoop-streaming-3.3.6.jar USER should be replaced with your vm user id or can also be replaced with $USER which automatically takes your vm's user id. #### To check the output, execute the following command ``` hdfs dfs -cat /output_directory_created_on_hdfs/part-00000 ``` #### To save the output to a file: ``` hdfs dfs -cat /output_directory_created_on_hdfs/part-00000 > filename.txt ``` #### To delete directory from hdfs cluster ``` hdfs dfs -rm -r /directory_name ``` Similary to delete files: ``` hdfs dfs -rm -r /directory_name/file_name ``` ## Useful links 1. https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/Metrics.html 2. https://www.datadoghq.com/blog/monitor-hadoop-metrics/ 3. https://stackoverflow.com/questions/8464048/out-of-memory-error-in-hadoop?rq=3

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully