【hive基础】hive常见操作速查

一. hive变量操作

1. 查看当前hive配置信息

# 查看当前所有配置信息
hive > set ;

# 查看某一项配置信息
hive >set hive.metastore.uris;

不进入hive终端模糊搜索某项配置

# 模糊搜索set命令的输出结果中某个于warehouse相关的属性
$ hive -S -e "set" | grep warehouse
hive.metastore.warehouse.dir=/user/hive/warehouse
hive.warehouse.subdir.inherit.perms=false

 

2. 设置变量

hive> set com.gao.username;
com.gao.username is undefined
hive> set com.gao.username=liang;
hive> set com.gao.username;
com.gao.username=liang

设置hive变量

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

注意:此种方式设置属性的值,仅仅在当前会话session生效。

 

3. 修改变量

# hiveconf: Hive相关的配置属性
# 不进入Hive进行配置属性修改
hive --hiveconf hive.cli.print.current.db=true
# 进入hive进行配置修改
hive>set hiveconf:hive.cli.print.current_db=true;

注意有些hiveconf无法修改

# 查看
hive> set hiveconf:hive.security.authorization.enabled;
hiveconf:hive.security.authorization.enabled=true

# 设置失败
hive> set hiveconf:hive.security.authorization.enabled=false;
Query returned non-zero code: 1, cause: Cannot modify hive.security.authorization.enabled at runtime. It is in the list of parameters that can't be modified at runtime or is prefixed by a restricted variable

 

4. 进入hive终端重新加载配置

$ hive --config /hive-0.9.0/conf (重新载入新的配置文件)

 

5. beeline

beeline -u jdbc:hive2://hostname1:10000 

 

二. 执行hive sql

# 执行命令方式1:使用下面的 “一次使用”命令(-e是指一次执行,-S是指静默模式,在输出结果中不显示Ok和Time taken字段)
hive -e -S "select * from mytable limit 3";

# 执行命令方式2:调用Hive执行hql文件
hive -f /path/query.hql

# 执行命令方式3:在Hive shell内执行hql文件
$ hive
hive>source /path/query.hql

 

三. 启动hive

启动hiveserver和metastore

nohup hive --service hiveserver2 >> /tmp/hiveserver2.log 2>&1 &
nohup hive --service metastore >> /tmp/hivemeta.log 2>&1 &

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

roman_日积跬步-终至千里

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

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

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

打赏作者

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

抵扣说明:

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

余额充值