4.flume負載均衡(loadbalance)

master:

]# ./bin/flume-ng agent --conf conf --conf-file ./conf/flume-client.properties_loadbalance --name a1 -Dflume.root.logger=INFO,console

slave1:

]# ./bin/flume-ng agent --conf conf --conf-file ./conf/flume-server.properties --name a1 -Dflume.root.logger=INFO,console

slave2:

]# ./bin/flume-ng agent --conf conf --conf-file ./conf/flume-server.properties --name a1 -Dflume.root.logger=INFO,console

發送數據:

for i in `seq 1 100` ;do echo '====> '$i >> 2.log ;done

結果:負載均衡實現了 數據發送輪訓方式 均勻的發送到sink端

master:

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

# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -f /root/Data/test_data/2.log

# Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = slave1
a1.sinks.k1.port = 52020

a1.sinks.k2.type = avro
a1.sinks.k2.hostname = slave2
a1.sinks.k2.port = 52020

# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

 

# agent1 name
a1.channels = c1
a1.sources = r1
a1.sinks = k1

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

# other node, slave to master
a1.sources.r1.type = avro
a1.sources.r1.bind = slave1
a1.sources.r1.port = 52020

a1.sinks.k1.type = logger

slave2:輸出到控制檯

# agent1 name
a1.channels = c1
a1.sources = r1
a1.sinks = k1

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

# other node, slave to master
a1.sources.r1.type = avro
a1.sources.r1.bind = slave2
a1.sources.r1.port = 52020

a1.sinks.k1.type = logger

a1.sources.r1.channels = c1
a1.sinks.k1.channel=c1

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章