hadoop学习笔记--13.hive 属性配置、交互式命令行和文件系统交互

一、hive 配置文件常见属性


1.在cli命令行上显示当前的数据库名以及查询的行头信息
  在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>


2.日志文件配置
  默认log日志文件在/tmp/”系统用户名”/hive.log
  1.将hive目录下conf中的hive-log4j.properties.template重命名为hive-log4j.properties
  2.在hive-log4j.properties文件中设置以下几项
  hive.log.dir为日志文件的存放目录
  hive.log.file为日志的文件名
  hive.root.logger为日志的级别(默认为INFO,DRFA),如果想要在控制台输出,则可以添加console
  
 
3.控制台配置属性信息
  1.hive启动时配置属性信息
    

bin/hive --hiveconf <property=value>

  2.在hive启动后配置属性信息
    set property=value;
    set property=value;
  3.查看所有配置信息(set命令)
  
    
4.数据仓库位置配置
  1.默认位置为:/user/hive/warehouse
  2.在仓库目录下,没有对默认的数据库default创建文件夹
    * 如果某张表属于default数据库,直接在数据仓库目录下创建一个文件夹
    * 如果新建一个数据库,则会在仓库目录下新建一个以该数据库为名字的文件夹
  3.修改仓库位置  

<property>
        <name>hive.metastore.warehouse.dir</name>
        <value>/user/hive/warehouse</value>
    </property>
二、hive交互式命令行


1.查看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
 - help                        Print 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)

  
2.bin/hive -e "quoted-query-string"
  1.不进入hive交互命令界面
  2.直接执行"SQL语句",返回结果
  3.测试中常有

3.bin/hive -f <filename>
  1.在.sql文件中执行hql语句

2.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  (结果重定向,不在控制台输出)
2.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  (结果重定向,不在控制台输出)

  
4. bin/hive -i
  与用户udf相互使用
  

三、hive与文件系统交互


1.在hive cli命令窗口中如何操作hdfs文件系统
  hive (default)> dfs -ls / ;
2.在hive cli命令窗口中如何操作本地文件系统
  hive (default)> !ls /opt/datas ;

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值