hive的非交互模式

系统 1701 0

在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=true
1	1	133	8
2	1	720	6
3	1	971	10
4	1	1095	7
5	1	1616	10
6	1	1978	7
7	1	2145	8
8	1	2211	8
9	1	3751	7
10	1	4062	3

    


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 

 









hive的非交互模式


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论