Flume+SparkStreaming(SparkSQL)+Kafka+Mysql
使用flume采集文件数据,发送至kafka,再由SparkStreaming消费kafka消息,使用sparkSql对数据进行处理,结果数据保存到Mysql数据库。使用三台虚拟机完成测试,集群搭建配置就不赘述了。
Flume:
文件名: flume2Kafka.conf
#定义了当前agent的名字叫做a1
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /data/0000.unl
a1.sources.r1.shell=/bin/sh -c
# Describe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.topic = testTopic
a1.sinks.k1.brokerList = vm01:9092,vm02:9092,vm03:9092
a1.sinks.k1.requiredAcks = 1
a1.sinks.k1.batchSize = 100
# 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:
bin/flume-ng agent -c conf -f conf/flume2Kafka.conf --name a1 -Dflume.root.logger=INFO,console