Hive運維 — hive-site文件

0. hive設置的優先級(從高到低):

1. Hive set命令。 html

2. 命令行選擇 -hiveconf node

3. hive-site.xml linux

4. hive-default.xml sql

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下查看。 less

     命令:hive  -hiveconf  hive.root.logger=DEBUG,console  將調試信息打印到控制檯。 oop

 

使用set的使用 測試

1. 使用set查看設置的值: fetch

       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

相關文章
相關標籤/搜索