1.4.3.3 Hive常用需知

總目錄:http://www.itdecent.cn/p/e406a9bc93a9

Hadoop - 子目錄:http://www.itdecent.cn/p/9428e443b7fd

常用命令行交互命令

[root@master ~] hive -h
usage: hive
 -d,--define <key=value>          Variable substitution to apply to Hive
                                  commands. e.g. -d A=B or --define A=B
    --database <databasename>     Specify the database to use
 -e <quoted-query-string>         SQL from command line
 -f <filename>                    SQL from files
 -H,--help                        Print help information
    --hiveconf <property=value>   Use value for given property
    --hivevar <key=value>         Variable substitution to apply to Hive
                                  commands. e.g. --hivevar A=B
 -i <filename>                    Initialization SQL file
 -S,--silent                      Silent mode in interactive shell
 -v,--verbose                     Verbose mode (echo executed SQL to the
                                  console)

我們主要理解 -e和-f參數(shù)。

  • -e

SQL from command line
命令行中的SQL

本質(zhì)上是在命令行中執(zhí)行SQL語句。

[root@master ~]# hive -e "select * from stu;"
Logging initialized using configuration in jar:file:/usr/hdk/hive/lib/hive-common-2.3.6.jar!/hive-log4j2.properties Async: true
OK
1   zhangsan
2   lisi
3   wangwu
4   liuniu
5   zhaoqi
1   zhangsan
2   lisi
3   wangwu
4   liuniu
5   zhaoqi
Time taken: 11.535 seconds, Fetched: 10 row(s)
  • -f

SQL from files
文件中的SQL

用來執(zhí)行SQL文件。

[root@master usr] cat cs.sql 
select * from stu;
[root@master usr] hive -f cs.sql 
Logging initialized using configuration in jar:file:/usr/hdk/hive/lib/hive-common-2.3.6.jar!/hive-log4j2.properties Async: true
OK
1   zhangsan
2   lisi
3   wangwu
4   liuniu
5   zhaoqi
1   zhangsan
2   lisi
3   wangwu
4   liuniu
5   zhaoqi
Time taken: 11.204 seconds, Fetched: 10 row(s)

常用操作

  • 在hive客戶端內(nèi)查看hdfs文件目錄
    dfs -ls /

    查看hdfs

  • 在hive客戶端內(nèi)查看本地文件目錄
    ! ls /usr/hdk

    查看本地

  • 在hive客戶端內(nèi)查看歷史命令
    1.進入當前用戶的家目錄
    2.查看.hivehistory文件


    查看歷史命令

常用配置

  • 在客戶端上顯示當前庫與字段名
    修改配置如下,第一個配置是列名,第二個是數(shù)據(jù)庫名。
  <property>
    <name>hive.cli.print.header</name>
    <value>true</value>
    <description>Whether to print the names of the columns in query output.</description>
  </property>
  <property>
    <name>hive.cli.print.current.db</name>
    <value>true</value>
    <description>Whether to include the current database in the Hive prompt.</description>
  </property>
效果
  • 修改日志存放目錄
[root@master conf] cp hive-log4j2.properties.template hive-log4j2.properties
[root@master conf] vi hive-log4j2.properties
[root@master conf] cat hive-log4j2.properties
...
# list of properties
property.hive.log.level = INFO
property.hive.root.logger = DRFA
property.hive.log.dir = /usr/hdk/hive/logs   #修改這個配置
property.hive.log.file = hive.log
property.hive.perflogger.log.level = INFO
...
日志
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Zookeeper用于集群主備切換。 YARN讓集群具備更好的擴展性。 Spark沒有存儲能力。 Spark的Ma...
    Yobhel閱讀 7,605評論 0 34
  • 1. Hive基本介紹和基礎(chǔ): Facebook公司最早完成并開源了hive框架,可以將sql語句直接翻譯成Map...
    奉先閱讀 3,450評論 0 43
  • 2.1 Hive安裝地址 1)Hive官網(wǎng)地址: http://hive.apache.org/ 2)文檔查看地址...
    碼農(nóng)GG閱讀 473評論 0 0
  • 2.1 Hive安裝地址 1)Hive官網(wǎng)地址: http://hive.apache.org/ 2)文檔查看地址...
    臨時_01e2閱讀 366評論 0 0
  • 本文是對Hive組件的學習的一個初步總結(jié),包括如下章節(jié)的內(nèi)容: Hive是什么 Hive安裝 快速上手 Hive元...
    我是老薛閱讀 2,013評論 1 23

友情鏈接更多精彩內(nèi)容