hive的常用命令及配置
一、Hive常用命令
$ hive -help usage: hive -d,--define <key=value> Variable substitution 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 --hiveconf <property=value> Use value for given property --hivevar <key=value> Variable substitution to apply to Hive commands. e.g. --hivevar A=B -i <filename> Initialization SQL file -S,--silent Silent mode in interactive shell -v,--verbose Verbose mode (echo executed SQL to the console)
- “-e”不进入hive的交互窗口执行sql语句
$ bin/hive -e "select id from student;"
- “-f”执行脚本中sql语句
#创建一个sql脚本 $ touch hivef.sql #编写sql语句 select *from student; #执行文件中的sql语句 $ bin/hive -f hivef.sql # 执行文件中的sql语句并将结果写入文件中 $ bin/hive -f hivef.sql > /opt/module/datas/hive_result.txt
- 在hive cli命令窗口中查看hdfs文件系统:
hive(default)>dfs -ls /;
- 查看在hive中输入的所有历史命令 (进入当前用户的根目录/home/user)
#查看隐藏文件命令 ls -a cat .hivehistory
二、Hive运行日志配置
- Hive的log默认存放在/tmp/hw/hive.log目录下(当前用户名下)
- 修改hive的log存放日志到/opt/module/hive/logs
#修改/opt/module/hive/conf/hive-log4j2.properties.template文件名称为 hive-log4j2.properties mv hive-log4j2.properties.template hive-log4j2.properties # 在hive-log4j2.properties文件中修改log存放位置 hive.log.dir=/opt/module/hive/logs
三、Hive打印当前库 和 表头的配置
<property> <name>hive.cli.print.header</name> <value>true</value> </property> <property> <name>hive.cli.print.current.db</name> <value>true</value> </property>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?