1 官网内容

2 看一张图一目了然

3 详细配置

  source配置文件

  

#配置文件:
a1.sources= r1
a1.sinks= k1 k2
a1.channels= c1 #负载平衡
a1.sinkgroups = g1
a1.sinkgroups.g1.sinks = k1 k2
a1.sinkgroups.g1.processor.type = failover
a1.sinkgroups.g1.processor.priority.k1 = 5
a1.sinkgroups.g1.processor.priority.k2 = 10
a1.sinkgroups.g1.processor.maxpenalty = 1000 #Describe/configure the source
a1.sources.r1.type= exec
a1.sources.r1.command= tail -F /tmp/logs/test.log #Describe the sink
a1.sinks.k1.type= avro
a1.sinks.k1.hostname= 127.0.0.1
a1.sinks.k1.port= 50001 a1.sinks.k2.type= avro
a1.sinks.k2.hostname= 127.0.0.1
a1.sinks.k2.port= 50002 # Usea channel which buffers events in memory
a1.channels.c1.type= memory
a1.channels.c1.capacity= 1000
a1.channels.c1.transactionCapacity= 100 # set channel
a1.sinks.k1.channel= c1
a1.sinks.k2.channel= c1
a1.sources.r1.channels= c1

  sink1配置文件

	# Name the components on this agent
a2.sources = r1
a2.sinks = k1
a2.channels = c1 # Describe/configure the source
a2.sources.r1.type = avro
a2.sources.r1.channels = c1
a2.sources.r1.bind = 127.0.0.1
a2.sources.r1.port = 50001 # Describe the sink
a2.sinks.k1.type = logger
a2.sinks.k1.channel = c1 # Use a channel which buffers events inmemory
a2.channels.c1.type = memory
a2.channels.c1.capacity = 1000
a2.channels.c1.transactionCapacity = 100

  sink2配置

# Name the components on this agent
a3.sources = r1
a3.sinks = k1
a3.channels = c1 # Describe/configure the source
a3.sources.r1.type = avro
a3.sources.r1.channels = c1
a3.sources.r1.bind = 127.0.0.1
a3.sources.r1.port = 50002 # Describe the sink
a3.sinks.k1.type = logger
a3.sinks.k1.channel = c1 # Use a channel which buffers events inmemory
a3.channels.c1.type = memory
a3.channels.c1.capacity = 1000
a3.channels.c1.transactionCapacity = 100

4 启动服务

  

先启动sink1 sink2 再启动source

	flume-ng agent -c conf -f /mnt/software/flume-1.6.0/flume-conf/failOver/sink2.conf -n a3 -Dflume.root.logger=DEBUG,console
flume-ng agent -c conf -f /mnt/software/flume-1.6.0/flume-conf/failOver/sink1.conf -n a2 -Dflume.root.logger=DEBUG,console
flume-ng agent -c conf -f /mnt/software/flume-1.6.0/flume-conf/failOver/load_source_case.conf -n a1 -Dflume.root.logger=DEBUG,console

  5 效果测试

 启动后第一次走了sink2

	   	: /127.0.0.1:42828
19/02/21 23:45:47 INFO sink.LoggerSink: Event: { headers:{} body: 68 61 64 6F 6F 70 hadoop }
19/02/21 23:45:47 INFO sink.LoggerSink: Event: { headers:{} body: 7A 68 61 6E 67 6A 69 6E zhangjin }
19/02/21 23:45:47 INFO sink.LoggerSink: Event: { headers:{} body: 78 78 78 78 xxxx }
19/02/21 23:45:47 INFO sink.LoggerSink: Event: { headers:{} body: 79 79 79 79 yyyy }
19/02/21 23:45:47 INFO sink.LoggerSink: Event: { headers:{} body: 7A 68 61 6E 67 6A 69 6E zhangjin }
19/02/21 23:45:47 INFO sink.LoggerSink: Event: { headers:{} body: 78 78 78 78 xxxx }
19/02/21 23:45:47 INFO sink.LoggerSink: Event: { headers:{} body: 79 79 79 79 yyyy }
19/02/21 23:45:47 INFO sink.LoggerSink: Event: { headers:{} body: 7A 68 61 6E 67 6A 69 6E zhangjin }
19/02/21 23:45:47 INFO sink.LoggerSink: Event: { headers:{} body: 78 78 78 78 xxxx }
19/02/21 23:45:47 INFO sink.LoggerSink: Event: { headers:{} body: 79 79 79 79 yyyy } 挂掉sink2,之后source感知到sink2挂了 Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.jboss.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:148)
at org.jboss.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:104)
at org.jboss.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:78)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:312)
at org.jboss.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:41)
... 3 more 数据发往sink1 19/02/21 23:45:41 INFO ipc.NettyServer: [id: 0x77bfe0b5, /127.0.0.1:47142 => /127.0.0.1:50001] BOUND: /127.0.0.1:50001
19/02/21 23:45:41 INFO ipc.NettyServer: [id: 0x77bfe0b5, /127.0.0.1:47142 => /127.0.0.1:50001] CONNECTED: /127.0.0.1:47142
19/02/21 23:47:14 INFO sink.LoggerSink: Event: { headers:{} body: 7A 68 61 6E 67 6A 69 6E zhangjin }
19/02/21 23:47:14 INFO sink.LoggerSink: Event: { headers:{} body: 78 78 78 78 xxxx }
19/02/21 23:47:14 INFO sink.LoggerSink: Event: { headers:{} body: 79 79 79 79 yyyy }

  6 总结,从效果来看sink2挂了之后,数据发往sink1,实现了失败迁移的功能。

  

