Flume连接oracle实时推送数据到kafka
版本号:
flume安装
kafka安装
1、下载flume-ng-sql-source-1.4.3.jar
CSDN下载地址:http://download.csdn.net/detail/chongxin1/9892184
flume-ng-sql-source-1.4.3.jar是flume用于连接数据库的重要支撑jar包。
2、把flume-ng-sql-source-1.4.3.jar放到flume的lib目录下
3、把oracle(此处用的是oracle库)的驱动包放到flume的lib目录下
oracle的jdbc驱动包,放在oracle安装目录下,路径为:D:\app\product\11.2.0\dbhome_1\jdbc\lib
如图:
把ojdbc5.jar放到flume的lib目录下,如图:
4、新建flume-sql.conf
- touch /usr/local/flume/apache-flume-1.6.0-bin/conf/flume-sql.conf
- sudo gedit /usr/local/flume/apache-flume-1.6.0-bin/conf/flume-sql.conf
- agentOne.channels = channelOne
- agentOne.sources = sourceOne
- agentOne.sinks = sinkOne
- ###########sql source#################
- # For each one of the sources, the type is defined
- agentOne.sources.sourceOne.type = org.keedio.flume.source.SQLSource
- agentOne.sources.sourceOne.hibernate.connection.url = jdbc:oracle:thin:@192.168.168.100:1521/orcl
- # Hibernate Database connection properties
- agentOne.sources.sourceOne.hibernate.connection.user = flume
- agentOne.sources.sourceOne.hibernate.connection.password = 1234
- agentOne.sources.sourceOne.hibernate.connection.autocommit = true
- agentOne.sources.sourceOne.hibernate.dialect = org.hibernate.dialect.Oracle10gDialect
- agentOne.sources.sourceOne.hibernate.connection.driver_class = oracle.jdbc.driver.OracleDriver
- agentOne.sources.sourceOne.run.query.delay=10000
- agentOne.sources.sourceOne.status.file.path = /tmp
- agentOne.sources.sourceOne.status.file.name = sqlSource.status
- # Custom query
- agentOne.sources.sourceOne.start.from = 0
- agentOne.sources.sourceOne.custom.query = select sysdate from dual
- agentOne.sources.sourceOne.batch.size = 1000
- agentOne.sources.sourceOne.max.rows = 1000
- agentOne.sources.sourceOne.hibernate.connection.provider_class = org.hibernate.connection.C3P0ConnectionProvider
- agentOne.sources.sourceOne.hibernate.c3p0.min_size=1
- agentOne.sources.sourceOne.hibernate.c3p0.max_size=10
- ##############################
- agentOne.channels.channelOne.type = memory
- agentOne.channels.channelOne.capacity = 10000
- agentOne.channels.channelOne.transactionCapacity = 10000
- agentOne.channels.channelOne.byteCapacityBufferPercentage = 20
- agentOne.channels.channelOne.byteCapacity = 800000
- agentOne.sinks.sinkOne.type = org.apache.flume.sink.kafka.KafkaSink
- agentOne.sinks.sinkOne.topic = test
- agentOne.sinks.sinkOne.brokerList = 192.168.168.200:9092
- agentOne.sinks.sinkOne.requiredAcks = 1
- agentOne.sinks.sinkOne.batchSize = 20
- agentOne.sinks.sinkOne.channel = channelOne
- agentOne.sinks.sinkOne.channel = channelOne
- agentOne.sources.sourceOne.channels=channelOne
5、flume-ng启动flume-sql.conf和测试
- cd /usr/local/flume/apache-flume-1.6.0-bin
- bin/flume-ng agent --conf conf --conf-file conf/flume-sql.conf --name agentOne -Dflume.root.logger=INFO,console
运行成功日志如下:
- 2017-07-08 00:12:55,393 (lifecycleSupervisor-1-1) [INFO - org.apache.flume.instrumentation.MonitoredCounterGroup.register(MonitoredCounterGroup.java:120)] Monitored counter group for type: SINK, name: sinkOne: Successfully registered new MBean.
- 2017-07-08 00:12:55,394 (lifecycleSupervisor-1-1) [INFO - org.apache.flume.instrumentation.MonitoredCounterGroup.start(MonitoredCounterGroup.java:96)] Component type: SINK, name: sinkOne started
- 2017-07-08 00:12:55,463 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - kafka.utils.Logging$class.info(Logging.scala:68)] Fetching metadata from broker id:0,host:localhost,port:9092 with correlation id 0 for 1 topic(s) Set(test)
- 2017-07-08 00:12:55,528 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - kafka.utils.Logging$class.info(Logging.scala:68)] Connected to localhost:9092 for producing
- 2017-07-08 00:12:55,551 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - kafka.utils.Logging$class.info(Logging.scala:68)] Disconnecting from localhost:9092
- 2017-07-08 00:12:55,582 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - kafka.utils.Logging$class.info(Logging.scala:68)] Connected to slave2:9092 for producing
启动kafka的消费者,监听topic主题:
- kafka-console-consumer.sh --zookeeper localhost:2181 --topic test
运行成功日志如下:
- [root@master kafka_2.11-0.9.0.0]# kafka-console-consumer.sh --zookeeper localhost:2181 --topic test
- "2017-07-08 00:28:53.0"
- "2017-07-08 00:29:03.0"
- "2017-07-08 00:29:13.0"
- "2017-07-08 00:29:23.0"
- "2017-07-08 00:29:33.0"
- "2017-07-08 00:29:43.0"
- "2017-07-08 00:29:53.0"
- "2017-07-08 00:30:03.0"
6、常见报错解决办法
- 2017-06-27 16:26:01,293 (C3P0PooledConnectionPoolManager[identityToken->1hgey889o1sjxqn51anc3fr|29938ba5]-AdminTaskTimer) [WARN - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector.run(ThreadPoolAsynchronousRunner.java:759)] com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@2d6227f3 -- APPARENT DEADLOCK!!! Complete Status:
Flume连接oracle实时推送数据到kafka的更多相关文章
- 使用SignalR ASP.NET Core来简单实现一个后台实时推送数据给Echarts展示图表的功能
什么是 SignalR ASP.NET Core ASP.NET Core SignalR 是一种开放源代码库,可简化将实时 web 功能添加到应用程序的功能. 实时 web 功能使服务器端代码可以立 ...
- Spring MVC 实现web Socket向前端实时推送数据
最近项目中用到了webSocket服务,由后台实时向所有的前端推送消息,前端暂时是不可以发消息给后端的,数据的来源是由具体的设备数据收集器收集起来,然后通过socket推送给后端,后端收到数据后,再将 ...
- 基于HTTP协议之WEB消息实时推送技术原理及实现
很早就想写一些关于网页消息实时推送技术方面的文章,但是由于最近实在忙,没有时间去写文章.本文主要讲解基于 HTTP1.1 协议的 WEB 推送的技术原理及实现.本人曾经在工作的时候也有做过一些用到网页 ...
- 服务器端实时推送技术之SseEmitter的用法
这是SpringMVC提供的一种技术,可以实现服务端向客户端实时推送数据.用法非常简单,只需要在Controller提供一个接口,创建并返回SseEmitter对象,发送数据可以在另一个接口调用其se ...
- WebSocket和kafka实现数据实时推送到前端
一. 需求背景 最近新接触一个需求,需要将kafka中的数据实时推送到前端展示.最开始想到的是前端轮询接口数据,但是无法保证轮询的频率和消费的频率完全一致,或造成数据缺失等问题.最终确定用利 ...
- 用node.js(socket.io)实现数据实时推送
在做商品拍卖的时候,要求在商品的拍卖页面需要实时的更新当前商品的最高价格.实现的方式有很多,比如: 1.setInterval每隔n秒去异步拉取数据(缺点:更新不够实时) 2. AJAX轮询方式方式推 ...
- SpringBoot2.0整合WebSocket,实现后端数据实时推送!
之前公司的某个系统为了实现推送技术,所用的技术都是Ajax轮询,这种方式浏览器需要不断的向服务器发出请求,显然这样会浪费很多的带宽等资源,所以研究了下WebSocket,本文将详细介绍下. 一.什么是 ...
- Springboot:SpringBoot2.0整合WebSocket,实现后端数据实时推送!
一.什么是WebSocket? B/S结构的软件项目中有时客户端需要实时的获得服务器消息,但默认HTTP协议只支持请求响应模式,这样做可以简化Web服务器,减少服务器的负担,加快响应速度,因为服务器不 ...
- Flume推送数据到SparkStreaming案例实战和内幕源码解密
本期内容: 1. Flume on HDFS案例回顾 2. Flume推送数据到Spark Streaming实战 3. 原理绘图剖析 1. Flume on HDFS案例回顾 上节课要求大家自己安装 ...
随机推荐
- python day17面向对象-组合
组合: 给一个类的对象封装一个属性,这个属性是另一个类的对象. class GameRole: def __init__(self, name, ad, hp): self.name = name s ...
- [翻译]60,000毫秒内对Linux进行性能诊断
原文链接:http://techblog.netflix.com/2015/11/linux-performance-analysis-in-60s.html 原文作者:Brendan Gregg,L ...
- url的反向解析
1. url的语法格式: url(regex, views, **kwargs, name) name:为地址起别名,反向解析时使用 2.反向解析 对于Django中的url反向解析,是分模板和视图的 ...
- Failed to start component [StandardEngine[Catalina].stadardHost[loclahost].StandardContent[/GarageMgtB]]
错误如图: 新导入的一个web工程,在problems中显示错误是:Target runtime Apache Tomcatv8.0 is not defined. 终于找到解决方法.方法是:在工程目 ...
- js 关于本地文件的处理
https://developer.mozilla.org/zh-CN/docs/Web/API/File/Using_files_from_web_applications
- Sublime text3常用的插件功能和常用的快捷键
Sublime text3常用的插件功能和用法 Package control 插件管理 (使用ctrl+` 将代码复制后粘贴到代码粘贴处,按Enter没有出现错误的话就安装成功了)(ctrl+shi ...
- hdu 1556 A - Color the ball 数状数组做法
#include<bits/stdc++.h> using namespace std; ; int n; int c[maxn]; int lowbit(int x) { return ...
- js中将一个字一个字的打印出来
第一种方式: setTimeout(function(){ var cc=document.createTextNode(ss[i]) content.appendChild(cc) },3000)
- Go Example--结构体
package main import "fmt" //定义一个私有结构体 type person struct { name string age int } func main ...
- 【java编程】java中什么是bridge method(桥接方法)
https://blog.csdn.net/mhmyqn/article/details/47342577 https://www.cnblogs.com/strinkbug/p/5019453.ht ...