启动服务
http://kafka.apache.org/documentation.html#quickstart
先启动zookeeper,bin/zookeeper-server-start.sh config/zookeeper.properties
再启动kafka,bin/kafka-server-start.sh config/server.properties
新建一个topic,叫做test,bin/kafka-create-topic.sh --zookeeper localhost:2181 --replica 1 --partition 1 --topic test
查看刚才新建的topic,bin/kafka-list-topic.sh --zookeeper localhost:2181
结果:topic: test partition: 0 leader: 0 replicas: 0 isr: 0
发送消息,bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
消息内容:
This is a message
This is another message
----partition1
topic------partition2
----……
使用API
http://kafka.apache.org/documentation.html#api
创建一个topic,bin/kafka-create-topic.sh --topic page_visits --replica 3 --zookeeper localhost:2181 --partition 5
查看数据:bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic page_visits –from-beginning
http://kafka.apache.org/documentation.html#quickstart
先启动zookeeper,bin/zookeeper-server-start.sh config/zookeeper.properties
再启动kafka,bin/kafka-server-start.sh config/server.properties
新建一个topic,叫做test,bin/kafka-create-topic.sh --zookeeper localhost:2181 --replica 1 --partition 1 --topic test
查看刚才新建的topic,bin/kafka-list-topic.sh --zookeeper localhost:2181
结果:topic: test partition: 0 leader: 0 replicas: 0 isr: 0
发送消息,bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
消息内容:
This is a message
This is another message
----partition1
topic------partition2
----……
使用API
http://kafka.apache.org/documentation.html#api
创建一个topic,bin/kafka-create-topic.sh --topic page_visits --replica 3 --zookeeper localhost:2181 --partition 5
查看数据:bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic page_visits –from-beginning