为什么使用本地模式?
大多数的Hadoop, Job是需要Hadoop提供的完整的可扩展性来处理大数据集的。有的时候 Hive的输入数据量是非常小的。在这种情况下,为查询触发执行任务的时间消耗可能会比实 际job的执行时间要多得多。对于大多数这种情况,Hive 可以通过本地模式在单台机器上(或 某些时候在单个进程中)处理所有的任务。对于小数据集,执行时间可以明显被缩短。
所以用户在执行过程中临时启用本地模式:(很明显执行效率加快)
hive.exec.mode.local.auto=true (默认是false) hive.exec.mode.local.auto.inputbytes.max=134217728(默认是128M) hive.exec.mode.local.auto.input.files.max=4(默认是4)
使用本地模式的条件(或者说一个job能使用本地模式的条件):
- job的输入数据大小必须小于参数:hive.exec.mode.local.auto.inputbytes.max
- job的map数必须小于参数:hive.exec.mode.local.auto.tasks.max
- job的reduce数必须为0或者1
使用本地模式的好处:
- 不使用本地模式:执行 insert into hive2 hbase select * from ip7_temp where id > 3445;
- 使用本地模式:执行 insert into hive2 hbase select * from ip7_temp where id > 3445;
很明显,使用本地模式的执行效率更高!!!