Flume拓扑结构之---------负载均衡模式

Flume拓扑结构之---------负载均衡模式_第1张图片

一、案例需求

Flume拓扑结构之---------负载均衡模式_第2张图片

使用flume-1监控文件变动,flume-1将变动内容传递给flume-2,flume-2负责将数据打印到控制台。同时flume-1将变动内容传递给flume-3,flume-3也负责将数据打印到控制台

二、配置文件

配置1个接收日志文件的source和1个channel、两个sink,分别输送给flume-flume1和flume-flume2。

1、一个channel:flume-netcat-flume.conf

$ touch flume-netcat-flume.conf

配置如下:

注意点有:①有a1.sinkgroups = g1有了这个组的概念a1.sinks = k1 k2这个就是制定两个sink③最后记得在配置一下这个a1.sinkgroups.g1.sinks = k1 k2      ④输出依然是avro模式

# Name the components on this agent
a1.sources = r1
a1.channels = c1
a1.sinkgroups = g1
a1.sinks = k1 k2

# Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444

# round轮训
a1.sinkgroups.g1.processor.type = load_balance
a1.sinkgroups.g1.processor.backoff = true
a1.sinkgroups.g1.processor.selector = round_robin
a1.sinkgroups.g1.processor.selector.maxTimeOut=10000

# Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = hadoop102
a1.sinks.k1.port = 4141

a1.sinks.k2.type = avro
a1.sinks.k2.hostname = hadoop102
a1.sinks.k2.port = 4142

# Describe the channel
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinkgroups.g1.sinks = k1 k2
a1.sinks.k1.channel = c1
a1.sinks.k2.channel = c1

2、一个sink:flume-flume1.conf

配置如下:

# 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.bind = hadoop102
a2.sources.r1.port = 4141

# Describe the sink
a2.sinks.k1.type = logger

# Describe the channel
a2.channels.c1.type = memory
a2.channels.c1.capacity = 1000
a2.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel
a2.sources.r1.channels = c1
a2.sinks.k1.channel = c1

3、一个sink是:flume-flume2.conf

配置如下:

# Name the components on this agent
a3.sources = r1
a3.sinks = k1
a3.channels = c2

# Describe/configure the source
a3.sources.r1.type = avro
a3.sources.r1.bind = hadoop102
a3.sources.r1.port = 4142

# Describe the sink
a3.sinks.k1.type = logger

# Describe the channel
a3.channels.c2.type = memory
a3.channels.c2.capacity = 1000
a3.channels.c2.transactionCapacity = 100

# Bind the source and sink to the channel
a3.sources.r1.channels = c2
a3.sinks.k1.channel = c2

本案例和前几篇总结:只要是在source和sink之间的传输,一定要用avro模式。

你可能感兴趣的:(大数据学习,大数据生态技术)