文章目录
Hive系列文章
Hive系列 (八):Hive中的explode 与 lateral view
一、启动beeline
-
启动metastore
[hadoop@master ~]$ hive --service metastore&
-
启动hiveserver2
[hadoop@master ~]$ hive --service hiveserver2&
-
启动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;