Hive运维中hive-site文件的示例分析

发布时间:2021-12-10 10:37:54 作者:小新
来源:亿速云 阅读:111

小编给大家分享一下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,出错时hadoop的mapred 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获取数据(数据量过大, 也能 无 返回结果)

类似linux的vi,直接对文本进行操作。

也有点类似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>

以上是“Hive运维中hive-site文件的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. MySQL高可用运维的示例分析
  2. mongodb中运维的示例分析

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

hive

上一篇:Tensorflow中的张量数据结构是什么

下一篇:hive中出现FAILED: Error in metadata错误怎么办

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》