获取channel保存的数据并进行处理。sink从channel中移除事件并将其发送到下一个agent(即下一跳)或最终存储,如HDFS。
2.6、可靠性
事件在每个agent的channel中短暂存储,,之后事件被发送到下一个agent或者最终存储中。时间只有在存储在下一个agent或最终存储后才会从当前channel中删除。
flume使用事务的办法来保证事件的可靠传递。source和sink分别被封装到事务中,事务一般有channel提供,从而保证数据传输的可靠。在多个agent(多跳)中,上一跳的sink和下一跳的source都运行事务来保证数据的可靠性。
3、安装、使用(1.9.0版本)
下载地址:https://flume.apache.org/download.html
文档地址:https://flume.apache.org/releases/content/1.9.0/FlumeUserGuide.html
解压后删除lib目录下的guava-11.0.2.jar,防止和hadoop不兼容。
3.1、监听数据
步骤:
- 通过netcat向55555端口发送数据
- flume监控55555端口并通过source读取数据
- flume将读取到的数据通过sink写到控制台
操作:
- 安装netcat
sudo yum install -y nc
- 查看端口占用
netstat -nlp|grep 55555
- 新建job文件夹,编写flume-netcat-logger.conf文件
[root@hadoop101 apache-flume-1.11.0-bin]# mkdir job
[root@hadoop101 apache-flume-1.11.0-bin]# mkdir job
vim 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 = 55555
# Describe the sink
a1.sinks.k1.type =