上下游配置文件
上游
##定义a1的三个组件的名称 a1.sources = r1 a1.sinks = k1 a1.channels = c1
##定义Source的类型 a1.sources.r1.channels = c1 a1.sources.r1.type = TAILDIR a1.sources.r1.filegroups = g1 a1.sources.r1.filegroups.g1 = /var/logdata/whh_online_data.* a1.sources.r1.batchSize = 5000
##定义Channel的类型 a1.channels.c1.type = file a1.channels.c1.checkpointDir = /opt/data/flume-data/checkpoint/ a1.channels.c1.dataDir = /opt/data/flume-data/data/ a1.channels.c1.transactionCapacity = 10000
##定义Sink的类型 a1.sinks.k1.channel = c1 a1.sinks.k1.type = AVRO a1.sinks.k1.hostname = node03 a1.sinks.k1.port = 4646
下游
两个下游(node03)
# 命名此代理上的组件 a2.sources = r1 a2.sinks = k1 a2.channels = c1
#描述/配置源 a2.sources.r1.channels = c1 a2.sources.r1.type = avro a2.sources.r1.bind = node03 a2.sources.r1.port = 4646
#使用在内存中缓冲事件的通道 a2.channels.c1.type = file a2.channels.c1.checkpointDir = /opt/data/flume-data/checkpoint/ a2.channels.c1.dataDir = /opt/data/flume-data/data/ a2.channels.c1.transactionCapacity = 10000
#描述接收器 a2.sinks.k1.channel = c1 a2.sinks.k1.type = HDFS a2.sinks.k1.hdfs.path = hdfs://hdfs-whh/logdata/applog/%Y-%m-%d/ a2.sinks.k1.hdfs.filePrefix = whh- a2.sinks.k1.hdfs.fileSuffix = .log.snappy a2.sinks.k1.hdfs.rollInterval = 300 a2.sinks.k1.hdfs.rollSize = 104857600 a2.sinks.k1.hdfs.rollCount = 100 a2.sinks.k1.hdfs.fileType = CompressedStream a2.sinks.k1.hdfs.codeC = snappy a2.sinks.k1.hdfs.useLocalTimeStamp = false
启动命令
服务端:node03 bin/flume-ng agent -n a2 -c conf/ -f myconf/avro_2_hdfs.conf -Dflume.root.logger=INFO,console ? ? 将日志打印到控制台在命令后面加入-Dflume.root.logger=INFO,console
客户端:node01,node02 bin/flume-ng agent -n a1 -c conf/ -f myconf/file_2_avro.conf
后台启动: nohup bin/flume-ng agent -n a2 -c conf/ -f myconf/file_2_avro.conf 1>/dev/null 2>&1 &
查看状态 bin/flume-ng agent -n a2 -c conf/ -f myconf/avro_2_hdfs.conf -Dflume.monitoring.type=http -Dflume.monitoring.port=34545
bin/flume-ng agent -n a2 -c conf/ -f myconf/avro_2_hdfs.conf -Dflume.root.logger=INFO,console -Dflume.monitoring.type=http -Dflume.monitoring.port=34545
上游: 先在flume目录下创建文件 myconf,在myconf目录下配置文件vim file_2_avro.conf
下游 先在flume目录下创建文件myconf,在myconf目录下配置文件vim avro_2_hdfs.conf
启动时,因为数据存放到hdfs中,所以先把hadoop集群启动,随后启动服务端, 启动客户端,开启数据。
|