Apache NiFi之MySQL数据同步到HBase

摘要:
一.说明将ApacheNiFi做为关系型数据与非关系型数据库的数据同步工具使用,在此场景中需要将mysql导出的avro数据格式转化为json入库HBase二.开拔Ⅰ).配置ExecuteSQLRecorda).选择ExecuteSQLRecord在Processor中搜索ExecuteSQLRecordb).配置ExecuteSQLRecord1.创建DatabaseConnectionPool
一.说明

将Apache NiFi做为关系型数据与非关系型数据库的数据同步工具使用,在此场景中需要将mysql导出的avro数据格式转化为json入库HBase

二.开拔

Ⅰ).配置ExecuteSQLRecord

a).选择ExecuteSQLRecord

在Processor中搜索ExecuteSQLRecord

Apache NiFi之MySQL数据同步到HBase第1张

b).配置ExecuteSQLRecord

1.创建Database Connection Pool
2.创建JsonRecordSetWriter
3.配置SQL select query
select Host,User,authentication_string from mysql.user;

Apache NiFi之MySQL数据同步到HBase第2张

c).创建DBCPConnectionPool

在Database Connection Pool中选择DBCPConnectionPool

Apache NiFi之MySQL数据同步到HBase第3张

d).配置DBCPConnectionPool

1.Database Connection URL: jdbc:mysql://hostname:3306/druid
2.Database Driver Class Name: com.mysql.jdbc.Driver
3.Database User: username
4.Database Password: password

Apache NiFi之MySQL数据同步到HBase第4张

e).激活服务

Apache NiFi之MySQL数据同步到HBase第5张

Ⅱ).配置ConvertAvroToJSON

a).选择ConvertAvroToJSON

在Processor中搜索ConvertAvroToJSON

Apache NiFi之MySQL数据同步到HBase第6张

b).配置ConvertAvroToJSON

Apache NiFi之MySQL数据同步到HBase第7张

Ⅲ).配置SplitJson

a).选择SplitJson

在Processor中搜索SplitJson

Apache NiFi之MySQL数据同步到HBase第8张

b).配置SplitJson

Apache NiFi之MySQL数据同步到HBase第9张

Ⅳ).配置PutHBaseJSON

a).选择PutHBaseJSON

在Processor中搜索PutHBaseJSON

Apache NiFi之MySQL数据同步到HBase第10张

b).配置PutHBaseJSON

1.HBase Client Service: 选择匹配版本的HBaseClient
2.Table Name: 配置入库HBase表名
3.Row Identifier Field Name: 配置RowKey值
4.Column Family: 配置列簇

Apache NiFi之MySQL数据同步到HBase第11张

c).选择HBase_1_1_2_ClientService

在Processor中搜索HBase_1_1_2_ClientService

Apache NiFi之MySQL数据同步到HBase第12张

d).配置HBase_1_1_2_ClientService

1.Zookeeper Quorum: hostname1:2181,hostname2:2181,hostname3:2181
2.Zookeeper Client Port: 2181
3.Zookeeper ZNode Parent: /hbase

Apache NiFi之MySQL数据同步到HBase第13张
Apache NiFi之MySQL数据同步到HBase第14张

e).激活HBase_1_1_2_ClientService

Apache NiFi之MySQL数据同步到HBase第15张

Ⅴ).配置LogAttribute

Apache NiFi之MySQL数据同步到HBase第16张

Ⅵ).启动服务

可以点击选择单个Processor启动,也可以在空白处点击流程启动

Apache NiFi之MySQL数据同步到HBase第17张

Ⅶ).验证结果

a).MySQL源数据

select * from druid.druid_datasource;

Apache NiFi之MySQL数据同步到HBase第18张

b).HBase入库数据

scan 'druid.druid_datasource',{LIMIT=>10}

Apache NiFi之MySQL数据同步到HBase第19张

三.HBase命令
## 创建表空间
create_namespace 'druid'
## 查看表空间
list_namespace_tables 'druid'
## 创建表
create 'druid.druid_datasource','cf1'
## 查看表数据
scan 'druid.druid_datasource',{LIMIT=>10}
四.MySQL数据库驱动问题

a).解决方案一

将mysql驱动包放到nifi按照目录的lib中,重启nifi;如图中无需配置:Database Driver Location(s)项

Apache NiFi之MySQL数据同步到HBase第20张

b).解决方案二

如图配置:Database Driver Location(s)项,则驱动包可放在任何可访问的地址,无需重启nifi

Apache NiFi之MySQL数据同步到HBase第4张

免责声明:文章转载自《Apache NiFi之MySQL数据同步到HBase》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Windows Server 2008 R2 安装及配置配置IIS应用程序池下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

mysql的itcast笔记

1 课程回顾 自定义标签&编码实战                             1)自定义标签步骤:                                                1.1 编写标签处理器类,继承SimpleTagSupport类,覆盖doTag方法                             ...

CentOS7安装MySQL8.0图文教程

1.下载 MySQL 所需要的安装包         网址:https://dev.mysql.com/downloads/mysql/   2.Select Operating System: 选择 Red Hat ,CentOS 是基于红帽的,Select OS Version: 选择 linux 7   3.选择 RPM Bundle 点击 Down...

网站报错Access denied for user 'root'@'localhost' -问题排查续

网站报错Access denied for user 'root'@'localhost' (using password: YES) 每次的挽救办法就是: /etc/init.d/mysqld stop mysqld_safe --skip-grant-tables & 几乎每隔10分钟就出现一次,如下图,然后手动安全模式重启mysql。偶...

Druid 集群方式部署 —— 启动服务

启动 Master 服务器 拷贝 Druid 的分发包和你修改过的配置到 Master 服务器上。 如果你已经在你的本地计算机上修改了配置,你可以使用 rsync 来进行拷贝。 rsync -az apache-druid-apache-druid-0.21.1/ MASTER_SERVER:apache-druid-apache-druid-0.21....

java通过jdbc访问mysql,update数据返回值的思考

 先不说那么多,把Java代码贴出来吧。 public static void main(String[] args) throws InterruptedException, IOException { try { DriverManagerDataSource dataSource = new DriverManager...

Apache NiFi之Kafka流数据到HBase

一.说明 在大数据平台的业务场景中,处理实时kafka数据流数据,以成为必要的能力;此篇将尝试通过Apache NiFi来接入Kafka数据然后处理后存储之HBase 二.开拔 Ⅰ).配置ConsumeKafka_0_10 测试使用了kafka0.10版本,所以NiFi中也选择对于版本 a).选择ConsumeKafka_0_10 在Processor...