Hive运维 — hive-site文件

0. hive设置的优先级(从高到低):

1. Hive set命令。

2. 命令行选择 -hiveconf

3. hive-site.xml

4. hive-default.xml

5. hadoop-site.xml(或者是core-site.xml   hdfs-site.xml  mapred-site.xml)

6. hadoop-default.xml(或者是core-default.xml   hdfs-default.xml  mapred-default.xml)

7. hive的日志信息存放在 /tmp/$USER/hive.log,出错时hadoopmapred task logs也可以查看,本环境在/tmp/nslab下查看。

     命令:hive  -hiveconf  hive.root.logger=DEBUG,console  将调试信息打印到控制台。

 

使用set的使用

1. 使用set查看设置的值:

       set hive.enforce.bucketing

2. 只输入一个set,会列出所有的设置。

3. 设置新的属性,格式类似下面:

     set  hive.enforce.bucketing=true;

1. 动态分区:

hive.exec.dynamic.partition

是否打开动态分区。

默认:false

 

hive.exec.dynamic.partition.mode

打开动态分区后,动态分区的模式,有 strict nonstrict 两个值可选,strict 要求至少包含一个静态分区列,nonstrict 则无此要求。

默认:strict

 

hive.exec.max.dynamic.partitions

所允许的最大的动态分区的个数。

默认:1000

 

hive.exec.max.dynamic.partitions.pernode

单个 reduce 结点所允许的最大的动态分区的个数。

默认:100

 

hive.exec.default.partition.name

默认的动态分区的名称,当动态分区列为''或者null时,使用此名称。''

2. 打印列名, 开启行转列(有待测试)

set hive.cli.print.header=true;            // 打印列名

set hive.cli.print.row.to.vertical=true;   // 开启行转列功能, 前提必须开启打印列名功能

set hive.cli.print.row.to.vertical.num=1; // 设置每行显示的列数

3. 查看hive版本:

set hive.hwi.war.file;

 

4. 查看hive命令行字符编码:

hive.cli.encoding

Hive 默认的命令行字符编码。

默认: 'UTF8'

5. Hive  Fetch Task执行:

set hive.fetch.task.conversion=more;

对于简单的不需要聚合的类似SELECT <col> from <table> LIMIT n语句,不需要起MapReduce job,直接通过Fetch task获取数据(数据量过大, 也能 返回结果)

 

类似linuxvi,直接对文本进行操作。

也有点类似shark的列存储的操作: 放在同一个array里面,所以查询数据很快

 

hive.fetch.task.conversion

Hive 默认的mapreduce操作

默认: minimal

6. MapJoin

旧版本HIVE需要自行在查询/子查询的SELECT关键字后面添加/*+ MAPJOIN(tablelist) */提示优化器转化为MapJoin。高版本只需设置:

set hive.auto.convert.join=true;  

HIVE自行选择小表作为LEFT的左表。

7. Strict Mode

hive.mapred.mode=true,严格模式不允许执行以下查询:

分区表上没有指定了分区

没有limit限制的order by语句

笛卡尔积:JOIN时没有ON语句

 

8. 并发执行任务:

设置该参数是控制在同一个sql中的不同的job是否可以同时运行,默认是false

hive.exec.parallel=true ,默认为false

hive.exec.parallel.thread.number=8

9. 负载均衡

hive.groupby.skewindata=true:数据倾斜时负载均衡,当选项设定为true,生成的查询计划会有两个MRJob。第一个MRJob 中,

Map的输出结果集合会随机分布到Reduce中,每个Reduce做部分聚合操作,并输出结果,这样处理的结果是相同的GroupBy Key

有可能被分发到不同的Reduce中,从而达到负载均衡的目的;第二个MRJob再根据预处理的数据结果按照GroupBy Key分布到

Reduce中(这个过程可以保证相同的GroupBy Key被分布到同一个Reduce中),最后完成最终的聚合操作。

10. hive.exec.rowoffset:是否提供虚拟列

11.  set hive.error.on.empty.partition=true;  那么动态分区如果为空,则会报异常

    set hive.error.on.empty.partition = true;
    set hive.exec.dynamic.partition.mode=nonstrict; 

   参考地址: http://my.oschina.net/repine/blog/541380

12. hive.merge.mapredfiles:合并小文件

    工作需要合并reduce产生文件

    set hive.merge.smallfiles.avgsize=67108864;
    set hive.merge.mapfiles=true;
    set hive.merge.mapredfiles=true;

    参考地址: http://www.linuxidc.com/Linux/2015-06/118391.htm

1.先在hive-site.xml中设置小文件的标准. 

<property>
  <name>hive.merge.smallfiles.avgsize</name>
  <value>536870912</value>
  <description>When the average output file size of a job is less than this number, Hive will start an additional map-reduce job to merge the output files into bigger files.  This is only done for map-only jobs if hive.merge.mapfiles is true, and for map-reduce jobs if hive.merge.mapredfiles is true.</description>
</property>

2.为只有map的mapreduce的输出并合并小文件.

<property>
  <name>hive.merge.mapfiles</name>
  <value>true</value>
  <description>Merge small files at the end of a map-only job</description>
</property>

3.为含有reduce的mapreduce的输出并合并小文件.

<property>
  <name>hive.merge.mapredfiles</name>
  <value>true</value>
  <description>Merge small files at the end of a map-reduce job</description>
</property>


————————————————————————————————————

配置文件地址,可参考:http://www.68dl.com/2014/1207/18496.html


转载于:https://my.oschina.net/repine/blog/532235

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值