Hive的管理

一 Hive的启动方式
1、CLI(命令行)方式
2、Web界面方式
3、远程服务启动方式

二 CLI(命令行方式)
1、直接输入hive
2、hive --service cli
3、静默模式
hive -S
[root@localhost ~]# hive

Logging initialized using configuration in jar:file:/root/apache-hive-0.13.0-bin/lib/hive-common-0.13.0.jar!/hive-log4j.properties
hive> quit;
[root@localhost ~]# hive --service cli

Logging initialized using configuration in jar:file:/root/apache-hive-0.13.0-bin/lib/hive-common-0.13.0.jar!/hive-log4j.properties
hive> exit;

三 常用的CLI命令
1、清屏:
Ctrl+L或者!clear
2、查看数据仓库中的表
show tables;
3、查看数据仓库中内置的函数
show functions;
4、查看表结构
desc 表名
5、查看HDFS上的文件
dfs -ls 目录
6、执行操作系统命令
!命令
7、执行HQL语句
select *** from ***
8、执行SQL的脚本
source SQL文件
9、操作系统下执行命令
hive -e 'show tables';

四 实战
hive> show tables;
OK
Time taken: 1.656 seconds
hive> show functions;
OK
    > create table test1(tid int,tname string);
OK
Time taken: 1.944 seconds
hive> 
    > desc test1;
OK
tid                 	int                 	                    
tname               	string              	                    
Time taken: 0.664 seconds, Fetched: 2 row(s)
hive> dfs -ls /user;
Found 2 items
drwxr-xr-x   - root supergroup          0 2017-08-23 20:55 /user/hive
drwxr-xr-x   - root supergroup          0 2017-08-20 14:51 /user/root
hive> dfs -lsr /user;
drwxr-xr-x   - root supergroup          0 2017-08-23 20:55 /user/hive
drwxr-xr-x   - root supergroup          0 2017-08-23 20:55 /user/hive/warehouse
drwxr-xr-x   - root supergroup          0 2017-08-23 20:55 /user/hive/warehouse/test1
    > !pwd ;
hive> /root

    > !ls ;
hive> 123
aa.av
a.av
abc
abcd

hive> select * from test1;
OK
Time taken: 3.628 seconds
hive> select tname from test1;
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_201708231948_0001, Tracking URL = http://localhost:50030/jobdetails.jsp?jobid=job_201708231948_0001
Kill Command = /opt/hadoop-1.2.1/libexec/../bin/hadoop job  -kill job_201708231948_0001
Hadoop job information for Stage-1: number of mappers: 0; number of reducers: 0
2017-08-23 21:04:40,183 Stage-1 map = 0%,  reduce = 0%
2017-08-23 21:04:58,012 Stage-1 map = 100%,  reduce = 100%
Ended Job = job_201708231948_0001
MapReduce Jobs Launched: 
Job 0:  HDFS Read: 0 HDFS Write: 0 SUCCESS
Total MapReduce CPU Time Spent: 0 msec
OK
Time taken: 80.903 seconds

hive> source /root/my.sql;
OK
Time taken: 0.543 seconds
hive> source /root/my1.sql;
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_201708231948_0002, Tracking URL = http://localhost:50030/jobdetails.jsp?jobid=job_201708231948_0002
Kill Command = /opt/hadoop-1.2.1/libexec/../bin/hadoop job  -kill job_201708231948_0002
Hadoop job information for Stage-1: number of mappers: 0; number of reducers: 0
2017-08-23 21:10:53,970 Stage-1 map = 0%,  reduce = 0%
2017-08-23 21:11:14,799 Stage-1 map = 100%,  reduce = 100%
Ended Job = job_201708231948_0002
MapReduce Jobs Launched: 
Job 0:  HDFS Read: 0 HDFS Write: 0 SUCCESS
Total MapReduce CPU Time Spent: 0 msec
OK
Time taken: 58.833 seconds
[root@localhost ~]# hive -S
hive> source /root/my1.sql;
hive> 

[root@localhost ~]# hive -e 'show tables';

Logging initialized using configuration in jar:file:/root/apache-hive-0.13.0-bin/lib/hive-common-0.13.0.jar!/hive-log4j.properties
OK
test1
Time taken: 3.197 seconds, Fetched: 1 row(s)

[root@localhost conf]# hive -e 'select * from test1';

Logging initialized using configuration in jar:file:/root/apache-hive-0.13.0-bin/lib/hive-common-0.13.0.jar!/hive-log4j.properties
OK
Time taken: 6.289 seconds
[root@localhost conf]# hive -S -e 'select * from test1';
[root@localhost conf]# 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值