## 配置信息 ## 文件名 example-netcat.conf a1.sources = r1 a1.sinks = k1 a1.channels = c1 a1.sources.r1.type = netcat a1.sources.r1.bind = localhost a1.sources.r1.port = 7000 a1.sinks.k1.type = logger a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 a1.sources.r1.channels = c1 a1.sinks.k1.channel = c1
flume-ng agent -n a1 -c /opt/bdsp/apache-flume-1.6.0-bin/conf/ -f /opt/bdsp/conf/flume/example-netcat.conf -Dflume.root.logger=INFO,console
telnet localhost 7000
## nodez001 ## 文件名 example-avro_node1.conf a1.sources = r1 a1.sinks = k1 a1.channels = c1 a1.sources.r1.type = cmd a1.sources.r1.command = tail -F /root/flume.txt a1.sinks.k1.type = avro a1.sinks.k1.hostname = nodez002 a1.sinks.k1.port = 45454 a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 a1.sources.r1.channels = c1 a1.sinks.k1.channel = c1 ## nodez002 ## example-avro_node2.conf a2.sources = r1 a2.sinks = k1 a2.channels = c1 a2.sources.r1.type = avro a2.sources.r1.hostname = nodez002 a2.sources.r1.port = 45454 a2.sinks.k1.type = logger a2.channels.c1.type = memory a2.channels.c1.capacity = 1000 a2.channels.c1.transactionCapacity = 100 a2.sources.r1.channels = c1
## nodez002上执行 flume-ng agent -n a2 -c /opt/bdsp/apache-flume-1.6.0-bin/conf/ -f /opt/bdsp/conf/flume/example-avro_node2.conf -Dflume.root.logger=INFO,console ## nodez001上执行 flume-ng agent -n a1 -c /opt/bdsp/apache-flume-1.6.0-bin/conf/ -f /opt/bdsp/conf/flume/example-avro_node1.conf
## nodez001 echo "xxxx" >> /root/flume.txt # 查看nodez001 界面
## example-dir.conf a1.sources = r1 a1.sinks = k1 a1.channels = c1 a1.sources.r1.type = spooldir a1.sources.r1.spoolDir = /opt/bdsp/logs a1.sources.r1.fileHeader = true a1.sinks.k1.type = logger a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 a1.sources.r1.channels = c1 a1.sinks.k1.channel = c1
## nodez002上执行 flume-ng agent -n a1 -c /opt/bdsp/apache-flume-1.6.0-bin/conf/ -f /opt/bdsp/conf/flume/example-dir.conf -Dflume.root.logger=INFO,console
mv xxx.txt /opt/bdsp/logs/ # 移动文件到指定位置 观察窗口变化
## example-hdfs.conf a1.sources = r1 a1.sinks = k1 a1.channels = c1 a1.sources.r1.type = spooldir a1.sources.r1.spoolDir = /opt/bdsp/logs a1.sources.r1.fileHeader = true a1.sinks.k1.type = hdfs a1.sinks.k1.hdfs = hdfs://bdsp/flume/%y-%m-%d/%H%M ##每隔60秒或者文件大小超过10M的时候产生新文件 ##hdfs有多少消息是新建文件,0不基于消息个数 a1.sinks.k1.hdfs.rollCount = 0 ##hdfs创建多长时间新建文件,0不基于时间 a1.sinks.k1.hdfs.rollInterval = 60 ##hdfs多大时创建新建文件,0不基于文件带下 a1.sinks.k1.hdfs.rollSize = 10240 ##当目前被打开的临时文件在改参数指定时间(秒)内,没有目标文件 a1.sinks.k1.hdfs.idleTimeout = 3 a1.sinks.k1.hdfs.fileType = DataStream a1.sinks.k1.hdfs.useLocalTimeStamp = true ##每五分钟生产一个目录 ##是够启用时间上的舍弃,这里的舍弃,类似于四舍五入所有时间表达式 a1.sinks.k1.hdfs.round = true ##时间上进行舍弃的值 a1.sinks.k1.hdfs.roundValue = 5 ##时间上舍弃的单位,包含second,minute,hour a1.sinks.k1.hdfs.roundUnit = minute a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 a1.sources.r1.channels = c1 a1.sinks.k1.channel = c1
flume-ng agent -n a1 -c /opt/bdsp/apache-flume-1.6.0-bin/conf/ -f /opt/bdsp/conf/flume/example-hdfs.conf
mv xxx.txt /opt/bdsp/logs/ # 移动文件到指定位置 观察 hdfs://bdsp/flume 文件夹
如果有谬误,请指出来,希望共同学习,共同进步,day day up!