1. 程式人生 > >flume負載均衡版配置

flume負載均衡版配置

flume負載均衡的意思:由node01 傳送資料給node02 和node03 ,由他們倆分別輪詢接收訊息

設定node01,在flume安裝包的conf目錄下新建load_balancer.conf

#命名
a1.sources = r1
a1.channels = c1
a1.sinks = k1 k2

#設定資源
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /export/servers/taillogs/access_log

#設定通道channels
a1.channels.c1.type = memory
a1.channels.c1.capatity = 1000
a1.channels.c1.transactionCapacity = 100

#設定sink1
a1.sinks.k1.type=avro
a1.sinks.k1.hostname=node02
a1.sinks.k1.port=52020

#設定sink2
a1.sinks.k2.type=avro
a1.sinks.k2.hostname=node03
a1.sinks.k2.port=52020

#關係
a1.sources.r1.channels=c1
a1.sinks.k1.channel=c1
a1.sinks.k2.channel=c1

#設定proceecing
a1.sinkgroups=g1
a1.sinkgroups.g1.sinks=k1 k2
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=1000

 

設定node02 ,新建load_banlancer_server.conf

#命名
a1.sources = r1
a1.sinks = k1
a1.channels = c1

#資源
a1.sources.r1.type = avro
a1.sources.r1.bind = node02
a1.sources.r1.port = 52020

# sink
a1.sinks.k1.type = logger

#通道
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# 連線
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

 

設定node02 ,新建load_banlancer_server.conf

#命名
a1.sources = r1
a1.sinks = k1
a1.channels = c1

#資源
a1.sources.r1.type = avro
a1.sources.r1.bind = node03
a1.sources.r1.port = 52020

# sink
a1.sinks.k1.type = logger

#通道
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# 連線
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

 

分別開啟node02 node03 和node01

bin/flume-ng agent -n a1 -c conf -f conf/load_banlancer_server.conf -Dflume.root.logger=DEBUG,console

 

往node01的/export/servers/taillogs/access_log追加資料看node02 和node03的變化

結果如下,數字都是位元組流