【数据治理】Atlas2.2.0基于HDP进行Hive的接入

35 篇文章 0 订阅
2 篇文章 0 订阅

前言

本文记录了在HDP3.1.5下,对接Atlas2.2.0的相关操作步骤和注意事项

正文

前提条件

  • 确认脚本运行的服务器存在hive客户端配置文件,且路径为/etc/hive/conf/
  • atlas-application.properties配置文件拷贝到hive客户端配置路径;
  • 确保脚本运行的服务器存在hadoop服务和依赖包,简而言之,要有客户端程序;

操作步骤

导入离线数据

针对已经在Hive中存在的数据,要使用离线脚本进行导入,该脚本在Atlas中已经包含:

./import-hive.sh 

image-20221101172032787

设置Hive-Hook

如果使用的是Ambari,直接在Hive中进行设置或者修改hive-site.xml客户端配置:

  <property>
      <name>hive.exec.post.hooks</name>
      <value>org.apache.atlas.hive.hook.HiveHook</value>
  </property>
  <property>
      <name>atlas.cluster.name</name>
      <value>atlas</value>
  </property>

image-20221102135507465

自定义atlas-application.properties配置:

# hive-hook相关的信息
atlas.hook.hive.keepAliveTime=10
atlas.hook.hive.maxThreads=5
atlas.hook.hive.minThreads=5
atlas.hook.hive.numRetries=3
atlas.hook.hive.queueSize=1000
atlas.hook.hive.synchronous=false
# 以下配置项保证和Server端一致
atlas.kafka.bootstrap.servers=172.18.2.11:6667,172.18.2.37:6667,172.18.2.19:6667
atlas.kafka.hook.group.id=atlas
atlas.kafka.zookeeper.connect=172.18.2.11:2181,172.18.2.37:2181,172.18.2.19:2181
atlas.kafka.zookeeper.connection.timeout.ms=200
atlas.kafka.zookeeper.session.timeout.ms=400
# 使用的kafkaTopic名称
atlas.notification.topics=ATLAS_HOOK,ATLAS_ENTITIES
# atlas对应的restapi地址
atlas.rest.address=http://172.18.0.25:21000
# 集群名称
atlas.cluster.name=dev

image-20221102140205446

image-20221102140310392

设置以后重启Hive服务,目前没有测试不重启是否能生效,估计是不能

测试SQL触发血缘变化

创建数据库
create database atlas_test;

image-20221102165301426

创建数据表
create table `dept`(
`deptno` int,
`dname` varchar(14),
`loc` varchar(13)
) row format delimited fields terminated by '\t'
stored as textfile;

image-20221102165334351

插入数据,测试血缘
# 插入原始数据
insert into dept values (10,'accounting','new york'),(20,'research','dallas'),(30,'sales','chicago'),(40,'operations','boston');
# 创建dept_two表,数据来自于dept
create table dept_two as select * from dept;
# 创建dept_three表,数据来自于dept_two
create table dept_three as select * from dept_two;
# 创建dept_four空表
CREATE TABLE `dept_four`(                         
  `deptno` int,                                    
  `dname` varchar(14),                             
  `loc` varchar(13))                               
ROW FORMAT SERDE                                   
  'org.apache.hadoop.hive.ql.io.orc.OrcSerde'      
STORED AS INPUTFORMAT                              
  'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'  
OUTPUTFORMAT                                       
  'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat' 
LOCATION                                           
  'hdfs://node-4.datasw:8020/warehouse/tablespace/managed/hive/atlas_test.db/dept_four' 
TBLPROPERTIES (                                    
  'bucketing_version'='2',                         
  'transactional'='true',                          
  'transactional_properties'='default',            
  'transient_lastDdlTime'='1667376408');
# 向dept_four表插入数据,数据来源于dept_three
insert into table dept_four select * from dept_three;
# 向dept_four表插入数据,数据来源于dept_two
insert into table dept_four select * from dept_two;

最终形成如下的血缘图:

image-20221102165902254

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Meepoljd

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值