Number of mappers and reducers can be set like (5 mappers, 2 reducers):
-D mapred.map.tasks=5 -D mapred.reduce.tasks=2
in the command line.
In the code, one can configure JobConf variables.
job.setNumMapTasks(5); // 5 mappers
job.setNumReduceTasks(2); // 2 reducers
Note that on Hadoop 2 (YARN), the mapred.map.tasks
and mapred.reduce.tasks
aredeprecated and are replaced by other variables:
mapred.map.tasks --> mapreduce.job.maps
mapred.reduce.tasks --> mapreduce.job.reduces
=============================================================
如果想在本地使用mapreduce,那么把mapreduce.framework.name和mapreduce.jobtracker.address都设置成local