Hive启动成功

发布时间 2023-04-11 18:13:41作者: yappleorange

1. 启动hive

[root@hadoop1 ~]#  /root/tools/hive/hive/bin/hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/tools/hive/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/tools/hadoop/tools/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

Logging initialized using configuration in jar:file:/root/tools/hive/hive/lib/hive-common-2.3.7.jar!/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.

2. 查看数据库

hive> show databases;
OK
default
Time taken: 12.49 seconds, Fetched: 1 row(s)

3. 使用数据库

hive> use default ;
OK
Time taken: 0.292 seconds

4. 在默认数据库创建一张表

hive> create table student(id int,name string);
OK
Time taken: 3.387 seconds

5. 查看表的结构

hive> desc student;
OK
id                      int                                         
name                    string                                      
Time taken: 0.767 seconds, Fetched: 2 row(s)

6.向表中插入数据

hive> insert into student values(1000,xiaoming);
FAILED: SemanticException [Error 10293]: Unable to create temp file for insert values Expression of type TOK_TABLE_OR_COL not supported in insert/values
hive> insert into student values(1000,"xiaoming");
WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
Query ID = root_20230411174606_404ab8f8-3343-42ce-96d9-115ec43da499
Total jobs = 3
Launching Job 1 out of 3
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_1681100520235_0001, Tracking URL = http://hadoop1:8088/proxy/application_1681100520235_0001/
Kill Command = /root/tools/hadoop/tools/hadoop/bin/hadoop job  -kill job_1681100520235_0001
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 0
2023-04-11 17:48:24,055 Stage-1 map = 0%,  reduce = 0%
2023-04-11 17:49:25,018 Stage-1 map = 0%,  reduce = 0%
2023-04-11 17:49:40,735 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 4.13 sec
MapReduce Total cumulative CPU time: 4 seconds 130 msec
Ended Job = job_1681100520235_0001
Stage-4 is selected by condition resolver.
Stage-3 is filtered out by condition resolver.
Stage-5 is filtered out by condition resolver.
Moving data to directory hdfs://ns/hive/warehouse/student/.hive-staging_hive_2023-04-11_17-46-06_384_5537635800260417117-1/-ext-10000
Loading data to table default.student
MapReduce Jobs Launched: 
Stage-Stage-1: Map: 1   Cumulative CPU: 4.13 sec   HDFS Read: 4033 HDFS Write: 85 SUCCESS
Total MapReduce CPU Time Spent: 4 seconds 130 msec
OK
Time taken: 265.837 seconds

7. 查询表中的数据

select * from student;
OK
1000    xiaoming
Time taken: 14.543 seconds, Fetched: 1 row(s)

8. 退出hive

hive> quit;