hive系列 (二):hive基础知识(持续更新中~~)

本文详细介绍了Hive的基础知识,包括启动beeline、数据库操作、内部表与外部表的操作,重点讲解了Hive分区表的概念、语法、静态与动态分区的使用,以及分桶表的原理和作用,旨在帮助读者深入理解Hive的数据管理和优化技巧。
摘要由CSDN通过智能技术生成

Hive系列文章

Hadoop完全分布式搭建(腾讯云服务器+阿里云服务器)

hive系列 (一):Hive搭建

hive系列 (二):Hive基础知识

Hive系列 (三):开窗函数详解

Hive系列 (四):自定义函数UDF UDTF UDAF

Hive系列 (五):Hive数据类型

Hive系列 (六):Hive数据类型转换

Hive系列 (七):Hive常用函数

Hive系列 (八):Hive中的explode 与 lateral view

Hive系列 (九):Hive数据存储

Hive系列 (十):Hive调优

一、启动beeline

  1. 启动metastore

    [hadoop@master ~]$ hive --service metastore&
    
  2. 启动hiveserver2

    [hadoop@master ~]$ hive --service hiveserver2&
    
  3. 启动beeline

    [hadoop@master hive]$ cd bin
    [hadoop@master bin]$ ll
    total 48
    -rwxr-xr-x 1 hadoop hadoop   881 Aug 23  2019 beeline
    -rwxr-xr-x 1 hadoop hadoop   252 Jul 13 13:10 beeline.exp
    drwxrwxr-x 3 hadoop hadoop  4096 Jul 13 10:47 ext
    -rwxr-xr-x 1 hadoop hadoop 10158 Aug 23  2019 hive
    -rwxr-xr-x 1 hadoop hadoop  1900 Aug 23  2019 hive-config.sh
    -rwxr-xr-x 1 hadoop hadoop   885 Aug 23  2019 hiveserver2
    -rwxr-xr-x 1 hadoop hadoop   880 Aug 23  2019 hplsql
    -rwxr-xr-x 1 hadoop hadoop  3064 Aug 23  2019 init-hive-dfs.sh
    -rwxr-xr-x 1 hadoop hadoop   832 Aug 23  2019 metatool
    -rwxr-xr-x 1 hadoop hadoop   884 Aug 23  2019 schematool
    [hadoop@master bin]$ expect beeline.exp
    spawn beeline
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/opt/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.30.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]
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/opt/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.30.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]
    Beeline version 3.1.2 by Apache Hive
    beeline> !connect jdbc:hive2://master:10000
    Connecting to jdbc:hive2://master:10000
    Enter username for jdbc:hive2://master:10000: hive
    Enter password for jdbc:hive2://master:10000: ****
    Connected to: Apache Hive (version 3.1.2)
    Driver: Hive JDBC (version 3.1.2)
    Transaction isolation: TRANSACTION_REPEATABLE_READ
    0: jdbc:hive2://master:10000> 
    
    

二、数据库操作

查看数据库

0: jdbc:hive2://master:10000> show databases;
INFO  : Compiling command(queryId=hadoop_20210720100303_fc55bfb3-42b5-4b7d-ae49-b6c448642077): show databases
INFO  : OK
INFO  : Concurrency mode is disabled, not creating a lock manager
+----------------+
| database_name  |
+----------------+
| default        |       |
+----------------+
3 rows selected (1.938 seconds)
0: jdbc:hive2://master:10000> 

创建数据库

0: jdbc:hive2://master:10000> create database myhive;
INFO  : Compiling command(queryId=hadoop_20210719164318_a71ee0eb-6631-4948-a86f-bd2fbc131c40): create database myhive
INFO  : Concurrency mode is disabled, not creating a lock manager
INFO  : Semantic Analysis Completed (retrial = false)
INFO  : Returning Hive schema: Schema(fieldSchemas:null, properties:null)
INFO  : Completed compiling command(queryId=hadoop_20210719164318_a71ee0eb-6631-4948-a86f-bd2fbc131c40); Time taken: 0.038 seconds
INFO  : Concurrency mode is disabled, not creating a lock manager
INFO  : Executing command(queryId=hadoop_20210719164318_a71ee0eb-6631-4948-a86f-bd2fbc131c40): create database myhive
INFO  : Starting task [Stage-0:DDL] in serial mode
OK
  INFO  : Completed executing command(queryId=hadoop_20210719164318_a71ee0eb-6631-4948-a86f-bd2fbc131c40); Time taken: 1.604 seconds
INFO  : OK
INFO  : Concurrency mode is disabled, not creating a lock manager
No rows affected (1.657 seconds)

查看新建myhive信息

0: jdbc:hive2://master:10000> desc database myhive;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值