Académique Documents
Professionnel Documents
Culture Documents
1 Hadoop Installation
2 Hadoop Configuration
4 Map Reduce
5 Mapreduce Implementation
Requirements
Necessary Optional
Java Version 1.7 or above Eclipse
ssh ( Secure shell ) Internet
Linux OS (Ubuntu Version 14.04 or above) connec-
tion
Hadoop framework
http://hadoop.apache.org/releases.html
Files to Configure
Add property in
/usr/local/hadoop/etc/hadoop/mapred-site.xml
In file we add The host name and port that the MapReduce job
tracker runs at. Add following in mapred-site.xml :
< property >
< name > mapred.job.tracker < /name >
< value > localhost : 54311 < /value >
< /property >
Map-Reduce Framework
Hadoop - MapReduce
MapReduce - WordCountMapper
Continue...
Continue...
MapReduce - WordCountReducer
WordCountJob
run method
public int run(String[] args) throws Exception {
// initializing the job object with configuration
Job job = new Job(getConf());
job.setJobName("Word count job");
job.setJarByClass(this.getClass()); // main job class
job.setMapperClass(WordCountMapper.class);
job.setReducerClass(WordCountReducer.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(LongWritable.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(LongWritable.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
return job.waitForCompletion(true) ? 0 : 1;
}
Bapatla Engineering College, Bapatla, Guntur
Big Data & Hadoop
November 22, 2016 Slide: 31 / 38
Outline Hadoop Installation Hadoop Configuration Starting & Stopping Map Reduce Mapreduce Implementation
main method
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;
main method
Continue ....
http://machine name:50070
http://machine name:8042
http://machine name:8088
kill -9 PID
hadoop fs -touchz /demo/test
hadoop fs -setrep -w 3 /demo/test
hadoop home/share/hadoop/mapreduceexamples
hadoop jar jarfilename mainclass parameters
/usr/local/hadoop/etc/hadoop/slaves
/usr/local/hadoop/etc/hadoop/masters
/etc/hostname
sudo reboot
thank You