数据治理之元数据管理的利器——Atlas入门宝典

随着数字化转型的工作推进,数据治理的工作已经被越来越多的公司提上了日程。作为Hadoop生态最紧密的元数据管理与发现工具,Atlas在其中扮演着重要的位置。但是其官方文档不是很丰富,也不够详细。所以整理了这份文档供大家学习使用。

本文档基于Atlas2.1.0版本,整理自部分官网内容,各种博客及实践过程。文章较长,建议收藏。新版本的文档请关注公众号 大数据流动,会持续的更新~

本文档共分为8个部分,层级结构如下图所示。

数据治理之元数据管理的利器——Atlas入门宝典

文档版权为公众号 大数据流动 所有,请勿商用。相关技术问题以及安装包可以联系笔者 独孤风加入相关技术交流群讨论获取。

一、数据治理与元数据管理

背景

为什么要做数据治理? 业务繁多,数据繁多,业务数据不断迭代。人员流动,文档不全,逻辑不清楚,对于数据很难直观理解,后期很难维护。

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:11fd0d34-7799-4ec0-8641-f62a37688042

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:2118b070-4f22-4252-b089-ee26d37ab9ec

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:dc0eab3c-6439-43f8-99b6-4bf224a13b95

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:0e5ac4f4-884b-4eea-ba2e-81333cd6c80d

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:979aa3b8-0a93-4ad8-b883-046c64419f25

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:cd9c85e0-de34-406a-8788-8a2eb51134c3

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:c3fd9ceb-e8cf-44ca-b49f-bc8518799ebc

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:b9d9b0ce-c522-4340-8456-02a6171df7cd

元数据管理

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:4f2f493b-c57b-48df-8f2a-0ac77e0bf829

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:9ddbdf62-2e93-4cd6-98b6-f4cb91c602b6

三十年前,数据资产可能是 Oracle 数据库中的一张表。然而,在现代企业中,我们拥有一系列令人眼花缭乱的不同类型的数据资产。可能是关系数据库或 NoSQL 存储中的表、实时流数据、 AI 系统中的功能、指标平台中的指标,数据可视化工具中的仪表板。

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:0f95a7a3-3596-41e4-89cd-9394d030ac6a

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:f0264e72-b1a9-4eae-bc8d-d5d881919c71

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:313d9dbd-b7bc-4eac-9a20-55f19d645d3a

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:4bbb04fa-8110-4390-8526-f82f1e3baacf

  • 搜索和发现:数据表、字段、标签、使用信息
  • 访问控制:访问控制组、用户、策略
  • 数据血缘:管道执行、查询
  • 合规性:数据隐私/合规性注释类型的分类
  • 数据管理:数据源配置、摄取配置、保留配置、数据清除策略
  • AI 可解释性、再现性:特征定义、模型定义、训练运行执行、问题陈述
  • 数据操作:管道执行、处理的数据分区、数据统计
  • 数据质量:数据质量规则定义、规则执行结果、数据统计

架构与开源方案

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:f37ab893-6727-4dc9-acd3-cbf264b865ee

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:4b17e7b3-62c0-444a-8948-466fb8864595

下图描述了第一代元数据架构。它通常是一个经典的单体前端(可能是一个 Flask 应用程序),连接到主要存储进行查询(通常是 MySQL/Postgres),一个用于提供搜索查询的搜索索引(通常是 Elasticsearch),并且对于这种架构的第 1.5 代,也许一旦达到关系数据库的”递归查询”限制,就使用了处理谱系(通常是 Neo4j)图形查询的图形索引。

数据治理之元数据管理的利器——Atlas入门宝典

很快,第二代的架构出现了。单体应用程序已拆分为位于元数据存储数据库前面的服务。该服务提供了一个 API,允许使用推送机制将元数据写入系统。

数据治理之元数据管理的利器——Atlas入门宝典

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:3db30ff9-1cd1-4266-9f90-b108d1e93dbd

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:8237983d-89b8-4ec0-9a81-ecc7c3aeb63c

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:ca76d187-3331-4586-91f8-aab9c3a84b46

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:6ea4d4b5-903c-4027-96c9-7726ca0948a2

数据治理之元数据管理的利器——Atlas入门宝典

Apache Atlas 就是采用的这种架构,并且与Hadoop 生态系统紧密耦合。

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:df083fa8-b4dc-4689-a659-58cac9dcba9e

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:2458702c-0d0a-469f-9982-57ee318581c1

(包含部分非开源方案)

数据治理之元数据管理的利器——Atlas入门宝典

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:81f21ba5-9b91-46a4-8d3b-f6f0a5782900

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:22c76aeb-e948-400e-a73f-7233f46d677a

