部署配置
Kafka 集群的配置与部署
本假设你本机还没有安装任何的
> tar -xzf kafka_2.11-0.9.0.0.tgz
> cd kafka_2.11-0.9.0.0
> bin/zookeeper-server-start.sh config/zookeeper.properties
[2013-04-22 15:01:37,495] INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
...
然后启动
> bin/kafka-server-start.sh config/server.properties
[2013-04-22 15:01:47,028] INFO Verifying properties (kafka.utils.VerifiableProperties)
[2013-04-22 15:01:47,051] INFO Property socket.send.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties)
...
使用
在启动了test
的主题,设置只有一个
> bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
然后我们在查询主题列表的时候就可以看到该主题了
> bin/kafka-topics.sh --list --zookeeper localhost:2181
test
除了手动地指定创建主题,我们也可以配置
> bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
This is a message
This is another message
消息发送完毕之后,我们需要设置
> bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
This is a message
This is another message
如果你在不同的命令行中分别运行上述命令,那么你的