如何在hive中设置mapreduce任务的数量等于1

时间:2011-12-27 10:42:18

标签: hadoop mapreduce hive elastic-map-reduce

我在hive中试过了 -

set hive.exec.reducers.max = 1;
set mapred.reduce.tasks = 1;

from flat_json
insert overwrite table aggr_pgm_measure PARTITION(dt='${START_TIME}')
reduce  log_time,
 req_id, ac_id, client_key, rulename, categoryname, bsid, visitorid, visitorgroupid, visitortargetid, targetpopulationid, windowsessionid, eventseq, event_code, eventstarttime
 using '${SCRIPT_LOC}/aggregator.pl' as 
 metric_id, metric_value, aggr_type, rule_name, category_name; 

尽管将减少的任务的最大数量和数量设置为1,但我看到生成了2个map reduce任务。请看下面 -

 > set hive.exec.reducers.max = 1;
hive>  set mapred.reduce.tasks = 1;
hive>
    > from flat_json
    > insert overwrite table aggr_pgm_measure PARTITION(dt='${START_TIME}')
    > reduce  log_time,
    >  req_id, ac_id, client_key, rulename, categoryname, bsid, visitorid, visitorgroupid, visitortargetid, targetpopulationid, windowsessionid, eventseq, event_code, eventstarttime
    >  using '${SCRIPT_LOC}/aggregator.pl' as
    >  metric_id, metric_value, aggr_type, rule_name, category_name;
converting to local s3://dsp-emr-test/anurag/dsp-test/60mins/script/aggregator.pl
Added resource: /mnt/var/lib/hive_07_1/downloaded_resources/aggregator.pl
Total MapReduce jobs = 2
Launching Job 1 out of 2
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_201112270825_0009, Tracking URL = http://ip-10-85-66-9.ec2.internal:9100/jobdetails.jsp?jobid=job_201112270825_0009
Kill Command = /home/hadoop/.versions/0.20.205/libexec/../bin/hadoop job  -Dmapred.job.tracker=10.85.66.9:9001 -kill job_201112270825_0009
2011-12-27 10:30:03,542 Stage-1 map = 0%,  reduce = 0%

1 个答案:

答案 0 :(得分:1)

您认为相关的两件事情并非如此。您正在设置reduce 任务的数量,而不是MapReduce 作业。 Hive会将您的查询转换为几个MapReduce作业,就像需要完成的工作一样。每个MapReduce作业都包含多个地图任务,并减少任务

您要设置的是任务的最大数量。这意味着,每个MapReduce作业都将受到它可以启动的任务数量的限制。但是,您仍然需要运行两个工作。关于使用Hive的MapReduce作业的数量,您无能为力。它需要运行每个阶段才能执行您的查询。