1)案例需求:
使用 Flume 监听一个端口,收集该端口数据,并打印到控制台。
2)需求分析:
3)实现步骤:
1.安装 netcat 工具
2.判断 44444 端口是否被占用
3.创建 Flume Agent 配置文件 flume-netcat-logger.conf
在 flume 目录下创建 job 文件夹并进入 job 文件夹。
在 job 文件夹下创建 Flume Agent 配置文件 flume-netcat-logger.conf。
在 flume-netcat-logger.conf 文件中添加如下内容。
4. 先开启 flume 监听端口
第一种写法:
第二种写法:
参数说明:
–conf/-c:表示配置文件存储在 conf/目录
–name/-n:表示给 agent 起名为 a1
–conf-file/-f:flume 本次启动读取的配置文件是在 job 文件夹下的 flume-telnet.conf
文件。
-Dflume.root.logger=INFO,console 😄 表示 flume 运行时动态修改 flume.root.logger
参数属性值,并将控制台日志打印级别设置为 INFO 级别。日志级别包括:log、info、warn、 error。
5.使用 netcat 工具向本机的 44444 端口发送内容
6.在 Flume 监听页面观察接收数据情况