HIVE-元数据存储

HIVE-元数据存储

元数据(Meta Date),主要记录数据仓库中模型的定义、各层级间的映射关
系、监控数据仓库的数据状态及 ETL 的任务运行状态。一般会通过元数据资料库
(Metadata Repository)来统一地存储和管理元数据,其主要目的是使数据仓
库的设计、部署、操作和管理能达成协同和一致。


1. 元数据存储介质

根据元数据存储的介质不同,分为下面两个版本,其中 derby 属于内嵌模式,无需配置直接可用。实际生产环境中则使用 mysql 来进行元数据的存储。
(1) 内置 derby 版:
解压 hive 安装包 , bin/hive 启动即可使用 .
缺点:不同路径启动 hive,每一个 hive 拥有一套自己的元数据,无法共享
理解 : 在哪个目录下启动,就会在那个目录下生成 derby.log 和 metastore.db,只有在此目录下再次启动才可以继续使用上次的元数据库.

schematool -dbType derby -initSchema

(2) mysql 版:
解压安装hive(版本)

修改hive配置文件

# 修改Hadoop_HOME
vi conf/hive-env.sh 
# 配置元数据库信息
vi conf/hive-site.xml

配置 Mysql 元数据库信息

<!--数据库名hive-->
<configuration>
        <property>
                <name>javax.jdo.option.ConnectionURL</name>
                <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
                <description>JDBC connect string for a JDBC metastore</description>
        </property>

        <property>
                <name>javax.jdo.option.ConnectionDriverName</name>
                <!--com.mysql.cj.jdbc.Driver-->
                <value>com.mysql.jdbc.Driver</value>
                <description>Driver class name for a JDBC metastore</description>
        </property>

        <property>
                <name>javax.jdo.option.ConnectionUserName</name>
                <value>root</value>
                <description>username to use against metastore database</description>
        </property>

        <property>
                <name>javax.jdo.option.ConnectionPassword</name>
                <value>123456</value>
                <description>password to use against metastore database</description>
        </property>
</configuration>

将mysql的连接jar包拷贝到$HIVE_HOME/lib目录下
这里写图片描述配置元数据类型为mysql
schematool -dbType mysql -initSchema

[root@iZm5edx24ecfoc8828jj1pZ bin]# service mysqld start
Starting mysqld:                                           [  OK  ]
[root@iZm5edx24ecfoc8828jj1pZ bin]# schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/module/apache-hive-2.3.4-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/module/hadoop-2.7.4/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]
Metastore connection URL:        jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:       root
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Initialization script completed
schemaTool completed

启动 bin/hive 后mysql会生成hive数据库及相关表
这里写图片描述


2 元数据表(持续探索)
(1)DBS database元数据表
(2)SDS table映射表 可查看分区
(3)TBLS table元数据表
https://www.cnblogs.com/qingyunzong/p/8710356.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值