kafka认知--(1)

文档参考:http://kafka.apache.org/documentation.html

下载代码:

tar -xzf kafka_2.11-0.11.0.0.tgz

cd kafka_2.11-0.11.0.0

启动

bin/zookeeper-server-start.sh config/zookeeper.properties

创建topic(主题为test,只有一个分区,一个副本)

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

查看topic

bin/kafka-topics.sh --list --zookeeper localhost:2181

发送消息

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test

启动消费者

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

 

设置多集群:

config/server.properties config/server-1.properties

config/server.properties config/server-2.properties

配置文件

config/server-1.properties:

    broker.id=1
    listeners=PLAINTEXT://:9093
    log.dir=/tmp/kafka-logs-1
 
config/server-2.properties:
    broker.id=2
    listeners=PLAINTEXT://:9094
    log.dir=/tmp/kafka-logs-2
broker.id属性是集群中的每个节点的唯一和永久的名字
 

 

posted @ 2017-07-31 11:24  liutiantian  阅读(175)  评论(0)    收藏  举报