Flume配置Failover Sink Processor的更多相关文章

  1. flume配置和说明(转)

    Flume是什么 收集.聚合事件流数据的分布式框架 通常用于log数据 采用ad-hoc方案,明显优点如下: 可靠的.可伸缩.可管理.可定制.高性能 声明式配置,可以动态更新配置 提供上下文路由功能 ...

  2. Flume-Failover Sink Processor 故障转移与 Load balancing Sink 负载均衡

    接上一篇:https://www.cnblogs.com/jhxxb/p/11579518.html 使用 Flume1 监控一个端口,其 sink 组中的 sink 分别对接 Flume2 和 Fl ...

  3. 大数据学习day36-----flume02--------1.avro source和kafka source 2. 拦截器(Interceptor) 3. channel详解 4 sink 5 slector(选择器)6 sink processor

    1.avro source和kafka source 1.1 avro source avro source是通过监听一个网络端口来收数据,而且接受的数据必须是使用avro序列化框架序列化后的数据.a ...

  4. 关于flume配置加载(二)

    为什么翻flume的代码,一方面是确实遇到了问题,另一方面是想翻一下flume的源码,看看有什么收获,现在收获还谈不上,因为要继续总结.不够已经够解决问题了,而且确实有好的代码,后续会继续慢慢分享,这 ...

  5. Flume配置Load balancing Sink Processor

    1 官网内容 2 找一个图来理解一目了然 3 详细配置 配置文件load_source_case.conf 配置数据入口 source到channel 配置了两个sink用来做负载均衡 #配置文件: ...

  6. 第1节 flume:11、flume的failover机制实现高可用

    1.4 高可用Flum-NG配置案例failover 在完成单点的Flume NG搭建后,下面我们搭建一个高可用的Flume NG集群,架构图如下所示: 图中,我们可以看出,Flume的存储可以支持多 ...

  7. flume 配置

    [root@dtpweb data]#tar -zxvf apache-flume-1.7.0-bin.tar.gz[root@dtpweb conf]# cp flume-env.sh.templa ...

  8. 关于flume配置加载

    最近项目在用到flume,因此翻了下flume的代码, 启动脚本: nohup bin/flume-ng agent -n tsdbflume -c conf -f conf/配置文件.conf -D ...

  9. Flume配置Replicating Channel Selector

    1 官网内容 上面的配置是r1获取到的内容会同时复制到c1 c2 c3 三个channel里面 2 详细配置信息 # Name the components on this agent a1.sour ...

随机推荐

  1. Vue--组件嵌套

    1.全局注册: 组件放到components文件夹内,建议组件名是什么行为的name名就是什么 main.js 引入组件:import Users from '组件位置' 注册全局组件:Vue.com ...

  2. (转)轻松学,Java 中的代理模式及动态代理

    背景:讲到反射机制,肯定会想到动态代理. 轻松学,Java 中的代理模式及动态代理 代理模式可以在不修改被代理对象的基础上,通过扩展代理类,进行一些功能的附加与增强.值得注意的是,代理类和被代理类应该 ...

  3. ImageMagickObject.MagickImage.1 '80041771' - 安装vc2008运行库

    今天重装了系统后,发现 ImageMagick 不能正常的使用了: ImageMagickObject.MagickImage.1  '80041771' convert: 455: unable t ...

  4. PHP中防止SQL注入

    防止SQL注入,我们需要注意以下几个要点: 1.永远不要信任用户的输入.对用户的输入进行校验,可以通过正则表达式,或限制长度:对单引号和 双"-"进行转换等. 2.永远不要使用动态 ...

  5. CAS (多线程保证原子性)

    面试必问的CAS,你懂了吗? 置顶 2018年03月14日 22:29:19 程序员囧辉 阅读数:29612   版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csd ...

  6. io系列之常用流一

    一. 读取键盘录入和数据打印 在System类中, System.out: 对应的是标准输出设备(控制台)(一个PrintStream). System.in: 对应的是标准输入设备(键盘)(一个In ...

  7. windows下ngnix+php配置

    1.需要工具: 下载ngnix  网址:http://nginx.org/ 下载:RunHiddenConsole 第二步 将下载文件解压后,将RunHiddenConsole拷贝到ngnix目录与p ...

  8. php解析文本文件呈现在表格上

    name.txt如下 1 | 朱芳 | 18 | b.unyrl@tpwpqt.st | http://XEP.VC 2 | 康丽 | 22 | e.ifmc@fyvutpzio.pro | http ...

  9. Go数据类型和变量

    一:Go数据类型 1.1 Go语言按照分类有以下几种数据类型 布尔型 布尔型的是一个常量true或者false 数字类型 整型int和浮点型 float32, float64 字符串类型 字符串就是一 ...

  10. org.hibernate.MappingException: class com.itheima.domain.Customer.java not found while looking for property: cust_id at org.hibernate.internal.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.

    我这次异常的出现时,没有配置逐渐生成策略.