DataHub元数据治理平台架构

839 阅读3分钟

概述

datahub提供数据治理、数据发现、数据血缘的元数据管理平台。采用模型优先的理念。

架构

image.png 从上图可以看到DataHub由以下几部分组成:

  • 前端
  • 数据摄取(datahub ingestion)
  • Datahub serving

image.png 从上图可以看到由三个层级结构:

  • 客户端层:前端页面、数据摄取以及一些数据发射API
  • APP层:为前端页面提供服务的server、元数据服务、存储元数据变更事件的kafka
  • 持久化层
    • mysql:前端页面的查询数据
    • es:元数据
    • kafka:metadata commit log(MCL)

Datahub是面向流的。这样可以方便获得元数据的变更事件并通过订阅这些变更事件来实现元数据变更事件驱动的系统。

元数据建模

Datahub是通过什么方式组织元数据的?也就是Datahub的核心数据结构是什么样的?从元数据的摄取到元数据的存储都是用的什么数据模型呢?

Datahub采用schema-first的设计哲学来建模(model)元数据(metadata)。Datahub通过PDL(Pegasus schema language)来描述。PDL类似于ProtoBuf,只不过PDL使用JSON进行序列化。

Datahub有如下模型(model):

  • Entity: An entity is the primary node in the metadata graph。可以理解为一个DataSet实例是一个Entity;一个CorpUser也是一个Entity(类似于一个MySQL的table)。Entity是由Aspect组成的。
  • Aspect: An aspect is a collection of attributes that describes a particular facet of an entity. They are the smallest atomic unit of write in DataHub. That is, multiple aspects associated with the same Entity can be updated independently. For example, DatasetProperties contains a collection of attributes that describes a Dataset. Aspects can be shared across entities, for example "Ownership" is an aspect that is re-used across all the Entities that have owners.
    • Aspect是描述一个entity的属性集合。Aspects是Datahub进行更新的最小单元。Aspect可以在多个Entity之间共享。

数据摄取

Datahub提供了摄取各种数据源的Python SDK。可以将外部系统(如MySQL、mongo、kafka、hudi)数据转换为Datahub的数据模型,然后写入到kafka或者直接通过rest API写入到Datahub的存储层。

image.png

上图中Proposal(提交) Stream中存放的是MCE(Metadata Change Event)。MCE表示的是元数据变化的事件,通过mce-consumer消费到datahub的服务层( Generalized Metadata Service GMS)。GMS可以理解为Datahub的存储层。

Datahub在摄取数据时,既支持拉(Python SDK)的方式,有支持推(可以同步又可以异步)的方式。

Datahub serving

image.png

Datahub服务层包括核心组件Metadataservice(图中的datahub-gms),还包括向datahub-frontend提供查询的Rest API和GraphQL(如血缘关系)、二级索引、全文索引。

MCL

The DataHub Service Tier also emits a commit event Metadata Change Log when a metadata change has been successfully committed to persistent storage. This event is sent over Kafka. 在上一节中讲到MCE(Metadata change event),这里当Datahub通过service层将元数据变更事件成功持久化到DataStore(MySQL)之后,会发送MAE(Metadata Accept Event)到kafka。由Change Stream Processor(mae-consumer)消费到es。业务方也可以订阅这个kafka的消息来做外部扩展应用。

To ensure that metadata changes are processed in the correct chronological order, MCLs are keyed by the entity URN — meaning all MAEs for a particular entity will be processed sequentially by a single thread. 为了确保所有的metadata变更按照正确的顺序被处理,MCL通过URN(Uniform Resouce Name,保证唯一)来标识一个entity实体,这样针对一个entity实体的所有MAE都可以被一个线程顺序处理。

名词解释

  • AVRO
    • 一个序列化框架。主要用于大数据hadoop领域。
      • Apache Avro™ is the leading serialization format for record data, and first choice for streaming data pipelines.

参考