agent.sources=s1
agent.channels=c1
agent.sinks=k1
agent.sources.s1.type=exec
agent.sources.s1.command=tail -F /tmp/logs/kafka.log
agent.sources.s1.channels=c1
agent.channels.c1.type=memory
agent.channels.c1.capacity=10000
agent.channels.c1.transactionCapacity=100
#设置Kafka接收器
agent.sinks.k1.type=org.apache.flume.sink.kafka.KafkaSink
#设置Kafka的broker地址和端口号
agent.sinks.k1.brokerList=192.168.16.100:9092
#设置Kafka的Topic
agent.sinks.k1.topic=kafkatest
#设置序列化方式
agent.sinks.k1.serializer.class=kafka.serializer.StringEncoder
agent.sinks.k1.channel=c1
for ((i=0;i<=1000;i++));
do
echo "kafka_test-"+$i >> /tmp/logs/kafka.log;
done
另一个窗口touch /tmp/logs/kafka.log
老命令
kafka-server-start.sh -daemon config/server.properties &
新命令(一般用新)
kafka-server-start.sh /usr/local/kafka/config/server.properties &
d.打开新终端,在kafka安装目录下执行如下命令,生成对topickafkatest的消费
kafka-console-consumer.sh --bootstrap-server 192.168.16.100:9092 --topic kafkatest --from-beginning
flume-ng agent --conf . --conf-file /usr/local/flume/conf/kafka.conf --name agent -D flume.root.logger=DEBUG,console
flume-ng agent --name agent --conf . --conf-file kafka.conf -Dflume.root.logger=DEBUG,console