Flume监听端口,输出端口数据案例

1、在flume目录下新建/myconf目录,并在目录下新建socket-console.conf 文件!

mkdir myconf
cd myconf
touch socket-console.conf

2、编辑文件vim socket-console.conf,添加以下内容:

# 定义这个agent中各组件的名字
a1.sources = r1
a1.sinks = k1
a1.channels = c1
 
# 描述和配置source组件:r1
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444
 
# 描述和配置sink组件:k1
a1.sinks.k1.type = logger
 
# 描述和配置channel组件,此处使用是内存缓存的方式
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
 
# 描述和配置source  channel   sink之间的连接关系
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

3、运行命令 bin/flume-ng agent --conf conf/ --name a1 --conf-file myconf/socket-console.conf -Dflume.root.logger==INFO,console

其中-Dflume.root.logger==INFO,console的意思是将日志打印在控制台上

4、新建一个终端页面进入44444端口nc localhost 44444,并输入测试信息
在这里插入图片描述
可以看到在flume服务端上已经打印出了相关的信息!!

PS:flume的启动命令可以使用以下两种方式

bin/flume-ng agent --conf conf --conf.file example.conf --name a1 -Dflume.root.logger=INFO,console
bin/flume-ng agent -n $agent_name -c conf -f conf/flume-conf.properties.template
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章