hive的metastore与hiveserver2

版权声明:本文为博主九师兄(QQ群:spark源代码 198279782 欢迎来探讨技术)原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_21383435/article/details/81670355

1. metastore配置

 <property>
     <name>hive.metastore.uris</name>
     <value>thrift://111.121.21.23:9083</value>
     <description></description>
</property>

metastore 启动方式

lcc@lcc ~$ hive --service metastore

我们一般用下面连接

HiveConf conf = new HiveConf();
conf.set("hive.metastore.uris", metaStoreUrls);
// 做血缘解析需要的东西
conf.set("hive.exec.post.hooks","org.apache.hadoop.hive.ql.hooks.LineageLogger");
// 有些语法需要的东西
conf.set("hive.exec.dynamic.partition.mode", "nonstrict");
SessionState.start(conf);
LOGGER.info("建立连接hive metastore成功, uris: {}", metaStoreUrls);

使用它获取元数据信息

SessionState.get().setCurrentDatabase(currentDatabase);

2. hiveserver2配置

<property>
       <name>hive.server2.thrift.port</name>
      <value>10002</value>
 </property>

主要是数据库操作

lcc@lcc ~$ beeline -u "jdbc:hive2://lcc:10013"
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/lcc/soft/hive/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/lcc/soft/hadoop/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]
Connecting to jdbc:hive2://lcc:10013
Connected to: Apache Hive (version 2.2.0)
Driver: Hive JDBC (version 2.2.0)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 2.2.0 by Apache Hive
0: jdbc:hive2://lcc:10013> show databases;
+----------------+--+
| database_name  |
+----------------+--+
| db1            |
| default        |
| lccdb          |

猜你喜欢

转载自blog.csdn.net/qq_21383435/article/details/81670355
今日推荐