Run your Mapreduce programme in standlone Mode and PseudoDistributed mode
Posted By : Md Qasim Siddiqui | 28-Dec-2014
In this blog, you will read how to run your mapreduce programme in pseudodistributed mode. First of all configure some hadoop configuration files.
- Core-site.xml
hadoop.tmp.dir /app/hadoop/tmp A base for other temporary directories. fs.default.name hdfs://hostname:9000 The name of the default file system. A URI whose scheme and authority determine the FileSystem implementation.
-
Mapred-site.xml
mapred.job.tracker hostname:8021
Now write wordcount mapreduce programme.
package org.apache.hadoop.examples;
import java.io.IOException;
import java.util.StringTokenizer;
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.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
public class WordCount {
public static class TokenizerMapper
extends Mapper
This programme will run in standlone mode and take input from your local machine(“/home/user/input/”) and create output in “/home/user/output/”.
To run this programme in Pseudo distributed mode just make small changes in above programme, add these lines in your programme.
conf.set("fs.default.name","hdfs://hostname:9000");
conf.set("mapred.job.tracker","hostname:8021");
Well, after adding these lines your mapreduce programme will run in pseudo distributed mode . Your programme will take input from HDFS directory and also create output in HDFS too.
So, before giving input and output path in above programme create input directory in HDFS and add file into it which you want to process.
Hope, This solution will help your to run programme in pseudo-distributed mode.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Md Qasim Siddiqui
Qasim is an experienced web app developer with expertise in groovy and grails,Hadoop , Hive, Mahout, AngularJS and Spring frameworks. He likes to listen music in idle time and plays counter strike.