總目錄:http://www.itdecent.cn/p/e406a9bc93a9
Hadoop - 子目錄:http://www.itdecent.cn/p/9428e443b7fd
常用命令行交互命令
[root@master ~] hive -h
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和-f參數(shù)。
- -e
SQL from command line
命令行中的SQL
本質(zhì)上是在命令行中執(zhí)行SQL語句。
[root@master ~]# hive -e "select * from stu;"
Logging initialized using configuration in jar:file:/usr/hdk/hive/lib/hive-common-2.3.6.jar!/hive-log4j2.properties Async: true
OK
1 zhangsan
2 lisi
3 wangwu
4 liuniu
5 zhaoqi
1 zhangsan
2 lisi
3 wangwu
4 liuniu
5 zhaoqi
Time taken: 11.535 seconds, Fetched: 10 row(s)
- -f
SQL from files
文件中的SQL
用來執(zhí)行SQL文件。
[root@master usr] cat cs.sql
select * from stu;
[root@master usr] hive -f cs.sql
Logging initialized using configuration in jar:file:/usr/hdk/hive/lib/hive-common-2.3.6.jar!/hive-log4j2.properties Async: true
OK
1 zhangsan
2 lisi
3 wangwu
4 liuniu
5 zhaoqi
1 zhangsan
2 lisi
3 wangwu
4 liuniu
5 zhaoqi
Time taken: 11.204 seconds, Fetched: 10 row(s)
常用操作
-
在hive客戶端內(nèi)查看hdfs文件目錄
dfs -ls /
查看hdfs -
在hive客戶端內(nèi)查看本地文件目錄
! ls /usr/hdk
查看本地 -
在hive客戶端內(nèi)查看歷史命令
1.進入當前用戶的家目錄
2.查看.hivehistory文件
查看歷史命令
常用配置
- 在客戶端上顯示當前庫與字段名
修改配置如下,第一個配置是列名,第二個是數(shù)據(jù)庫名。
<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>

效果
- 修改日志存放目錄
[root@master conf] cp hive-log4j2.properties.template hive-log4j2.properties
[root@master conf] vi hive-log4j2.properties
[root@master conf] cat hive-log4j2.properties
...
# list of properties
property.hive.log.level = INFO
property.hive.root.logger = DRFA
property.hive.log.dir = /usr/hdk/hive/logs #修改這個配置
property.hive.log.file = hive.log
property.hive.perflogger.log.level = INFO
...

日志


