Flumeとkafkaの接続テスト

1684 ワード

Flumeのプロファイル:(kafkaに接続されたプロファイル)
#ファイル名:kafka.properties
#構成内容:
それぞれlinuxシステムに2つのフォルダを作成します.1つのフォルダはプロファイル(flumetest)を格納し、1つのフォルダは読み取りが必要なファイル(flume)を格納します.
a1.sources = s1
a1.channels = c1
a1.sinks = k1

a1.sources.s1.type = netcat
a1.sources.s1.bind = 192.168.123.102
a1.sources.s1.port = 44455

a1.channels.c1.type = memory

a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.kafka.topic = t1
a1.sinks.k1.kafka.bootstrap.servers = 192.168.123.103:9092

a1.sources.s1.channels = c1
a1.sinks.k1.channel = c1

まずzookeeperを起動する必要があります.
kafkaクラスタの起動:(構成されたノードはすべて起動する)
[hadoop@hadoop02 kafka_2.11-1.0.0]$ bin/kafka-server-start.sh config/server.properties

kafkaクラスタにはt 1というtopicが必要です
a1.sinks.k1.kafka.topic = t1

Flumeの起動:
[hadoop@hadoop02 apache-flume-1.8.0-bin]$ flume-ng agent --conf conf --conf-file /home/hadoop/apps/apache-flume-1.8.0-bin/flumetest/kafka.properties --name a1 -Dflume.root.logger=INFO,console

hadoop 03でkafka消費を開始する情報:
[hadoop@hadoop03 kafka_2.11-1.0.0]$ bin/kafka-console-consumer.sh --zookeeper hadoop02:2181 --from-beginning --topic t1       
Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper].
ok
aaa

次にhadoop 02に接続します.
[hadoop@hadoop02 kafka_2.11-1.0.0]$ telnet 192.168.123.102 44455  
Trying 192.168.123.102...
Connected to 192.168.123.102.
Escape character is '^]'.
aaa
OK
送信aaaはhadoop 03ノードのkafka消費情報に表示されます.