赞
踩
1、启动元数据管理服务(必须启动,否则无法工作)
前台启动:bin/hive --service metastore
后台启动:nohup bin/hive --service metastore >> logs/metastore.log 2>&1 &
2、启动客户端
Hive Shell方式(可以直接写SQL): bin/hive
Last login: Sat May 27 08:10:46 2023 [root@node1 ~]# /export/server/hive/bin/hive SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/export/server/apache-hive-3.1.3-bin/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/export/server/hadoop-3.3.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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:/export/server/apache-hive-3.1.3-bin/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/export/server/hadoop-3.3.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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] Hive Session ID = 54980ee6-d20b-4382-b19f-473d7371bc48 Logging initialized using configuration in jar:file:/export/server/apache-hive-3.1.3-bin/lib/hive-common-3.1.3.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. Hive Session ID = 69151652-3030-496e-bf5f-d23e37b42a34 hive> show databases; OK default Time taken: 0.558 seconds, Fetched: 1 row(s)
先启动metastore服务端,在启动hiveserver2客户端,最后启动Beeline工具连接客户端
1、启动metastore
2、启动hiveserver2
前台启动:bin/hive --service hiveserver2
后台启动:nohup bin/hive --service hiveserver2 >> logs/hiveserver2.log 2>&1 &
3、启动Beeline
启动hive安装目录下的bin/beeline
[root@node1 ~]# /export/server/hive/bin/beeline SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/export/server/apache-hive-3.1.3-bin/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/export/server/hadoop-3.3.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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:/export/server/apache-hive-3.1.3-bin/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/export/server/hadoop-3.3.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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.3 by Apache Hive beeline> !connect jdbc:hive2://node1:10000 Connecting to jdbc:hive2://node1:10000 Enter username for jdbc:hive2://node1:10000: root Enter password for jdbc:hive2://node1:10000: Connected to: Apache Hive (version 3.1.3) Driver: Hive JDBC (version 3.1.3) Transaction isolation: TRANSACTION_REPEATABLE_READ 0: jdbc:hive2://node1:10000> show databases; INFO : Compiling command(queryId=root_20230527082711_5729d7f2-3dfa-4bfc-a0e8-3202a3d321da): show databases INFO : Concurrency mode is disabled, not creating a lock manager INFO : Semantic Analysis Completed (retrial = false) INFO : Returning Hive schema: Schema(fieldSchemas:[FieldSchema(name:database_name, type:string, comment:from deserializer)], properties:null) INFO : Completed compiling command(queryId=root_20230527082711_5729d7f2-3dfa-4bfc-a0e8-3202a3d321da); Time taken: 0.77 seconds INFO : Concurrency mode is disabled, not creating a lock manager INFO : Executing command(queryId=root_20230527082711_5729d7f2-3dfa-4bfc-a0e8-3202a3d321da): show databases INFO : Starting task [Stage-0:DDL] in serial mode INFO : Completed executing command(queryId=root_20230527082711_5729d7f2-3dfa-4bfc-a0e8-3202a3d321da); Time taken: 0.02 seconds INFO : OK INFO : Concurrency mode is disabled, not creating a lock manager +----------------+ | database_name | +----------------+ | default | +----------------+ 1 row selected (1.267 seconds) 0: jdbc:hive2://node1:10000> use default; INFO : Compiling command(queryId=root_20230527082722_f32f03bb-0e82-435d-8765-199834588275): use default 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=root_20230527082722_f32f03bb-0e82-435d-8765-199834588275); Time taken: 0.031 seconds INFO : Concurrency mode is disabled, not creating a lock manager INFO : Executing command(queryId=root_20230527082722_f32f03bb-0e82-435d-8765-199834588275): use default INFO : Starting task [Stage-0:DDL] in serial mode INFO : Completed executing command(queryId=root_20230527082722_f32f03bb-0e82-435d-8765-199834588275); Time taken: 0.012 seconds INFO : OK INFO : Concurrency mode is disabled, not creating a lock manager No rows affected (0.062 seconds) 0: jdbc:hive2://node1:10000>
正常启动后会出现表格形式展示hive中的数据库。而使用bin/hive方式启动客户端,不会以表格形式展示,使用Beeline方式比较可视化一些。
!connect jdbc:hive2://node1:10000
beeline工具使用hive2协议连接hiveserver2客户端
node1为主机名称,由于我设置了主机映射,可以直接使用主机名,代替ip地址
10000为连接hiveserver2的10000端口
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。