Kafka與ZooKeeper的配置
阿新 • • 發佈:2019-02-15
(3)虛擬機器(192.168.100.106)進行如下操作
a)對檔案: $KAFKA_HOME/config/server.properties進行修改編輯:
broker.id=2
port=9092
host.name=flumekafka3
advertised.host.name=flumekafka3
num.partitions=2
zookeeper.contact=flumekafka1:2181,flumekafka2:2181,flumekafka3:2181
(6)在flumekafka2
(4)啟動kafka服務, 在flumekafka1,flumekafka2,flumekafka3上分別執行:
$ kafka-server-start.sh $KAFKA_HOME/config/server.properties
(5) 新建一個TOPIC(replication-factor=num of brokers)
$ kafka-topics.sh --create --topic flume --replication-factor 3 --partitions 2 --zookeeperflumekafka1:2181
(6)在flumekafka2 上,開一個終端,傳送訊息至kafka佇列
$ kafka-console-producer.sh --broker-list flumekafka1:9092 --sync --topic flume
然後在傳送訊息的終端輸入:Hello Kafka
(7)在flumekafka3上,開一個終端,顯示訊息的消費
$ kafka-console-consumer.sh --zookeeper flumekafka1:2181 --topic flume --from-beginning