日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無(wú)先后,達(dá)者為師

網(wǎng)站首頁(yè) 編程語(yǔ)言 正文

flume的負(fù)載均衡load balancer

作者:FOX有愛(ài) 更新時(shí)間: 2022-05-20 編程語(yǔ)言

????????負(fù)載均衡是用于解決一臺(tái)機(jī)器(一個(gè)進(jìn)程)無(wú)法解決所有請(qǐng)求而產(chǎn)生的一種算法。Load balancing Sink Processor 能夠?qū)崿F(xiàn) load balance 功能,如下圖Agent1 是一個(gè)路由節(jié)點(diǎn),負(fù)責(zé)將 Channel 暫存的 Event 均衡到對(duì)應(yīng)的多個(gè) Sink組件上,而每個(gè) Sink 組件分別連接到一個(gè)獨(dú)立的 Agent 上,示例配置,如下所示:

在此處我們通過(guò)三臺(tái)機(jī)器來(lái)進(jìn)行模擬flume的負(fù)載均衡
三臺(tái)機(jī)器規(guī)劃如下:
node01:采集數(shù)據(jù),發(fā)送到node02和node03機(jī)器上去
node02:接收node01的部分?jǐn)?shù)據(jù)
node03:接收node01的部分?jǐn)?shù)據(jù)

一、開(kāi)發(fā)配置node01服務(wù)器的flume配置

node01服務(wù)配置:

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin/conf
vim load_banlancer_client.conf

#agent name
a1.channels = c1
a1.sources = r1
a1.sinks = k1 k2

#set gruop
a1.sinkgroups = g1

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

a1.sources.r1.channels = c1
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /export/servers/taillogs/access_log

# set sink1
a1.sinks.k1.channel = c1
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = node02
a1.sinks.k1.port = 52020

# set sink2
a1.sinks.k2.channel = c1
a1.sinks.k2.type = avro
a1.sinks.k2.hostname = node03
a1.sinks.k2.port = 52020

#set sink group
a1.sinkgroups.g1.sinks = k1 k2

#set failover
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

二、開(kāi)發(fā)node02服務(wù)器的flume配置

node02服務(wù)配置:

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin/conf
vim load_banlancer_server.conf

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

# Describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.channels = c1
a1.sources.r1.bind = node02
a1.sources.r1.port = 52020

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

# Use a channel which buffers events in memory
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.sinks.k1.channel = c1

三、開(kāi)發(fā)node03服務(wù)器flume配置

node03服務(wù)配置:

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin/conf
vim load_banlancer_server.conf

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

# Describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.channels = c1
a1.sources.r1.bind = node03
a1.sources.r1.port = 52020

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

# Use a channel which buffers events in memory
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.sinks.k1.channel = c1

四、準(zhǔn)備啟動(dòng)flume服務(wù)

啟動(dòng)node03的flume服務(wù)

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin
bin/flume-ng agent -n a1 -c conf -f conf/load_banlancer_server.conf -Dflume.root.logger=DEBUG,console

啟動(dòng)node02的flume服務(wù)

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin
bin/flume-ng agent -n a1 -c conf -f conf/load_banlancer_server.conf -Dflume.root.logger=DEBUG,console

啟動(dòng)node01的flume服務(wù)

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin
bin/flume-ng agent -n a1 -c conf -f conf/load_banlancer_client.conf -Dflume.root.logger=DEBUG,console

五、node01服務(wù)器運(yùn)行腳本產(chǎn)生數(shù)據(jù)

cd /export/servers/shells
sh tail-file.sh

原文鏈接:https://blog.csdn.net/qq_15083919/article/details/121710943

欄目分類
最近更新