標籤:hive hadoop shell
工作中經常使用hive,熟練使用hvie的配置參數可以更加高效的使用Hive
Hive option:
hive -f script.hql : 從檔案script.hql中的讀取hql執行
hive -e ‘select * from xxx‘: 啟動hive時指定執行的hql,此種方式hql會先經過shell解釋,然後再用hive執行,因此需要注意hql中被shell轉義的字元
hive -S :安靜模式執行hql,這樣標準輸出中只有hql執行的結果,沒有進度等資訊,便於對結果進行過濾
hive -i .hiverc :指定啟動的hiverc檔案
hive --help:顯示協助資訊
hive --serverice:啟動hive service,可用的service: beeline cli help hiveserver2 hiveserver hwi jar lineage metastool rcfilecat
hive --service service_name --help: 顯示hive service的協助資訊
hive --define/-d/--hivevar:命令列傳遞hive變數
Hive set var Option:
可用在hive命令列中查看hive配置參數和所有的變數,hive中的變數有不同的命名空間和存取權限:
hivevar:可讀/可寫:使用者自訂變數
hiveconf: 可讀/可寫:hive想配置屬性
system: 可讀/可寫:Java定義配置屬性
env: 只可讀: Shell環境變數
set; 顯示hiveconf, hivevar,env,system中變數
set hivevar/env/system:var_name 顯示具體某一個空間中的某個變數
set -v : 顯示所有變數,包括hadoop相關配置
常用hive配置:
set hive.cli.print.header=true; 輸出資料行名
set hive.cli.print.current.db=true; 輸出current db
set hive.mapred.mode=nostrict; 使用nostrict模式,允許order by 而不limit
set hive.exec.mode.local.auto=true; 盡量以高效地本地模式執行hql
hive ql 注釋: --command
hive執行hdfs cmd: dfs command, 類似hadoop fs command
hive執行shell:!shell_cmd
hive 曆史命令:.hivehistory
hive預設配置: hivedefault.xml.template
hive log配置:hive-log4j.properties, 更改hive.root.logger=DEBUG, console可將調試資訊輸出到console