五金制品东莞网站建设技术支持,寮步东莞网站建设,成都网站建设今明互联,线上推广的目的一、目的
对于Flume的聚合拓扑结构#xff0c;进行一个开发测试
二、聚合 #xff08;一#xff09;结构含义
这种模式是我们最常见的#xff0c;也非常实用。日常web应用通常分布在上百个服务器#xff0c;大者甚至上千个、上万个服务器产生的日志#xff0c;处理起来…一、目的
对于Flume的聚合拓扑结构进行一个开发测试
二、聚合 一结构含义
这种模式是我们最常见的也非常实用。日常web应用通常分布在上百个服务器大者甚至上千个、上万个服务器产生的日志处理起来也非常麻烦。
二结构特征
用flume的这种组合方式能很好的解决这一问题每台服务器部署一个 flume 采集日志传送到一个集中收集日志的flume再由此flume上传到hdfs、hive、hbase等进行日志分析。
三、需求案例
一案例需求 hurys22 上的 Flume-1 监控文件/opt/flume/group.log hurys23 上的 Flume-2 监控某一个端口的数据流 Flume-1 与 Flume-2 将数据发送给 hurys24 上的 Flume-3Flume-3 将最终数据打印到控制台。 二需求分析 四、前期准备
一在hurys22、hurys23、hurys24上安装好Flume 二在hurys22、hurys23、hurys24上创建测试任务的文件夹group3
[roothurys22 ~]# cd /usr/local/hurys/dc_env/flume/flume190/conf/[roothurys22 conf]# mkdir group3 三在hurys22上创建Flume-1的 监控文件 /opt/flume/group.log
[roothurys22 opt]# cd ./flume/[roothurys22 flume]# touch group.log[roothurys22 flume]# ll 总用量 0 -rw-r--r-- 1 root root 0 12月 13 10:47 group.log 四hurys22、hurys23都可以ssh连接hurys24(192.168.0.24)
1、hurys22 ssh连接192.168.0.24
[roothurys22 ~]# ssh -p22 root192.168.0.24 Last login: Wed Dec 13 10:54:57 2023 from 192.168.9.123 2、hurys23 ssh连接192.168.0.24
[roothurys23 ~]# ssh -p22 root192.168.0.24 Last login: Wed Dec 13 11:10:32 2023 from 192.168.0.22 五、在group3中创建flume的任务文件
一在hurys22创建任务文件 a1 flume1-logger-flume.conf
配置 Source 用于监控 group.log 文件配置 Sink 输出数据到下一级 Flume。
[roothurys22 group3]# vi flume1-logger-flume.conf
# Name the components on this agent a1.sources r1 a1.sinks k1 a1.channels c1
# Describe/configure the source a1.sources.r1.type execa1.sources.r1.command tail -F /opt/flume/group.log a1.sources.r1.shell /bin/bash -c
# Describe the sink a1.sinks.k1.type avroa1.sinks.k1.hostname 192.168.0.24 a1.sinks.k1.port 4141
# 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.sinks.k1.channel c1 注意
1、配置文件中的各项参数需要调式这里只是为了演示实现目的、打通路径即可实际在项目中操作时需要调试参数。
2、a1.sources.r1.command tail -F /opt/flume/group.log 为监控文件的group.log路径
二在hurys23创建任务文件 a2 flume2-netcat-flume.conf
配置 Source 监控端口 44444 数据流配置 Sink 数据到下一级 Flume
[roothurys23 group3]# vi flume2-netcat-flume.conf
# Name the components on this agent a2.sources r1 a2.sinks k1 a2.channels c1
# Describe/configure the source a2.sources.r1.type netcata2.sources.r1.bind hurys23 a2.sources.r1.port 44444
# Describe the sink a2.sinks.k1.type avroa2.sinks.k1.hostname 192.168.0.24 a2.sinks.k1.port 4141
# Use a channel which buffers events in memory a2.channels.c1.type memory a2.channels.c1.capacity 1000 a2.channels.c1.transactionCapacity 100
# Bind the source and sink to the channel a2.sources.r1.channels c1 a2.sinks.k1.channel c1 三在hurys24创建任务文件 a3 flume3-flume-logger.conf
配置 source 用于接收 flume1 与 flume2 发送过来的数据流最终合并后 sink 到控制台。
[roothurys24 group3]# vi flume3-flume-logger.conf
# Name the components on this agent a3.sources r1 a3.sinks k1 a3.channels c1
# Describe/configure the source a3.sources.r1.type avroa3.sources.r1.bind hurys24 a3.sources.r1.port 4141
# Describe the sink a3.sinks.k1.type logger
# Describe the channel a3.channels.c1.type memory a3.channels.c1.capacity 1000 a3.channels.c1.transactionCapacity 100
# Bind the source and sink to the channel a3.sources.r1.channels c1 a3.sinks.k1.channel c1 六、分别启动Flume任务文件
一首先在hurys24启动 a3任务 flume3-flume-logger.conf
[roothurys24 flume190]# bin/flume-ng agent -n a3 -f /usr/local/hurys/dc_env/flume/flume190/conf/group3/flume3-flume-logger.conf 二其次在hurys23启动 a2任务 flume2-netcat-flume.conf
[roothurys23 flume190]# bin/flume-ng agent -n a2 -f /usr/local/hurys/dc_env/flume/flume190/conf/group3/flume2-netcat-flume.conf 三其次在hurys22启动 a1任务 flume1-logger-flume.conf
[roothurys22 flume190]# bin/flume-ng agent -n a1 -f /usr/local/hurys/dc_env/flume/flume190/conf/group3/flume1-logger-flume.conf 七、Flume任务运行执行状况
一hurys22 a1任务运行截图 二hurys23 a2任务运行截图 三hurys24 a3任务运行截图 八、在 hurys22上向/opt/flume/目录下的 group.log 追加内容观察hurys24的控制台打印情况
一在 hurys22上向/opt/flume/目录下的 group.log 追加内容
[roothurys22 group3]# cd /opt/flume/[roothurys22 flume]# echo hello group.log[roothurys22 flume]# echo hello java group.log 二观察hurys24的控制台打印情况 九、在 hurys23上用netcat 工具向 44444 端口发送数据观察hurys24的控制台打印情况
一在 hurys23上用netcat 工具向 44444 端口发送数据
[roothurys23 flume3]# telnet hurys23 44444 Trying fe80::65e8:aec4:9ddc:391%eth0... telnet: connect to address fe80::65e8:aec4:9ddc:391%eth0: Connection refused Trying 192.168.0.23... Connected to hurys23. Escape character is ^]. zhao qian OK sun li OK zhou wu OK zheng wang OK 二观察hurys24的控制台打印情况 Flume的聚合结构案例就到这里吧有点明白了。
把2个Flume的数据聚合到第3个Flume里面然后一起输出这样省的一个个输出。节省功夫