小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Hive學(xué)習(xí)之路 (十八)Hive的Shell操作

 HK123COM 2019-02-14

目錄

 

正文

一、Hive的命令行

1、Hive支持的一些命令

Command Description

quit Use quit or exit to leave the interactive shell.

set key=value Use this to set value of particular configuration variable. One thing to note here is that if you misspell the variable name, cli will not show an error.

set This will print a list of configuration variables that are overridden by user or hive.

set -v This will print all hadoop and hive configuration variables.

add FILE [file] [file]* Adds a file to the list of resources

add jar jarname

list FILE list all the files added to the distributed cache

list FILE [file]* Check if given resources are already added to distributed cache

! [cmd] Executes a shell command from the hive shell

dfs [dfs cmd] Executes a dfs command from the hive shell

[query] Executes a hive query and prints results to standard out

source FILE Used to execute a script file inside the CLI.

2、語法結(jié)構(gòu)

hive [-hiveconf x=y]* [<-i filename>]* [<-f filename>|<-e query-string>] [-S]

說明:

1、-i 從文件初始化 HQL

2、-e 從命令行執(zhí)行指定的 HQL

3、-f 執(zhí)行 HQL 腳本

4、-v 輸出執(zhí)行的 HQL 語句到控制臺(tái)

5、-p connect to Hive Server on port number

6、-hiveconf x=y(Use this to set hive/hadoop configuration variables)

7、-S:表示以不打印日志的形式執(zhí)行命名操作

3、示例

(1)運(yùn)行一個(gè)查詢

[hadoop@hadoop3 ~]$ hive -e "select * from cookie.cookie1;"

(2)運(yùn)行一個(gè)文件

 編寫hive.sql文件

運(yùn)行編寫的文件

(3)運(yùn)行參數(shù)文件

從配置文件啟動(dòng) hive,并加載配置文件當(dāng)中的配置參數(shù)

二、Hive的參數(shù)配置方式

1、Hive的參數(shù)配置大全

https://cwiki./confluence/display/Hive/Configuration+Properties

2、Hive的參數(shù)設(shè)置方式

開發(fā) Hive 應(yīng)用時(shí),不可避免地需要設(shè)定 Hive 的參數(shù)。設(shè)定 Hive 的參數(shù)可以調(diào)優(yōu) HQL 代碼 的執(zhí)行效率,或幫助定位問題。然而實(shí)踐中經(jīng)常遇到的一個(gè)問題是,為什么設(shè)定的參數(shù)沒有 起作用?這通常是錯(cuò)誤的設(shè)定方式導(dǎo)致的

對(duì)于一般參數(shù),有以下三種設(shè)定方式:

1、配置文件 (全局有效)

2、命令行參數(shù)(對(duì) hive 啟動(dòng)實(shí)例有效)

3、參數(shù)聲明 (對(duì) hive 的連接 session 有效)

(1)配置文件

Hive 的配置文件包括:

  A. 用戶自定義配置文件:$HIVE_CONF_DIR/hive-site.xml

  B. 默認(rèn)配置文件:$HIVE_CONF_DIR/hive-default.xml

用戶自定義配置會(huì)覆蓋默認(rèn)配置。

另外,Hive 也會(huì)讀入 Hadoop 的配置,因?yàn)?Hive 是作為 Hadoop 的客戶端啟動(dòng)的,Hive 的配 置會(huì)覆蓋 Hadoop 的配置。

配置文件的設(shè)定對(duì)本機(jī)啟動(dòng)的所有 Hive 進(jìn)程都有效。

(2)命令行參數(shù)

啟動(dòng) Hive(客戶端或 Server 方式)時(shí),可以在命令行添加-hiveconf param=value 來設(shè)定參數(shù),例如:

這一設(shè)定對(duì)本次啟動(dòng)的 session(對(duì)于 server 方式啟動(dòng),則是所有請(qǐng)求的 session)有效。

(3)參數(shù)聲明 

可以在 HQL 中使用 SET 關(guān)鍵字設(shè)定參數(shù),例如:

這一設(shè)定的作用域也是 session 級(jí)的。

set hive.exec.reducers.bytes.per.reducer= 每個(gè) reduce task 的平均負(fù)載數(shù)據(jù)量 Hive 會(huì)估算總數(shù)據(jù)量,然后用該值除以上述參數(shù)值,就能得出需要運(yùn)行的 reduceTask 數(shù)

set hive.exec.reducers.max= 設(shè)置 reduce task 數(shù)量的上限

set mapreduce.job.reduces= 指定固定的 reduce task 數(shù)量

但是,這個(gè)參數(shù)在必要時(shí)<業(yè)務(wù)邏輯決定只能用一個(gè) reduce task> hive 會(huì)忽略,比如在設(shè)置 了 set mapreduce.job.reduces = 3,但是 HQL 語句當(dāng)中使用了 order by 的話,那么就會(huì)忽略該參數(shù)的設(shè)置。

上述三種設(shè)定方式的優(yōu)先級(jí)依次遞增。即參數(shù)聲明覆蓋命令行參數(shù),命令行參數(shù)覆蓋配置 文件設(shè)定。注意某些系統(tǒng)級(jí)的參數(shù),例如 log4j 相關(guān)的設(shè)定,必須用前兩種方式設(shè)定,因?yàn)?那些參數(shù)的讀取在 session 建立以前已經(jīng)完成了。

 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多