1.4.3.3 Hive常用需知

总目录:https://blog.csdn.net/qq_41106844/article/details/105553392

Hadoop - 子目录:https://blog.csdn.net/qq_41106844/article/details/105553369

 

常用命令行交互命令

[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参数。

  • -e

SQL from command line
命令行中的SQL

本质上是在命令行中执行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

用来执行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客户端内查看hdfs文件目录
    dfs -ls /

     
    20155953-2e25856b1c1e89e1.png
    查看hdfs

     

  • 在hive客户端内查看本地文件目录
    ! ls /usr/hdk

     
    20155953-f19246a5825caf6e.png
    查看本地

     

  • 在hive客户端内查看历史命令
    1.进入当前用户的家目录
    2.查看.hivehistory文件

     
     
    20155953-f3483d81e356c2f0.png
    查看历史命令

常用配置

  • 在客户端上显示当前库与字段名
    修改配置如下,第一个配置是列名,第二个是数据库名。
  <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>
 
20155953-24bfabfe42515084.png
效果
  • 修改日志存放目录
[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
...
 
20155953-f84c595cb8141802.png
日志
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寒 暄

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值