Flume安装及测试

前置博客

安装telnet

安装

  1. 将apache-flume-1.9.0-bin.tar.gz上传到并解压到linux的/url/local目录下
  2. 将flume/conf下的flume-env.sh.template文件修改为flume-env.sh,并配置flume-env.sh文件
    在这里插入图片描述

测试:

示例:监听指定端口telnet发送来的数据

第一步:在flume目录下创建文件夹job,然后在其下面创建配置文件flume-telnet-logger.conf:

# Name the components on this agent
a1.sources = r1  		# a1表示agent的名称  r1表示a1的输入源
a1.sinks = k1  			# k1表示a1的输出目的地
a1.channels = c1 		#c1表示a1的缓冲区

# Describe/configure the source
a1.sources.r1.type = netcat  		# 表示a1的输入源类型为netcat端口
a1.sources.r1.bind = localhost  	# 表示a1监听的主机为本机
a1.sources.r1.port = 44444 			#表示a1监听的端口

# Describe the sink
a1.sinks.k1.type = logger 			#表示a1输出目的地是控制台logger类型

# Use a channel which buffers events in memory
a1.channels.c1.type = memory 					#表示a1的channel类型是memory内存型
a1.channels.c1.capacity = 100 					#表示a1的channel总容量为100个event
a1.channels.c1.transactionCapacity = 100 		#表示a1的channel传输时收集到了100条event以后再去提交事务

# Bind the source and sink to the channel
a1.sources.r1.channels = c1 		#表示将r1和c1连接起来
a1.sinks.k1.channel = c1 			#表示将k1和c1连接起来

第二步:启动flume

bin/flume-ng agent --conf conf/ --name a1 --conf-file job/flume-telnet-logger.conf -Dflume.root.logger=INFO,console

在这里插入图片描述
参数说明:

  • –conf conf/ :表示配置文件存储在conf/目录
  • –name a1 :表示给agent起名为a1
  • –conf-file job/flume-telnet-logger.conf :flume本次启动读取的配置文件是在job文件夹下的flume-telnet-logger.conf文件。
  • -Dflume.root.logger==INFO,console :-D表示flume运行时动态修改flume.root.logger参数属性值,并将控制台日志打印级别设置为INFO级别。日志级别包括:log、info、warn、error。

第三步:打开新的连接,在其中启动telnet往44444端口发送数据
在这里插入图片描述
发送数据
在这里插入图片描述
在Flume窗口查看到结果:
在这里插入图片描述

发布了407 篇原创文章 · 获赞 798 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/lianghecai52171314/article/details/104887618