需求: 将131上产生的日志文件负载均衡到 132 和133机器上
如图:
配置132 机器和133机器 (相同))
arov.conf
a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = avro a1.sources.r1.bind =0.0.0.0 a1.sources.r1.port =41414 # 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
启动132 和133 该flume进程 命令 注意一定要先启动不然在131访问的时候会说连接被拒绝
bin/flume-ng agent --name a1 --conf-file conf/avro.conf --conf conf/ -Dflume.root.logger=INFO,console -Dflume.monitoring.type=http -Dflume.monitoring.port=34343 &
配置131机器的flume
load_balance.conf
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 /opt/test.log # Describe the sink 1 a1.sinks.k1.type = avro a1.sinks.k1.hostname=192.168.13.132 a1.sinks.k1.port=41414 # Describe the sink 2 a1.sinks.k2.type = avro a1.sinks.k2.hostname=192.168.13.133 a1.sinks.k2.port=41414 # 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 a1.sinks.k2.channel = c1
启动命令
bin/flume-ng agent --name a1 --conf-file conf/load_balance.conf --conf conf/ -Dflume.root.logger=INFO,console &
测试:
在131机器上创建文件
执行命令查看132 和133机器上收到的信息.是否负载成功
echo ‘adddl‘ >> /opt/test.log
时间: 2024-11-13 06:56:24