Lecture 7 - Practice MapReduce with EMR
Roadmap
- Practice MapReduce With Amazon EMR (hands-on lab)
- Your Assignment Tasks
- Follow tutorial steps and capture screen along the way
- Complete an exercise
- Steps
- Create Amazon EMR
- Access Web UI of HDFS, YARN
- Create Wordcount MapReduce
- Run Wordcount on EMR
- Check Result on CLI
- Check Result file on HDFS
- Check MapReduce process on YARN
- Exercise: Create MapReduce program to list unique ID with total count of each ID

Related
- Lecture 6 - MapReduce Framework and Programming — theory behind Mapper / Reducer / Driver used in this lab
- HW4 - MapReduce on EMR — the homework built on this lab
Your Assignment Tasks
- Follow Tutorial Steps and capture screen along the way
- Complete an exercise
- Slides marked CAPTURE SCREEN = take a screenshot for your submission
- AWS EMR: Ready to use
- Test Web Access for HDFS GUI
- Test Web Access for YARN GUI
- Ready to Run MapReduce
- Execute MapReduce job
- Check Result from CLI
- Check Result file on HDFS
- Check MapReduce process on YARN
Steps (Overview)
- Tutorial
- Create Amazon EMR
- Access Web UI of HDFS, YARN
- Create Wordcount MapReduce
- Run Wordcount on EMR
- Check Result on CLI
- Check Result file on HDFS
- Check MapReduce process on YARN
- Exercise
- Create MapReduce Program to list of unique ID with total count of each id
Think of the lab as a cooking class: first the chef (tutorial) shows you how to make one dish (WordCount) step by step, then you cook a slightly different dish on your own (count taxi IDs) using the same recipe pattern.
Hadoop on Cloud: AWS EMR
- Access to AWS Learner Lab (50 USD credits)
- Select EMR service and click "Create cluster"
- EMR will stop after some time or after stop lab
- For next time, you can select "Clone" (copies the previous cluster's settings)

- Amazon EMR (Elastic MapReduce) = AWS's managed Hadoop/Spark cluster service
- AWS sets up the machines (EC2), installs Hadoop & friends, and connects them for you
EMR is like renting a fully-furnished apartment instead of building a house: you pick the size and the furniture (Hadoop, Spark, Hive...), AWS builds it in ~10 minutes, and you just move in and start working.
AWS EMR: Choose Big Data Framework
- Define Cluster Name (e.g.
My cluster) - Select EMR version:
emr-7.9.0- It matches with some version of the Hadoop ecosystem (e.g. Hadoop 3.4.1)
- Select only services you want (Application bundle → Custom):
- Hadoop, Tez
- Hive, Hue, Pig
- Spark, Livy
- JupyterHub, Zeppelin

| Service | What it is (quick idea) |
|---|---|
| Hadoop | HDFS (storage) + YARN (resource manager) + MapReduce |
| Tez | Faster execution engine used by Hive/Pig |
| Hive | SQL-like queries on Hadoop data |
| Hue | Web UI for Hadoop (browse files, run queries) |
| Pig | Scripting language for data flows on Hadoop |
| Spark | In-memory big data processing engine |
| Livy | REST service to submit Spark jobs |
| JupyterHub / Zeppelin | Web notebooks for data analysis |
AWS EMR: Select Hardware
- Select Instance groups (Uniform instance groups)
- 1 Primary node and 2 Core nodes
- Select
m4.large(2 vCore, 8 GiB memory, EBS only storage) - No task node
- Cluster scaling: Set cluster size manually → Core instance size = 2

- Node roles:
- Primary node (master) — runs the NameNode (HDFS) and ResourceManager (YARN); you SSH into this one
- Core nodes — run DataNode (store HDFS blocks) and NodeManager (run map/reduce tasks)
- Task nodes — only compute, no HDFS storage (not used here)
Primary node = the team manager who keeps the to-do list and knows where every file is. Core nodes = the workers who both store the files and do the work. Task nodes = temp workers who only help with work (we don't hire any).
AWS EMR: Select Network
- Use default VPC and subnet (no need to change anything)
- EC2 security groups (firewall) are created automatically:
- Primary node → Create ElasticMapReduce-Primary
- Core and task nodes → Create ElasticMapReduce-Core

AWS EMR: Cluster Termination and Node Replacement
- Cluster termination and node replacement: Set 3 hours
- Termination option: Automatically terminate cluster after idle time (Recommended)
- Idle time:
0 days03:00:00 - (Time must be > 1 minute and < 7 days, hh:mm:ss 24-hour format)
- Use termination protection ✓ — protects the cluster from accidental shutdown (must turn off protection before terminating)
- Unhealthy node replacement: Turn on — EMR gracefully stops processes on unhealthy nodes and replaces them with new EC2 instances

Auto-terminate after idle = a "sleep timer" on your TV. If you forget to turn the cluster off, it shuts itself down after 3 hours of doing nothing, so you don't burn your 50 USD credits.
AWS EMR: Assign Cluster Logs
- Check name of default S3 bucket location
- e.g.
s3://aws-logs-<account-id>-us-east-1/elasticmapreduce - ✓ Publish cluster-specific logs to Amazon S3
- e.g.
- Go to S3 to create S3 bucket with the same name (e.g.
aws-logs-<account-id>-us-east-1)

AWS EMR: Assign Security Key Pair
- For remote access to cluster, assign security key pair: select
vockey- Field: Amazon EC2 key pair for SSH to the cluster
- Keypair download from AWS Details of learner lab
- Download PEM

- PEM = private key file used by
ssh(Mac/Linux, MobaXterm) - PPK = PuTTY format of the same key (Windows PuTTY)
The key pair is like a lock-and-key set: AWS puts the lock (
vockeypublic key) on the cluster's door, and you keep the key (.pemfile). Without the key, nobody can SSH in.
AWS EMR: Assign Instance Profile and Service Role
- Assign EMR Service Role
- Choose an existing service role →
EMR_DefaultRole - The service role is an IAM role that EMR assumes to provision resources and perform service-level actions with other AWS services
- Choose an existing service role →
- Instance profile assigns a role to every EC2 instance in a cluster
- Choose an existing instance profile →
EMR_EC2_DefaultRole - Must specify a role that can access the resources for your steps and bootstrap actions (e.g. S3)
- Choose an existing instance profile →

| Role | Who uses it | Purpose |
|---|---|---|
| EMR_DefaultRole | The EMR service itself | Create/manage EC2 instances, networking, etc. |
| EMR_EC2_DefaultRole | Each EC2 node in the cluster | Read/write S3, write logs, etc. |
Service role = the permission slip for the contractor (EMR) to build the house. Instance profile = the badge each worker (EC2 node) wears so they can enter the storage room (S3).
AWS EMR: Create Cluster
- Click Create cluster
- It may take up to 10 minutes for the cluster to start
- Status shows Starting at first

AWS EMR: Ready to Use
CAPTURE SCREEN
- Wait until status shows
WaitingWaiting= cluster is up and idle, ready to accept jobs
- Use Primary node public DNS for remote connection
- e.g.
ec2-xx-xx-xx-xx.compute-1.amazonaws.com
- e.g.

- Cluster states: Starting → Bootstrapping → Running → Waiting (→ Terminating → Terminated)
AWS EMR: Ready to Use — Application UIs
- Check application UI for each service (Applications tab → Application UIs on the primary node)
- These require SSH tunneling to be enabled (or opening the port in the firewall, see below)
| Application | Port | URL pattern |
|---|---|---|
| HDFS Name Node | 9870 | http://<primary-dns>:9870/ |
| Hue | 8888 | http://<primary-dns>:8888/ |
| JupyterHub | 9443 | https://<primary-dns>:9443/ |
| Livy | 8998 | http://<primary-dns>:8998/ |
| Resource Manager (YARN) | 8088 | http://<primary-dns>:8088/ |
| Spark History Server | 18080 | http://<primary-dns>:18080/ |
| Tez UI | 8080 | http://<primary-dns>:8080/tez-ui |
| Zeppelin | 8890 | http://<primary-dns>:8890/ |

AWS EMR: Add SSH Allow on Firewall
- For best practice, we should not allow anyone to access the cluster
- So, we will allow only specific IP or subnet to access
- First, check your public IP: go to Google and type
my ip- Or try this web: https://whatismyipaddress.com/
- Then, allow this IP to access cluster
- If you change network, IP may change (→ must update the rule again)

A security group is the building's security guard with a guest list. By default nobody from outside is on the list. You add only your own IP so the guard lets just you in — if you move to another Wi-Fi (new IP), the guard won't recognize you until you update the list.
AWS EMR: Add SSH Allow on Firewall (Steps)
- Go to security group of primary node (Properties → Network and security → EC2 security groups → Primary node
sg-...) - Click link and select Edit inbound rule
- Add new rule with SSH and source is your public IP
- Type: SSH, Protocol: TCP, Port range: 22
- Source: Custom →
<your-public-ip>/32 - Description:
SSH access
- Save Rule

/32= CIDR notation meaning exactly one IP address (all 32 bits fixed)
AWS EMR: Add Allow GUI Access on Firewall
- Add port:
9870and8088for HDFS GUI and YARN GUI (allow only your public IP) - On Security group of primary node (
ElasticMapReduce-master)
| Type | Protocol | Port | Source | Description |
|---|---|---|---|---|
| SSH | TCP | 22 | <your-ip>/32 | SSH |
| Custom TCP | TCP | 9870 | <your-ip>/32 | HDFS |
| Custom TCP | TCP | 8088 | <your-ip>/32 | YARN |

Test Web Access for HDFS GUI
CAPTURE SCREEN
- Open
http://Change-to-your-primary-dns-name:9870
http://<primary-node-public-dns>:9870
- What you see:
- Overview — NameNode is active, Hadoop version 3.4.1-amzn-1
- Summary — Security off, Safemode off, number of files & blocks, heap memory
- Datanodes tab — should show 2 live DataNodes (the 2 core nodes)
- Note: Hadoop 3 uses port 9870 for the NameNode UI (older Hadoop 2 used 50070)
Test Web Access for YARN GUI
CAPTURE SCREEN
- Open
http://Change-to-your-primary-dns-name:8088
http://<primary-node-public-dns>:8088
- What you see:
- Cluster Metrics — Apps Submitted / Pending / Running / Completed, Memory Total, VCores Total
- Cluster Nodes Metrics — Active Nodes = 2
- Scheduler — Capacity Scheduler
- Application list is empty (no job run yet)
HDFS UI (9870) = the warehouse inventory screen (what files are stored where). YARN UI (8088) = the factory job board (which jobs are running, finished, or failed).
Use MobaXterm to Remote SSH to EMR (Windows)
- For Windows: https://mobaxterm.mobatek.net/download.html
- Select Home Edition (Free)
- Full X server and SSH support, remote terminal (SSH, telnet, rlogin, Mosh), X11-forwarding, automatic SFTP browser, max 12 sessions, max 2 SSH tunnels, etc.

Another Option for SSH
- Check learner lab detail under Modules → Launch AWS Academy Learner Lab
- Check link SSH Access from Windows or SSH Access from a Mac (in the Readme)
- Follow instruction

Use MobaXterm to Remote SSH to EMR (Session Setup)
- Create new session → SSH
- Host: copy from Primary node public DNS
- User:
hadoop - Port: 22
- Private key: download PEM from AWS Details of lab learner
- Advanced SSH settings → ✓ Use private key → select
labsuser.pem
- Advanced SSH settings → ✓ Use private key → select

For Mac
- Download PEM (AWS Details → SSH key → Download PEM)
- Open terminal and run:
cd ~/Downloads- Change the permissions on the key (check
.pemfilename, use the latest one):
chmod 400 labsuser.pem- Run ssh command to connect server:
ssh -i <filename>.pem hadoop@<Primary-node-public-dns>
- Why
chmod 400? →sshrefuses to use a private key that other users can read400= owner read-only, no permission for group/others
Ready to Run MapReduce!
CAPTURE SCREEN
- If it works, you should see the EMR logo and prompt for running CLI
- Prompt looks like
[hadoop@ip-172-31-xx-xx ~]$
- Prompt looks like

Your PC vs Primary Node vs Hadoop Cluster
- To prepare data for processing on Hadoop (HDFS) — 2 hops:
- Upload file to primary node (Your PC → EMR Primary Node, via SSH/SCP/SFTP)
- Import file on primary node to HDFS (Primary Node local disk → EMR Hadoop Service, via
hadoop fs -put)
- To run MR program:
- Upload program (
.jar) to primary node - Execute program (from the terminal of the primary node)
- Upload program (

Your PC ──(scp / SFTP upload)──► Primary node local disk ──(hadoop fs -put)──► HDFS
book.txt, MRWordCount.jar /home/hadoop/book.txt /wordcount/book.txt- Important distinction:
- Local file system of primary node (
/home/hadoop/...) ≠ HDFS (/wordcount/...) - The jar stays on the local disk (run with
hadoop jar) - The data must be in HDFS (MapReduce reads input from HDFS)
- Local file system of primary node (
Your PC = your home. Primary node = the front desk of a warehouse. HDFS = the actual warehouse shelves. You first carry the box to the front desk (upload), then the front desk puts it on the shelves (
hadoop fs -put). Workers (mappers) only pick items from the shelves, never from the front desk.
Create Your First Program: Word Count
- Prepare Java Development Environment
- Prepare library for Hadoop and MapReduce
- Create Mapper class
- Create Reducer class
- Create Main program
- Build Jar file
- Upload Jar file to Hadoop cluster
- Upload data file to HDFS
- Execute job
Prepare Java Development Environment
- Use Eclipse (it can be any version) for Java Development with JDK 1.8
- https://www.eclipse.org/downloads/packages/
- Download Eclipse IDE for Java Developers (Windows x86_64 / macOS x86_64 | AArch64 / Linux x86_64 | AArch64)

Prepare Java Development Environment — Project Setup
- Create project
MRWordcount - Define package as your student id
- Create three files:
WordCountDriver,WordCountMapper,WordCountReducer - Create folder
liband copy Hadoop and MapReduce lib tolibfolderhadoop-common-2.10.2.jarhadoop-mapreduce-client-core-2.10.2.jar
- Add them to the Java Build Path → Libraries (Add JARs...)

- Provided tutorial files (
MRTutorialData/):
MRTutorialData/
├── data/
│ ├── book.txt ← input for WordCount (a book, ~7,426 lines, ~364 KB)
│ └── taxi.csv ← input for the Exercise (~255,000 rows)
├── lib/
│ ├── hadoop-common-2.10.2.jar
│ └── hadoop-mapreduce-client-core-2.10.2.jar
└── src/
├── WordCountDriver.java
├── WordCountMapper.java
└── WordCountReducer.javaPrepare Java Development Environment — Compiler Level
- After creating the Java project, select Properties → Java Compiler
- ✓ Enable project specific settings and select compiler compliance level: 1.8

- Why 1.8? → The jar is compiled on your PC but runs on the cluster's Java; compiling for Java 8 bytecode keeps it compatible with the cluster's JVM
Create Mapper Class
- For each line, split with white space and iterate over the words
- Output with word as key and one as value
package des431;
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
public class WordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable>{
public void map(LongWritable key, Text value,Context con) throws IOException, InterruptedException{
String line = value.toString(); //Get All lines from the input files
String[] words=line.split(" "); //Extract all the words
for(String word: words )
{
Text outputKey = new Text(word.toUpperCase().trim());
IntWritable outputValue = new IntWritable(1);
con.write(outputKey, outputValue);
}
}
}Mapper<LongWritable, Text, Text, IntWritable>=Mapper<KEYIN, VALUEIN, KEYOUT, VALUEOUT>- KEYIN
LongWritable— byte offset of the line in the file (not used) - VALUEIN
Text— the line of text - KEYOUT
Text— the word - VALUEOUT
IntWritable— the number 1
- KEYIN
word.toUpperCase().trim()→ "the", "The", "THE" all becomeTHE(case-insensitive count)con.write(...)→ emits the intermediate pair
The mapper is a person reading one line at a time and shouting "HELLO, 1!", "WORLD, 1!" for every word they see — they don't count anything, they just call out each word.
Create Reducer Class
- For each key, sum number of word over the input (intermediate output from mapper)
- Output with word as key and sum of value
package des431;
import java.io.IOException;
import java.util.Iterator;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
public class WordCountReducer extends Reducer<Text, IntWritable, Text, IntWritable>{
@Override
protected void reduce(Text key, Iterable<IntWritable> values, Context c) throws IOException, InterruptedException {
int sumOfValues = 0;
Iterator<IntWritable> valuesIt = values.iterator();
//Aggregate the values
while(valuesIt.hasNext()){
sumOfValues = sumOfValues + valuesIt.next().get();
}
c.write(key, new IntWritable(sumOfValues));
}
}Reducer<Text, IntWritable, Text, IntWritable>= input → output- Reducer input types must match the mapper's output types
- After shuffle & sort, each
reduce()call gets one word and all of its 1s
After the shuffle, each reducer is like a vote counter who gets a bag with all ballots for one candidate. They just count the ballots in the bag and write "CANDIDATE: total".
Create Main Class (Driver)
- Configure Job, assign name and main class
- Set Mapper and Reducer
- Set Output key and value
- Set Input and Output path
- Execute the job
package des431;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.mapreduce.Job;
public class WordCountDriver {
public static void main(String[] args) throws Exception {
//Configure Job
Job job = Job.getInstance(new Configuration());
job.setJobName("WordCounter");
job.setJarByClass(WordCountDriver.class);
//Configure Mapper and Reducer class
job.setMapperClass(WordCountMapper.class);
job.setReducerClass(WordCountReducer.class);
//Setting the expected types of output.
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
job.setOutputFormatClass(TextOutputFormat.class);
//Configure Input and Output directories.
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
//Start the job
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}- Line by line:
Job.getInstance(new Configuration())— create a new job using the cluster configsetJobName("WordCounter")— the name you will see in the YARN UIsetJarByClass(...)— tells Hadoop which jar to ship to the worker nodessetMapperClass/setReducerClass— plug in your Mapper & ReducersetOutputKeyClass(Text)/setOutputValueClass(IntWritable)— final output typesTextOutputFormat— writes each pair askey<TAB>valueper lineargs[0]= input path (HDFS),args[1]= output path (HDFS, must not exist yet)waitForCompletion(true)— run the job and print progress; exit code0= success,1= failed
The Driver is the project manager's job ticket: "Job name: WordCounter. Readers: WordCountMapper. Counters: WordCountReducer. Take boxes from
/wordcount, put results in/wordcount_output. Go!"
Build Jar File
- Right click at project and select Export
- Select Java → JAR file
- Select resource (the
MRWordCountproject) - Select export destination
- Path
- Filename (e.g.
MRWordCount.jar)
- Finish → produces
MRWordCount.jar

- JAR (Java ARchive) = a zip of your compiled
.classfiles — this is what Hadoop runs - The Hadoop libraries do not need to be inside the jar — the cluster already has them
Upload Jar File to Hadoop Cluster
- Connect to Hadoop cluster via ssh
- You can use MobaXterm software, upload
MRWordCount.jarandbook.txt(from assignment) - MobaXterm's left SFTP panel (
/home/hadoop/) → click the upload (↑) button
- You can use MobaXterm software, upload
- On Mac/Linux you can use
scpinstead:
scp -i labsuser.pem MRWordCount.jar book.txt hadoop@<Primary-node-public-dns>:/home/hadoop/
Upload Data to HDFS
- First upload file to Hadoop cluster (local path). Use file:
book.txtfrom Assignment - Use
mkdircommand to create an input directory in HDFS
$HADOOP_HOME/bin/hadoop fs -mkdir /wordcount
# Or
hadoop fs -mkdir /wordcount- Use
putcommand to copy the input file (document.txt) to the input directory of HDFS
$HADOOP_HOME/bin/hadoop fs -put /home/hadoop/book.txt /wordcount- Use
lscommand to verify the files in the input directory of HDFS
$HADOOP_HOME/bin/hadoop fs -ls /wordcount
| Command | Meaning |
|---|---|
hadoop fs -mkdir <dir> | Create a directory in HDFS |
hadoop fs -put <local> <hdfs> | Copy a file from local disk → HDFS |
hadoop fs -ls <dir> | List files in HDFS |
hadoop fs -cat <file> | Print a file in HDFS |
hadoop fs -<cmd>works just like normal Linux commands (mkdir,ls,cat), except it acts on the HDFS warehouse, not the primary node's own disk.
Execute MapReduce Job
CAPTURE SCREEN
- Use
jarcommand to run the MapReduce program in the jar file - Output directory will be created automatically
hadoop jar MRWordCount.jar your_student_id.WordCountDriver /wordcount /wordcount_output- Structure of the command:
hadoop jar <jar file> <package>.<MainClass> <input dir in HDFS> <output dir in HDFS>
└── args[0] └── args[1]
- Reading the log:
number of splits: 1→ 1 map task (file is smaller than one HDFS block of 128 MB)map X% reduce Y%→ progress; reducers start after maps finishcompleted successfully+Counters→ job done; counters show records read/written
- ⚠️ If the output directory already exists, the job fails (
FileAlreadyExistsException) → delete it first or use a new name:
hadoop fs -rm -r /wordcount_outputCheck Result from CLI
CAPTURE SCREEN
- Use
catcommand to view the output. Better to uselsfirst to check files part-r-00000is the output file. If the input file is very large, the output may have multiple files — equal to number of reducers
$HADOOP_HOME/bin/hadoop fs -ls /wordcount_output
$HADOOP_HOME/bin/hadoop fs -cat /wordcount_output/part-r-00000
- Output files:
_SUCCESS— empty marker file = the job finished successfullypart-r-00000,part-r-00001, ... — one per reducer (r= reducer output;mwould be map-only output)- Each line =
WORD<TAB>count
- Notice punctuation stays attached (
"AFTER,!)) because the mapper only splits on a space" "
Each reducer writes its own result sheet. 3 reducers → 3 sheets (
part-r-00000..00002). Together they make the full answer; each word appears in exactly one of them.
Check Result File on HDFS
CAPTURE SCREEN
- Access to HDFS GUI
- Utilities ⇒ Browse the file system
- Make sure to see URL in the capture

- Columns: Permission, Owner, Group, Size, Last Modified, Replication, Block Size (128 MB), Name
Check MapReduce Process on YARN
- Access to YARN GUI (
http://<primary-dns>:8088) - Select your application:
WordCounter(the name set byjob.setJobName(...))

CAPTURE SCREEN
- Click the application ID to see its details page

- Key fields:
- State =
FINISHED, FinalStatus =SUCCEEDED→ the job worked - Elapsed — total job time (e.g. 30 sec)
- Logs link — debug output if something fails
- State =
Exercise
- Create MapReduce Program to list of unique ID with total line count of each id
- Use file:
taxi.csv - Submit screen captures of the following steps:
- Execute MapReduce
- Check Result from CLI
- Check MapReduce Process on YARN
- Submit via Google Classroom Assignment

taxi.csvformat (no header, comma-separated) — first column is the taxi ID:
5yc/f14Tqe9XCRu5qCGxv5qo+ug,1,13.83610,100.47647,2017-04-11 09:10:26,0,288,0,1
EO8d8iuEH3vjgNQURcvOM/PxgQo,1,13.82045,100.46629,2018-08-01 00:00:10,0,169,1,0
7D8GUsE79mc8lTjsrfnVPrxRgU0,0,13.72489,100.54439,2018-08-01 00:00:11,10,8,0,1- Idea: it is WordCount with a different key
- Mapper: split each line by
,→ take column 0 (ID) → emit - Reducer: same sum logic as
WordCountReducer
- Mapper: split each line by
Same recipe, different ingredient: instead of counting how many times each word appears in a book, you count how many GPS records each taxi has in a log file.
- See full solution: HW4 - MapReduce on EMR
Done.

Summary — Full Command Cheat Sheet
# 1) On your Mac: connect to the primary node
cd ~/Downloads
chmod 400 labsuser.pem
scp -i labsuser.pem MRWordCount.jar book.txt taxi.csv hadoop@<primary-dns>:/home/hadoop/
ssh -i labsuser.pem hadoop@<primary-dns>
# 2) On the primary node: put data into HDFS
hadoop fs -mkdir /wordcount
hadoop fs -put /home/hadoop/book.txt /wordcount
hadoop fs -ls /wordcount
# 3) Run the job
hadoop jar MRWordCount.jar <your_package>.WordCountDriver /wordcount /wordcount_output
# 4) Check results
hadoop fs -ls /wordcount_output
hadoop fs -cat /wordcount_output/part-r-00000
# 5) Web UIs (open ports 9870 and 8088 for your IP first)
# HDFS: http://<primary-dns>:9870 (Utilities → Browse the file system)
# YARN: http://<primary-dns>:8088 (find app "WordCounter")| Item | Value |
|---|---|
| EMR release | emr-7.9.0 (Hadoop 3.4.1) |
| Nodes | 1 Primary + 2 Core, m4.large, no Task |
| Idle auto-terminate | 3 hours |
| Key pair | vockey (download labsuser.pem) |
| Roles | EMR_DefaultRole, EMR_EC2_DefaultRole |
| SSH user / port | hadoop / 22 |
| HDFS UI port | 9870 |
| YARN UI port | 8088 |
| Java level | 1.8 |
| Output files | _SUCCESS + part-r-0000N (one per reducer) |