宁波做网站多少钱,装修公司加盟品牌排行榜,win8网站模版,无锡网站建设制作在哪里可以Flume概述
Flume 定义
Flume 是 Cloudera 提供的一个高可用的#xff0c;高可靠的#xff0c;分布式的海量日志采集、聚合和传输的系统。Flume 基于流式架构#xff0c;灵活简单。 Flume最主要的作用就是#xff0c;实时读取服务器本地磁盘的数据#xff0c;将数据写入到…Flume概述
Flume 定义
Flume 是 Cloudera 提供的一个高可用的高可靠的分布式的海量日志采集、聚合和传输的系统。Flume 基于流式架构灵活简单。 Flume最主要的作用就是实时读取服务器本地磁盘的数据将数据写入到HDFS。
Flume 基础架构 Agent
Agent 是一个 JVM 进程它以事件的形式将数据从源头送至目的。 Agent 主要有 3 个部分组成Source、Channel、Sink。
Source
Source 是负责接收数据到 Flume Agent 的组件。Source 组件可以处理各种类型、各种格式的日志数据包括 avro、thrift、exec、jms、spooling directory、netcat、taildir、sequence generator、syslog、http、legacy。
Sink
Sink 不断地轮询 Channel 中的事件且批量地移除它们并将这些事件批量写入到存储或索引系统、或者被发送到另一个 Flume Agent。 Sink 组件目的地包括 hdfs、logger、avro、thrift、ipc、file、HBase、solr、自定 义。
Channel
Channel 是位于 Source 和 Sink 之间的缓冲区。因此Channel 允许 Source 和 Sink 运作在不同的速率上。Channel 是线程安全的可以同时处理几个 Source 的写入操作和几个Sink 的读取操作。 Flume 自带两种 ChannelMemory Channel 和 File Channel。 Memory Channel 是内存中的队列。Memory Channel 在不需要关心数据丢失的情景下适用。如果需要关心数据丢失那么 Memory Channel 就不应该使用因为程序死亡、机器宕 机或者重启都会导致数据丢失。 File Channel 将所有事件写到磁盘。因此在程序关闭或机器宕机的情况下不会丢失数 据。
Flume 安装部署
解压
[rootguo146 install]# tar -zxf apache-flume-1.9.0-bin.tar.gz -C ../soft/修改名称
[rootguo146 soft]# mv apache-flume-1.9.0-bin/ flume190修改配置文件
[rootguo146 conf]# cp flume-env.sh.template flume-env.sh
[rootguo146 conf]# vim flume-env.sh修改内容如下 安装
[rootguo146 conf]# yum install -y nc
[rootguo147 conf]# yum install telnet-server -y
[rootguo147 conf]# yum install telnet.* -y测试
[rootguo147 conf]# nc -lk 8888再打开一个窗口
[rootguo147 ~]# telnet guo147 8888使用 Flume 监听一个端口收集该端口数据并打印到控制台
在 conf 文件夹下创建 Flume Agent 配置文件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 192.168.153.147
a1.sources.r1.port 8888# 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配置文件解析 开启 flume 监听端口
[rootguo147 flume190]# bin/flume-ng agent --conf ./conf/ --name a1 --conf-file ./conf/netcat-logger.conf -Dflume.root.loggerINFO,console参数说明 –conf/-c表示配置文件存储在 conf/目录 –name/-n表示给 agent 起名为 a1 –conf-file/-fflume 本次启动读取的配置文件是在 job 文件夹下的 flume-telnet.conf 文件。 -Dflume.root.loggerINFO,console -D 表示 flume 运行时动态修改 flume.root.logger 参数属性值并将控制台日志打印级别设置为 INFO 级别。日志级别包括:log、info、warn、 error。 使用 netcat 工具向本机的 8888 端口发送内容
[rootguo147 conf]# telnet 192.168.153.147 8888输入aa回车bb