Hive常见属性和交互操作

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yuanyi0501/article/details/83151228

常见属性

  • Hive数据仓库位置配置
    default
    /user/hive/warehouse
    注意事项
    * 在仓库目录下,没有对默认的数据库default创建文件夹
    * 如果某张表属于default数据库,直接在数据仓库目录下创建一个文件夹

    hive.metastore.warehouse.dir
    /user/hive/warehouse

    $ $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生效


常用交互操作

[root@hadoop-senior hive-0.13.1]$ 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,–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)

  • bin/hive -e < quoted-query-string> 不进入hive的交互式页面查询结果,常用于测试
    eg:
    bin/hive -e “select * from hive.student ;”

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

  • bin/hive -i < filename>
    与用户udf相互使用

  • 在hive cli命令窗口中如何查看hdfs文件系统
    hive (default)> dfs -ls / ;

  • 在hive cli命令窗口中如何查看本地(linux系统)文件系统
    hive (default)> !ls /opt/datas ;

  • exit和quit退出区别?
    exit:先隐性提交数据,再退出;quit:不提交数据,退出;

  • 在当前用户的home目录下有hive的操作历史
    $Home/.hivehistory

猜你喜欢

转载自blog.csdn.net/yuanyi0501/article/details/83151228
今日推荐