优秀的网站通过什么提供信息,网站开发设计合同,游戏客户端开发,网页设计培训班一般多少人1. 监控端口数据官方案例 1#xff09;案例需求#xff1a; 使用 Flume 监听一个端口#xff0c;收集该端口数据#xff0c;并打印到控制台。 2#xff09;需求分析#xff1a; 3#xff09;实现步骤#xff1a; #xff08;1#xff09;安装 netcat 工具
sudo yum …1. 监控端口数据官方案例 1案例需求 使用 Flume 监听一个端口收集该端口数据并打印到控制台。 2需求分析 3实现步骤 1安装 netcat 工具
sudo yum install -y nc
2判断 44444 端口是否被占用
sudo netstat -nlp | grep 44444
3创建 Flume Agent 配置文件 flume-netcat-logger.conf 4在 flume 目录下创建 job 文件夹并进入 job 文件夹。
mkdir job
cd job/
5在 job 文件夹下创建 Flume Agent 配置文件 flume-netcat-logger.conf。
touch net-flume-logger.conf
6在 flume-netcat-logger.conf 文件中添加如下内容。
#添加内容如下# Name the components on this agent
a1.sources r1
a1.sinks k1
a1.channels c1
# Describe/configure the source
a1.sources.r1.type netcat
a1.sources.r1.bind localhost
a1.sources.r1.port 44444
# 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
注配置文件来源于官方手册 Flume 1.11.0 User Guide — Apache Flume 同一台机器中不能配置多个相同的a1.事务的容量要比总容量要小也就是说a1.channels.c1.transactionCapacity a1.channels.c1.capacity一个source可以绑定多个channel一个channel只能发到一个sink。
7先开启 flume 监听端口 第一种写法
bin/flume-ng agent -n a1 -c conf/ -f job/net-flume-logger.conf -Dflume.root.loggerINFO,console
第二种写法
bin/flume-ng agent -c conf/ -n a1 -f job/flume-netcat-logger.conf -Dflume.root.loggerINFO,console
参数说明
--conf/-c表示配置文件存储在 conf/目录
--name/-n表示给 agent 起名为 a1
--conf-file/-fflume 本次启动读取的配置文件是在 job 文件夹下的 flume-telnet.conf 文件。
-Dflume.root.loggerINFO,console -D 表示 flume 运行时动态修改 flume.root.logger 参数属性值并将控制台日志打印级别设置为 INFO 级别。日志级别包括:log、info、warn、 error。 8使用 netcat 工具向本机的 44444 端口发送内容
nc localhost 44444
9在 Flume 监听页面观察接收数据情况