二、Apache Atlas简介

简介

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:c2551c2e-1505-4fb0-832b-c8332b128599

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:f4a00daa-acd9-4d1e-b724-6270827b51b2

大部分公司只是单纯的对数据进行了处理,而数据的血缘,分类等等却很难实现,市场上也急需要一个专注于数据治理的技术框架,这时Atlas应运而生。

Atlas官网地址:https://atlas.apache.org/

Atlas是Hadoop的数据治理和元数据框架。

Atlas是一组可扩展和可扩展的核心基础治理服务,使企业能够有效,高效地满足Hadoop中的合规性要求,并允许与整个企业数据生态系统集成。

Apache Atlas为组织提供了开放的元数据管理和治理功能,以建立其数据资产的目录,对这些资产进行分类和治理,并为数据科学家,分析师和数据治理团队提供围绕这些数据资产的协作功能。

如果想要对这些数据做好管理,光用文字、文档等东西是不够的,必须用图。Atlas就是把元数据变成图的工具。

http://atlas.apache.org/

数据治理之元数据管理的利器——Atlas入门宝典

特性

  • Atlas支持各种Hadoop和非Hadoop元数据类型
  • 提供了丰富的REST API进行集成
    [TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:2f59541b-1bb9-435d-b650-fee245b1b2e4
    [En]

    [TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:9c1859ed-f212-405d-a61f-dbcb8814c7d5

  • 对权限也有很好的控制

Atlas包括以下组件:

  • 采用Hbase存储元数据
  • 采用Solr实现索引
  • Ingest/Export 采集导出组件 Type System类型系统 Graph Engine图形引擎 共同构成Atlas的核心机制
  • 所有功能通过API向用户提供,也可以通过Kafka消息系统进行集成
  • Atlas支持各种源获取元数据:Hive,Sqoop,Storm。。。
  • 还有优秀的UI支持

效果图

数据治理之元数据管理的利器——Atlas入门宝典

数据治理之元数据管理的利器——Atlas入门宝典

三、整体架构

架构图

Atlas架构图如下:

数据治理之元数据管理的利器——Atlas入门宝典

Core层

Atlas核心包含以下组件:

类型(Type)系统: Atlas允许用户为他们想要管理的元数据对象定义模型。该模型由称为”类型”的定义组成。称为”实体”的”类型”实例表示受管理的实际元数据对象。 Type System是一个允许用户定义和管理类型和实体的组件。开箱即用的Atlas管理的所有元数据对象(例如Hive表)都使用类型建模并表示为实体。要在Atlas中存储新类型的元数据,需要了解类型系统组件的概念。

需要注意的一个关键点是Atlas中建模的一般特性允许数据管理员和集成商定义技术元数据和业务元数据。也可以使用Atlas的功能定义两者之间的丰富关系。

图形引擎: Atlas在内部使用Graph模型持久保存它管理的元数据对象。这种方法提供了很大的灵活性,可以有效地处理元数据对象之间的丰富关系。图形引擎组件负责在Atlas类型系统的类型和实体之间进行转换,以及底层图形持久性模型。除了管理图形对象之外,图形引擎还为元数据对象创建适当的索引,以便可以有效地搜索它们。 Atlas使用JanusGraph存储元数据对象。

采集/导出:采集组件允许将元数据添加到Atlas。同样,”导出”组件将Atlas检测到的元数据更改公开为事件。消费者可以使用这些更改事件来实时响应元数据的变更。

Integration层

在Atlas中,用户可以使用以下的两种方式管理元数据:

API: Atlas的所有功能都通过REST API向最终用户暴露,该API允许创建,更新和删除类型和实体。它也是查询和发现Atlas管理的类型和实体的主要机制。

Messaging: 除了API之外,用户还可以选择使用基于Kafka的消息传递接口与Atlas集成。这对于将元数据对象传递到Atlas以及使用Atlas使用可以构建应用程序的元数据更改事件都很有用。如果希望使用与Atlas更松散耦合的集成来实现更好的可伸缩性,可靠性等,则消息传递接口特别有用.Atlas使用Apache Kafka作为通知服务器,用于钩子和元数据通知事件的下游消费者之间的通信。事件由钩子和Atlas写入不同的Kafka主题。

Atlas支持开箱即用的多种元数据源集成。未来还将增加更多集成。目前,Atlas支持从以下来源提取和管理元数据:

  • HBase
  • Hive
  • Sqoop
  • Storm
  • Kafka

集成意味着两件事:Atlas定义的元数据模型用于表示这些组件的对象。 Atlas提供了从这些组件中摄取元数据对象的组件(在某些情况下实时或以批处理模式)。

Applications层

Atlas管理的元数据被各种应用程序使用,以满足许多治理需求。

Atlas Admin UI: 该组件是一个基于Web的应用程序,允许数据管理员和科学家发现和注释元数据。这里最重要的是搜索界面和类似SQL的查询语言,可用于查询Atlas管理的元数据类型和对象。 Admin UI使用Atlas的REST API来构建其功能。

Tag Based Policies:Apache Ranger是Hadoop生态系统的高级安全管理解决方案,可与各种Hadoop组件进行广泛集成。通过与Atlas集成,Ranger允许安全管理员定义元数据驱动的安全策略以实现有效的治理。 Ranger是Atlas通知的元数据更改事件的使用者。

四、编译、部署与安装

Atlas的安装坑较多。本教程将详细介绍Atlas2.1.0整个安装过程。

比较难受的是 ,Atlas不提供安装包,下载的是源码包 ,需要自行编译打包。

下载

请前往官网 https://atlas.apache.org/#/Downloads

数据治理之元数据管理的利器——Atlas入门宝典

下载对应版本的源码包 本文使用的是 2.1.0版本

国内站点 速度要快一些

https://mirrors.tuna.tsinghua.edu.cn/apache/atlas/2.1.0/apache-atlas-2.1.0-sources.tar.gz

安装maven

注意,需要先安装maven,因为这是使用maven开发的java web工程。maven3.6.3版本即可

一些下载地址

http://maven.apache.org/download.cgi

https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

上传到linux的/usr/local目录

cd /usr/local

解压文件

tar -zxvf apache-maven-3.6.3-bin.tar.gz

配置环境变量

vi /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.6.3
export PATH=MAVEN_HOME/bin:PATH

刷新环境变量

source /etc/profile

检查版本

mvn -v

数据治理之元数据管理的利器——Atlas入门宝典

配置好maven的环境变量
注意国内需要配置好maven的国内镜像,一般使用阿里,华为,清华等镜像
vi /usr/local/apache-maven-3.6.3/conf/settings.xml

<mirror>
    <id>alimaven</id>
    <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <mirrorof>central</mirrorof>
</mirror>

把这个setting.xml 拷贝到 ~/.m2/

cp settings.xml .m2/

编译Atlas

解压源码包

tar -zxvf apache-atlas-2.1.0-sources.tar.gz
1.修改atlas源码工程的pom.xml

将hbase zookeeper hive等依赖的版本修改成自己环境中一致的版本(或者兼容的版本)

&#x7236;&#x5DE5;&#x7A0B;pom&#x6587;&#x4EF6;
<zookeeper.version>3.4.14</zookeeper.version>
<hbase.version>2.2.3</hbase.version>
<solr.version>7.7.2</solr.version>
2.执行maven编译打包

atlas可以使用内嵌的hbase-solr作为底层索引存储和搜索组件,也可以使用外置的hbase和solr
如果要使用内嵌的hbase-solr,则使用如下命令进行编译打包
cd apache-atlas-sources-2.1.0/
export MAVEN_OPTS=”-Xms2g -Xmx2g”
mvn clean -DskipTests package -Pdist,embedded-hbase-solr

不用内置就这样 mvn clean -DskipTests package -Pdist

改完路径还会非常快的 耐心等待

数据治理之元数据管理的利器——Atlas入门宝典

atlas的webui子模块中依赖了nodejs,会从nodejs的中央仓库去下载相关依赖库

编译完成之后,会产生打包结果,所在位置是:源码目录中的新出现的distro/target目录

  • 注意,这里产出的有压缩包也有解压后的包。这里面的hook包,可以看到有各种平台的hook包。
    [TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:228d2a32-ab80-45ff-a8d8-097ae5b69ae1
    [En]

    [TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:7d9f7b39-7643-41fa-9871-38275fc1f90b

如果没有错误 并看到一排success就是成功了

数据治理之元数据管理的利器——Atlas入门宝典

安装Atlas

在完成Atlas编译以后,就可以进行Atlas的安装了。Atlas的安装主要是安装Atlas的Server端,也就Atlas的管理页面,并确保Atlas与Kafka Hbase Solr等组件的集成。

Atlas的系统架构如下,在确保 底层存储与UI界面正常后,之后就可以进行与Hive等组件的集成调试了。

在完成Atlas编译以后,就可以进行Atlas的安装了。Atlas的安装主要是安装Atlas的Server端,也就Atlas的管理页面,并确保Atlas与Kafka Hbase Solr等组件的集成。

在确保 底层存储与UI界面正常后,之后就可以进行与Hive等组件的集成调试了。

1、环境准备

安装之前 先要准备好

JDK1.8

Zookeeper

Kafka

Hbase

Solr

在启动Atlas时会配置这些环境变量的地址,所以一定要确保以上组件正常运行。

由于在编译时可以选择内部集成,所以这些Atlas是可以自带的,但是JDK一定要安装好。

在安装Altas中,需要Solr 预先创建好collection

 bin/solr create -c vertex_index -shards 3 -replicationFactor 2

 bin/solr create -c edge_index -shards 3 -replicationFactor 2

bin/solr create -c fulltext_index -shards 3 -replicationFactor 2

在solr中验证创建成功。

2、安装Atlas

到编译好的包的路径下 apache-atlas-sources-2.1.0/distro/target

将生成好的安装包 apache-atlas-2.1.0-server.tar.gz 拷贝到目标路径下。

解压:

tar -zxvf apache-atlas-2.1.0-server.tar.gz

3、修改配置

进入conf目录下:

vi  atlas-env.sh

在此指定JAVA_HOME和是否要用内嵌启动

export JAVA_HOME=/opt/jdk1.8.0_191/
export MANAGE_LOCAL_HBASE=true
export MANAGE_LOCAL_SOLR=true

如果使用内嵌,那么配置结束,直接去 启动Atlas

但是大部分时候,需要使用已经有的组件进行集成,所以设置为false。

export JAVA_HOME=/opt/jdk1.8.0_191/
export MANAGE_LOCAL_HBASE=false
export MANAGE_LOCAL_SOLR=false
#&#x6CE8;&#x610F;&#x4FEE;&#x6539;Hbase&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;
export HBASE_CONF_DIR=/opt/hbase/conf

修改其他配置

vim atlas-application.properties

这里就是设置Hbase Solr等配置

#Hbase&#x5730;&#x5740;  &#x5C31;&#x662F;Hbase&#x914D;&#x7F6E;&#x7684;zookeeper&#x5730;&#x5740;
atlas.graph.storage.hostname=slave01:2181,slave02:2181,slave03:2181

atlas.audit.hbase.zookeeper.quorum=slave01:2181,slave02:2181,slave03:2181

#solr&#x670D;&#x52A1;&#x5668;&#x5730;&#x5740;
atlas.graph.index.search.solr.http-urls=http://slave01:8984/solr

#kafka&#x5730;&#x5740;
atlas.notification.embedded=false
atlas.kafka.zookeeper.connect=slave01:2181,slave02:2181,slave03:2181
atlas.kafka.bootstrap.servers=slave01:9092,slave02:9092,slave03:9092

#atlas&#x5730;&#x5740;
atlas.rest.address=http://slave01:21000

启动Atlas

bin/atlas_start.py

启动成功后访问:

http://slave01:21000

admin/admin登录

数据治理之元数据管理的利器——Atlas入门宝典

五、页面功能介绍

Atlas的页面功能非常的丰富,可以进行元数据的管理及数据血缘的展示。

主界面

数据治理之元数据管理的利器——Atlas入门宝典

Search

数据治理之元数据管理的利器——Atlas入门宝典

基本搜索

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:4c5e94a4-73cc-42f4-8d28-eb085324c86e

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:2a4b73f3-2854-4e8e-bce5-56e36e846162

可以使用 AND/OR 条件对多个属性进行基于属性的过滤。

数据治理之元数据管理的利器——Atlas入门宝典
数据治理之元数据管理的利器——Atlas入门宝典
数据治理之元数据管理的利器——Atlas入门宝典

支持的过滤运算符

  • LT(符号:

高级搜索

Atlas 中的高级搜索也称为基于 DSL 的搜索。

领域特定搜索 (DSL) 是一种结构简单的语言,该语法模拟了关系数据库流行的结构化查询语言 (SQL)。

具体语法请参考Github上的Atlas DSL Grammer (Antlr G4格式)。

例:要检索名称可以是 time_dim 或 customer_dim 的 Table 类型的实体:

from Table where name = 'time_dim' or name = 'customer_dim'

Classification

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:76ce5dc8-decb-4933-b2ed-e8f99c612d48

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:a1d18d6e-b693-45fb-a12d-ce9afccbfd4e

数据治理之元数据管理的利器——Atlas入门宝典

为实体添加分类

将分类”PII”添加到”hdfs_path”实体后,该分类将传播到沿袭路径中的所有受影响实体,包括”员工”表、视图”us_employees”和”uk_employees” – 如下所示。

数据治理之元数据管理的利器——Atlas入门宝典

更新与实体关联的分类

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:55e0f039-98d0-4b5f-be50-738525c4f8f1

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:05562c01-0e33-47bc-b33e-d3ff931c4a03

数据治理之元数据管理的利器——Atlas入门宝典

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:647fca2a-d997-4900-8d70-b0940f6302f5

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:00e1a020-6985-4704-a7ed-66d718c4e0f1

glossary

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:9b826c07-9d87-4146-a3be-0844c3dfdb45

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:9812e7b6-2192-4c55-a063-b9b8f41eaead

数据治理之元数据管理的利器——Atlas入门宝典

通过单击词汇表 UI 中的术语名称,可以查看术语的各种详细信息。详细信息页面下的每个选项卡提供该术语的不同详细信息。

数据治理之元数据管理的利器——Atlas入门宝典

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:3cec7c2a-282d-43e8-ae0c-36cd7505a8d8

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:a4e31e5a-a114-447a-a15e-0d7bee7ad1c2

数据治理之元数据管理的利器——Atlas入门宝典

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:91e5946c-4103-4655-8e42-19ab898e285e

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:aa9f8e37-bcc1-4bf7-a43b-7825e8afde26

数据治理之元数据管理的利器——Atlas入门宝典

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:50b3e796-6d1a-46fd-a084-5a43f2f0a83c

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:bf85977f-a051-4c14-b13e-41151228ac49

六、Hive数据血缘

Hive2兼容性问题

Atlas与Hive存在兼容性问题,本文基于Atlas2.1.0兼容CDH6.3.2部署。Hive版本为2.1.1.其他版本的问题不在此文档讨论。

为兼容Hive2.1.1,需要修改源码重新编译。

  • 所需修改的项目位置: apache-atlas-sources-2.1.0\addons\hive-bridge

①.org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java 577行

String catalogName = hiveDB.getCatalogName() != null ? hiveDB.getCatalogName().toLowerCase() : null;

改为:

String catalogName = null;

②.org/apache/atlas/hive/hook/AtlasHiveHookContext.java 81行

this.metastoreHandler = (listenerEvent != null) ? metastoreEvent.getIHMSHandler() : null;

改为:C:\Users\Heaton\Desktop\apache-atlas-2.1.0-sources\apache-atlas-sources-2.1.0\addons

this.metastoreHandler = null;

集成Hive

  • 将 atlas-application.properties 配置文件,压缩加入到 atlas-plugin-classloader-2.0.0.jar 中
#必须在此路径打包,才能打到第一级目录下
cd /usr/local/src/atlas/apache-atlas-2.1.0/conf

zip -u /usr/local/src/atlas/apache-atlas-2.1.0/hook/hive/atlas-plugin-classloader-2.1.0.jar atlas-application.properties
  • 修改 hive-site.xml

数据治理之元数据管理的利器——Atlas入门宝典

    hive.exec.post.hooks
    org.apache.atlas.hive.hook.HiveHook

  • 修改 hive-env.sh 的 Gateway 客户端环境高级配置代码段(安全阀)

数据治理之元数据管理的利器——Atlas入门宝典
HIVE_AUX_JARS_PATH=/usr/local/src/atlas/apache-atlas-2.1.0/hook/hive
  • 修改 HIVE_AUX_JARS_PATH

数据治理之元数据管理的利器——Atlas入门宝典
  • 修改 hive-site.xml 的 HiveServer2 高级配置代码段(安全阀)

数据治理之元数据管理的利器——Atlas入门宝典

    hive.exec.post.hooks
    org.apache.atlas.hive.hook.HiveHook

    hive.reloadable.aux.jars.path
    /usr/local/src/atlas/apache-atlas-2.1.0/hook/hive

  • 修改 HiveServer2 环境高级配置代码段

数据治理之元数据管理的利器——Atlas入门宝典
HIVE_AUX_JARS_PATH=/usr/local/src/atlas/apache-atlas-2.1.0/hook/hive

需要将配置好的Atlas包发往各个hive节点后重启集群。

导入Hive元数据

  • 执行atlas脚本
./bin/import-hive.sh
#输入用户名:admin;输入密码:admin

登录Atlas查看元数据信息。

测试实时hive hook

简单执行一个hera资源统计的hive脚本

use sucx_test
;

-- &#x6628;&#x65E5;&#x5347;&#x7EA7;&#x8BBE;&#x5907;&#x6570;
create table if not exists qs_tzl_ProductTag_result(
pid string
,category string
,category_code string
,tag_name string
,tag_value string
,other string
,update_time string
)
partitioned by (tag_id string)
STORED AS PARQUET TBLPROPERTIES('parquet.compression'='SNAPPY')
;

insert overwrite table qs_tzl_ProductTag_result partition(tag_id='3014')
select
       T1.product_id as pid
       ,T2.category
       ,cast(from_unixtime(unix_timestamp()) as string) as update_time
from (select
             product_id
      from COM_PRODUCT_UPGRADE_STAT_D where p_day='20200901'
     ) T1
left join (select category
        from bi_ods.ods_smart_product where dt='20200901'
        ) T2
on T1.product_id=T2.id
;

执行后查看 qs_tzl_ProductTag_result 的表级血缘为

数据治理之元数据管理的利器——Atlas入门宝典

pid 的字段血缘为

数据治理之元数据管理的利器——Atlas入门宝典

七、Spark数据血缘

打包spark-atlas-connector

atlas 官方文档中并不支持 spark sql 的解析,需要使用第三方的包。

地址: https://github.com/hortonworks-spark/spark-atlas-connector

一、git clone 后本地进行打包

mvn package -DskipTests

二、打包后在 spark-atlas-connector/spark-atlas-connector-assembly/target 目录有一个 spark-atlas-connector-assembly-${version}.jar 的 jar,将该 jar 上传到服务器。
需要注意的是不要上传 spark-atlas-connector/spark-atlas-connector/target 这个目录内的 jar ,缺少相关依赖包

三、将 spark-atlas-connector-assembly-${version}.jar 放到一个固定目录 比如/opt/resource

测试spark hook

首先进入spark-sql client

spark-sql --master yarn  \
--jars /opt/resource/spark-atlas-connector_2.11-0.1.0-SNAPSHOT.jar  \
--files /opt/resource/atlas-application.properties \
--conf spark.extraListeners=com.hortonworks.spark.atlas.SparkAtlasEventTracker \
--conf spark.sql.queryExecutionListeners=com.hortonworks.spark.atlas.SparkAtlasEventTracker \
--conf spark.sql.streaming.streamingQueryListeners=com.hortonworks.spark.atlas.SparkAtlasStreamingQueryEventTracker

&#x6267;&#x884C; hera &#x7684;&#x4E00;&#x4E2A;&#x8D44;&#x6E90;&#x7EDF;&#x8BA1;&#x4EFB;&#x52A1;

CREATE EXTERNAL TABLE  IF NOT EXISTS sucx_hera.ads_hera_task_mem_top_10(
    job_id BIGINT COMMENT '&#x4EFB;&#x52A1;ID',
    user STRING COMMENT '&#x5173;&#x6CE8;&#x4EBA;',
    applicationId STRING COMMENT 'yarn&#x6267;&#x884C;&#x7684;app id',
    memorySeconds BIGINT COMMENT '&#x5185;&#x5B58;&#x4F7F;&#x7528;&#x65F6;&#x95F4;&#x548C;',
    startedTime BIGINT COMMENT '&#x5F00;&#x59CB;&#x65F6;&#x95F4;',
    finishedTime BIGINT COMMENT '&#x7ED3;&#x675F;&#x65F6;&#x95F4;',
    elapsedTime BIGINT COMMENT '&#x8FD0;&#x884C;&#x65F6;&#x95F4;',
    vcoreSeconds BIGINT COMMENT 'vcore&#x4F7F;&#x7528;&#x65F6;&#x95F4;&#x548C;')

ROW FORMAT SERDE
    'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
WITH SERDEPROPERTIES (
    'field.delim'='\t',
    'serialization.format'='\t')
STORED AS INPUTFORMAT
    'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
    'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
    'cosn://sucx-big-data/bi//sucx_hera/ads_hera_task_mem_top_10';

insert overwrite table sucx_hera.ads_hera_task_mem_top_10

select
 job_id,user,applicationId,memorySeconds,startedTime,finishedTime,elapsedTime,vcoreSeconds
from
(SELECT
    top.job_id,
    row_number() over(distribute by top.applicationId ORDER BY sso.id) as num,
    case when sso.name is null then operator
    else sso.name end as user,
    top.applicationId,
    top.memorySeconds,
    top.startedTime,
    top.finishedTime,
    top.elapsedTime,
    top.vcoreSeconds

FROM (
select * from sucx_hera.dws_hera_task_mem_top_10 where dt = '20200901' ) top

left join bi_ods.ods_hera_job_monitor monitor

on  monitor.dt='20200901' and top.job_id=monitor.job_id

left join bi_ods.ods_hera_sso sso

on sso.dt='20200901' and find_in_set(sso.id,monitor.user_ids) >0 order by job_id ) temp

where temp.num = 1

执行后,查看 ads_hera_task_mem_top_10 表级血缘

数据治理之元数据管理的利器——Atlas入门宝典

注意此包不支持 spark 字段的支持。

如果需要spark字段的支持,一种是spark代码转成hive跑一遍,一种就是需要自研了。

八、Atlas二次开发

atlas虽好,但是很多场景依然无法满足我们的需要。这时候就不得不做一些改动了。二次开发有两种方式一种是基于Atlas Api的开发,一种是修改源码。

REST API

http://atlas.apache.org/api/v2/index.html

DiscoveryREST

http://hostname:21000/api/atlas/v2/search/basic?classification=class1
&#x53C2;&#x6570;&#x652F;&#x6301;&#xFF1A;query&#x3001;typeName&#x3001;classification&#x3001;excludeDeletedEntities&#x3001;limit&#x3001;offset
code&#xFF1A;https://github.com/apache/atlas/blob/6bacbe946bbc5ca72118304770d5ad920695bd52/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java

&#x67E5;&#x8BE2;&#x6240;&#x6709; Table
http://hostname:21000/api/atlas/v2/search/dsl?typeName=Table

&#x67E5;&#x8BE2; owner &#x524D;&#x7F00;&#x4E3A; John &#x7684; Table
http://hostname:21000/api/atlas/v2/search/attribute?typeName=Table&attrName=owner&attrValuePrefix=John

&#x67E5;&#x8BE2; Table &#x7684;&#x4E00;&#x4E9B;&#x5C5E;&#x6027;&#xFF0C;&#x5982;&#xFF1A;guid, ownerName, searchParameters &#x7B49;
http://hostname:21000/api/atlas/v2/search/saved/Table

&#x4E0D;&#x662F;&#x5F88;&#x61C2;&#xFF08;&#x8FD4;&#x56DE;&#x7684;&#x6570;&#x636E;&#x548C;&#x4E0A;&#x9762;&#x90A3;&#x4E2A; API &#x4E00;&#x6A21;&#x4E00;&#x6837;&#xFF09;
http://hostname:21000/api/atlas/v2/search/saved

&#x67E5;&#x8BE2; EntityType - Table &#x4E0B;&#x6709;&#x54EA;&#x4E9B; entity.

http://hostname:21000/api/atlas/v2/search/saved/execute/Table

&#x67E5;&#x8BE2; guid &#x4E3A; e283d8c1-ae19-4f4b-80c0-38031788383b &#x7684; EntityType &#x4E0B;&#x6709;&#x54EA;&#x4E9B; entity.

http://hostname:21000/api/atlas/v2/search/saved/execute/guid/e283d8c1-ae19-4f4b-80c0-38031788383b

LineageREST

&#x67E5;&#x8BE2; guid &#x4E3A; a95cb57f-4643-4edf-b5a5-0f1de2e0f076 &#x7684;&#x5B9E;&#x4F53;&#x7684;&#x8840;&#x7F18;
http://hostname:21000/api/atlas/v2/lineage/a95cb57f-4643-4edf-b5a5-0f1de2e0f076

EntityREST

&#x67E5;&#x8BE2; guid &#x4E3A; 48f29229-47a9-4b05-b053-91e6484f42a1 &#x7684;&#x5B9E;&#x4F53;
http://hostname:21000/api/atlas/v2/entity/guid/48f29229-47a9-4b05-b053-91e6484f42a1

&#x67E5;&#x8BE2; guid &#x4E3A; 48f29229-47a9-4b05-b053-91e6484f42a1 &#x7684;&#x5B9E;&#x4F53;&#x7684;&#x5BA1;&#x8BA1;&#x6570;&#x636E;
http://hostname:21000/api/atlas/v2/entity/48f29229-47a9-4b05-b053-91e6484f42a1/audit

&#x67E5;&#x8BE2; guid &#x4E3A; 48f29229-47a9-4b05-b053-91e6484f42a1 &#x7684;&#x5B9E;&#x4F53;&#x6240;&#x5C5E;&#x7684; classifications
http://hostname:21000/api/atlas/v2/entity/guid/48f29229-47a9-4b05-b053-91e6484f42a1/classifications

&#x6839;&#x636E; EntityType &#x7684;&#x552F;&#x4E00;&#x5C5E;&#x6027;&#x67E5;&#x627E;&#x5B9E;&#x4F53;
&#x5982;&#x4E0B;&#xFF1A;name &#x662F; DB &#x7684;&#x4E00;&#x4E2A;&#x552F;&#x4E00;&#x5C5E;&#x6027;. &#x67E5;&#x627E; name=Logging &#x7684; DB.

http://hostname:21000/api/atlas/v2/entity/uniqueAttribute/type/DB?attr:name=Logging

&#x67E5;&#x8BE2; entity &#x4E0E; classification &#x662F;&#x5426;&#x6709;&#x5173;&#xFF1F;
http://hostname:21000/api/atlas/v2/entity/guid/48f29229-47a9-4b05-b053-91e6484f42a1/classification/Dimension

&#x6279;&#x91CF;&#x67E5;&#x8BE2;&#x5B9E;&#x4F53;
http://hostname:21000/api/atlas/v2/entity/bulk?guid=e667f337-8dcc-468b-a5d0-96473f8ede26&guid=a95cb57f-4643-4edf-b5a5-0f1de2e0f076

RelationshipREST

&#x67E5;&#x8BE2; guid &#x4E3A; 726c0120-19d2-4978-b38d-b03124033f41 &#x7684; relationship
&#x6CE8;&#xFF1A;relationship &#x53EF;&#x4EE5;&#x770B;&#x505A;&#x662F;&#x8840;&#x7F18;&#x7684;&#x4E00;&#x6761;&#x8FB9;
http://hostname:21000/api/atlas/v2/relationship/guid/726c0120-19d2-4978-b38d-b03124033f41

TypesREST

http://hostname:21000/api/atlas/v2/types/typedef/guid/e0ca4c40-6165-4cec-b489-2b8e5fc7112b
http://hostname:21000/api/atlas/v2/types/typedef/name/Table
http://hostname:21000/api/atlas/v2/types/typedefs/headers
http://hostname:21000/api/atlas/v2/types/typedefs
http://hostname:21000/api/atlas/v2/types/enumdef/name/hive_principal_type
http://hostname:21000/api/atlas/v2/types/enumdef/guid/ee30446a-92e1-4bbc-aa0a-66ac21970d88
http://hostname:21000/api/atlas/v2/types/structdef/name/hive_order
http://hostname:21000/api/atlas/v2/types/structdef/guid/0b602605-8c88-4b60-a177-c1c671265294
http://hostname:21000/api/atlas/v2/types/classificationdef/name/PII
http://hostname:21000/api/atlas/v2/types/classificationdef/guid/3992eef8-fd74-4ae7-8b35-fead363b2122
http://hostname:21000/api/atlas/v2/types/entitydef/name/DataSet
http://hostname:21000/api/atlas/v2/types/entitydef/guid/5dca20ce-7d57-4bc3-a3f1-93fa622c32b1
http://hostname:21000/api/atlas/v2/types/relationshipdef/name/process_dataset_outputs
http://hostname:21000/api/atlas/v2/types/relationshipdef/guid/5d76dae0-6bad-4d19-b9b2-cb0cdc3b53d5

GlossaryREST

http://hostname:21000/api/atlas/v2/glossary
http://hostname:21000/api/atlas/v2/glossary/302dc8f8-3bc8-4878-9ba2-0c585ca6de3d

本地开发环境

启动HBase和solr

由于在 Atlas需要使用到 HBase以及 slor。方便调试可以解压之前编译好内置 HBase&#x548C;sole的tar。

文件补充

创建文件夹将,atlas所需要的文件拷贝过去。

将编译内置HBase以及solr源码目录distro/target/conf下的文件拷贝到上述的上图的conf目录。
将源码中addons/models下所有的文件拷贝过去。
将源码中的atlas/webapp/target中的内容全部拷贝到webapp目录中。

源码启动

将clone下来的源码导入到IDEA中。配置启动参数:

-Datlas.home=/opt/deploy
-Datlas.conf=/opt/deploy/conf
-Datlas.data=/opt/deploy/data

附录:

参考文章:

http://atlas.apache.org/

https://blog.csdn.net/su20145104009/article/details/108253556

https://www.cnblogs.com/ttzzyy/p/14143508.html

本文档为Atlas入门宝典,介绍了Atlas基本的一些使用,部分高级功能还在调研与摸索中。包括Atlas与spark,flink的更深入整合,以及与数据湖的集成。也欢迎对数据治理,元数据管理,Atlas感兴趣的朋友加入学习群进行讨论交流~

数据治理之元数据管理的利器——Atlas入门宝典

数据治理之元数据管理的利器——Atlas入门宝典

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:b7b3d893-42db-434a-a7e0-4f1f71a7df47

[En]

[TencentCloudSDKException] code:FailedOperation.ServiceIsolate message:service is stopped due to arrears, please recharge your account in Tencent Cloud requestId:07a1977c-a6d7-4c73-8186-1440e58f9bac

Original: https://www.cnblogs.com/tree1123/p/15480639.html
Author: 独孤风
Title: 数据治理之元数据管理的利器——Atlas入门宝典

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/562195/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球