hive 常用的几种shell交互方式

查看hive命令帮助:bin/hive -help

[hd@hadoop-senior hive]$ bin/hive -help
usage: hive
-d,--define <key=value> Variable subsitution 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,--helpPrint help information
-h <hostname>connecting to Hive Server on remote host
--hiveconf <property=value> Use value for given property
--hivevar <key=value> Variable subsitution to apply to hive
commands. e.g. --hivevar A=B
-i <filename>Initialization SQL file
-p <port>connecting to Hive Server on port number
-S,--silent Silent mode in interactive shell
-v,--verbose Verbose mode (echo executed SQL to the
console)

不进入hive shell交互界面,直接执行:

* bin/hive -e <quoted-query-string>
eg:
bin/hive -e "select * from db_hive.student ;"

把sql脚本写入文件,通过 bin/hive -f 加载并执行脚本文件;通过bin/hive -f /opt/datas/hivef.sql > /opt/datas/hivef-res.txt 可以把结果输出到指定文件

* bin/hive -f <filename>
eg:
$ touch hivef.sql
select * from db_hive.student ;
$ bin/hive -f /opt/datas/hivef.sql
$ bin/hive -f /opt/datas/hivef.sql > /opt/datas/hivef-res.txt

与用户udf相互使用

* bin/hive -i <filename>

hive常见属性配置及命令

Hive数据仓库位置配置

default
/user/hive/warehouse
# 注意事项
* 在仓库目录下,没有对默认的数据库default创建文件夹
* 如果某张表属于default数据库,直接在数据仓库目录下创建一个文件夹 # 在hive-site.xml中配置
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property> # 并在hadoop中创建文件夹,并赋权限
$ $HADOOP_HOME/bin/hadoop fs -mkdir /tmp
$ $HADOOP_HOME/bin/hadoop fs -mkdir /user/hive/warehouse
$ $HADOOP_HOME/bin/hadoop fs -chmod g+w /tmp
$ $HADOOP_HOME/bin/hadoop fs -chmod g+w /user/hive/warehouse

Hive运行日志信息位置

$HIVE_HOME/conf/hive-log4j.properties
hive.log.dir=/opt/modules/hive-0.13.1/logs
hive.log.file=hive.log

指定hive运行时显示的log日志的级别

$HIVE_HOME/conf/hive-log4j.properties
hive.root.logger=INFO,DRFA

在cli命令行上显示当前数据库,以及查询表的行头信息

$HIVE_HOME/conf/hive-site.xml
<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>

在启动hive时设置配置属性信息

$ bin/hive --hiveconf <property=value>

查看当前所有的配置信息

hive > set ;

    hive (db_hive)> set system:user.name ;
system:user.name=beifeng
hive (db_hive)> set system:user.name=beifeng ; 此种方式,设置属性的值,仅仅在当前会话session生效

在hive cli命令窗口中如何查看hdfs文件系统

hive (default)> dfs -ls / ;

在hive cli命令窗口中如何查看本地文件系统

hive (default)> !ls /opt/datas ;

最新文章

  1. 【Machine Learning】KNN算法虹膜图片识别
  2. git初体验(四)git标签
  3. HTML5 本地存储 localStorage、sessionStorage 的遍历、存储大小限制处理
  4. LightOj 1289 - LCM from 1 to n(LCM + 素数)
  5. PHP Simple HTML DOM解析器
  6. JSON解析总结2
  7. 认识HTML
  8. [Swust 549]--变位词(vector水过)
  9. Java基础09 类数据与类方法
  10. 关于WdatePicker.js的结束时间大于开始时间
  11. C#中switch的使用
  12. IOS开发之XCode学习009:UIViewController使用
  13. Android的图片,字符串,demin,color,以及Array,boolean,Integer资源的使用-android学习之旅(五十四)
  14. 【放松一下】北美小游戏排行榜TOP10——“点击英雄”
  15. Ubuntu 16.04 LTS 安装Mongodb 3.4
  16. 2019.01.14 bzoj5343: [Ctsc2018]混合果汁(整体二分+权值线段树)
  17. Python3.5 学习二十
  18. vue之给a标签赋值
  19. WinForm自定义控件–TextBox扩展
  20. ThinkPHP中I(&#39;post.&#39;)与create()方法的对比

热门文章

  1. 41个linux命令大全(鸟哥的私房菜)
  2. mysql关于访问权限以及root密码修改
  3. ASP.NET MVC学习---(二)EF文件结构
  4. iOS---sha1加密的一个坑
  5. Node.js 极简入门Helloworld版服务器例子
  6. WebGL 启动载入触发更新流程分析
  7. python的偏函数(partial)
  8. 【HTML5】元素&lt;script&gt;与&lt;noscript&gt;的使用
  9. Android Zxing 加入闪光灯功能
  10. Android中关于cursor类介绍