大数据全系列 教程
1869个小节阅读:464.7k
目录
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
案例实战
node1(Flume1)上添加配置文件failover_sink.conf
xxxxxxxxxx
[root@node1 jobs]# vim loadbalance_sink.conf
# Name the components on this agent
a1.sources = r1
a1.channels = c1
#配置sinkgroups
a1.sinkgroups = g1
a1.sinks = k1 k2
# Describe/configure the source
# 指定sources.r1类型
a1.sources.r1.type = exec
# 指定对应的命令
a1.sources.r1.command = tail -F /usr/local/nginx/logs/access.log
# 指定解释上面命令的命令解释器是谁
a1.sources.r1.shell = /bin/bash -c
# 一批数据的数量:从Source到putList
a1.sources.r1.batchSize = 3
# 批的实效时间 单位为毫秒
a1.sources.r1.batchTimeout = 5000
# 指定sinkgroups为负载均衡
a1.sinkgroups.g1.processor.type = load_balance
a1.sinkgroups.g1.processor.backoff = true
a1.sinkgroups.g1.processor.selector = random
# Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = node2
a1.sinks.k1.port = 10020
a1.sinks.k2.type = avro
a1.sinks.k2.hostname = node3
a1.sinks.k2.port = 10020
# 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
node2上复制avro-logger.conf为failover.conf
xxxxxxxxxx
[root@node2 jobs]# cp avro-logger.conf loadbalance.conf
node2上修改failover.conf
xxxxxxxxxx
[root@node2 jobs]# vim loadbalance.conf
# 指定监听服务器的端口号
a1.sources.r1.port = 10086
#该为如下
a1.sources.r1.port = 10020
node3上复制avro-logger.conf为failover.conf
xxxxxxxxxx
[root@node3 jobs]# cp avro-logger.conf loadbalance.conf
node3上修改failover.conf
xxxxxxxxxx
[root@node3 jobs]# vim loadbalance.conf
# 指定监听服务器的端口号
a1.sources.r1.port = 10086
#该为如下
a1.sources.r1.port = 10020
先启动node2和node3上的flume
xxxxxxxxxx
[root@node2 jobs]# flume-ng agent -c ./ -n a1 -f loadbalance.conf -Dflume.root.logger=INFO,console
[root@node3 jobs]# flume-ng agent -c ./ -n a1 -f loadbalance.conf -Dflume.root.logger=INFO,console
再启动node1上的flume
xxxxxxxxxx
[root@node1 jobs]# flume-ng agent -c ./ -n a1 -f loadbalance_sink.conf -Dflume.root.logger=INFO,console
如果Nginx没有启动,则启动nginx。
打开浏览器不断访问nginx页面:http://node1/index=1 ,每次访问index的值加1。
查看Flume2及Flume3的控制台打印日志