hive的非互動模式,hive模式
在linux的終端執行:$HIVE_HOME/bin/hive 會進入互動模式;
$HIVE_HOME/bin/hive -e或者-f 是非互動模式
1、非互動模式執行HQL語句
$HIVE_HOME/bin/hive -e 'select * from movie limit 10'
會顯示mapreduce的進度,但不會進入hive的互動模式,最終現實查詢結果
2、非互動模式執行HQL語句(-S靜音)
$HIVE_HOME/bin/hive -S -e 'select * from movie limit 10'
加入-S選項,不會顯示mapreduce進度
[hadoop@gaoyuan hive-0.14]$ bin/hive -S -e 'select * from movie limit 10'SLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding in [jar:file:/home/hadoop/hadoop-2.4.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: Found binding in [jar:file:/home/hadoop/hive-0.14/lib/hive-jdbc-0.14.0-SNAPSHOT-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]Error rolling back: Can't call rollback when autocommit=true1113382172063197110411095751161610611978771214588122118913751710140623
3、把hive查詢匯出到一個檔案中
$HIVE_HOME/bin/hive -S -e 'select * from movie limit 10' > /gaoyuan/ouput.txt
這個會把hive查詢語句的執行結果匯入output.txt檔案中
4、不進入hive互動模式,執行hive指令碼
$HIVE_HOME/bin/hive -f hiveScript.sql
也可以把輸出結果存入一個檔案中
$HIVE_HOME/bin/hive -f hiveScript.sql >> /home/username/output.txt
互動式shell與非互動式shell的不同
互動式模式就是shell等待你的輸入,並且執行你提交的命令。這種模式被稱作互動式是因為shell與使用者進行互動。這種模式也是大多數使用者非常熟悉的:登入、執行一些命令、簽退。當你簽退後,shell也終止了。
shell也可以運行在另外一種模式:非互動式模式。在這種模式下,shell不與你進行互動,而是讀取存放在檔案中的命令,並且執行它們。當它讀到檔案的結尾,shell也就終止了。
Hive是什?
此外,hive也支援熟悉map-reduce的開發人員使用map-reduce程式對資料做更加複雜的分析。hive可以很好的結合thrift和控制分隔字元,也支援使用者自訂分隔字元。hive基於hadoop,hadoop是批處理系統,不能儲存低延遲,因此,hive的查詢也不能保證低延遲。hive的工作模式是:提交一個任務,等到任務結束時被通知,而不是即時查詢。相對應的是,類似於Oracle這樣的系統當運行於小資料集的時候,響應非常快,可當處理的資料集非常大的時候,可能需要數小時。需要說明的是,hive即使在很小的資料集上運行,也可能需要數分鐘才能完成。低延遲不是hive追求的首要目標。