1. 概述

source -> channel -> sink
(nc) -> channel -> (logger)

2. 案例实操

2.1 配置文件

  1. job/ 目录 vi net-flume-logger.conf文件 ```shell

    example.conf: A single-node Flume configuration

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

  1. <a name="aYf6u"></a>
  2. ## 2.2 管理命令
  3. <a name="qGOtI"></a>
  4. ### 1. 启动服务端
  5. ```shell
  6. flume-1.9.0 > bin/flume-ng agent -n a1 -c conf/ -f job/net-flume-logger.conf -Dflume.root.logger=INFO,console

image.png

2. 测试

  1. 另启一个窗口(客户端),并使用 nc localhost 44444 来创建客户端链接
  2. 客户端输入内容:

    1. flume > nc localhost 44444
    2. hello world
    3. OK
  3. 服务端收到内容并打印出:

image.png