启动zookeeper
bin/zookeeper-server-start.sh config/zookeeper.properties
启动kafka server
bin/kafka-server-start.sh config/server.properties
创建topic
bin/kafka-create-topic.sh --zookeeper localhost:2181 --replica 1 --partition 1 --topic test
list
bin/kafka-list-topic.sh --zookeeper localhost:2181
producer
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
comsumer
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
多个brocker 整目录拷贝多份就可以了
cp config/server.properties config/server-1.properties
cp config/server.properties config/server-1.properties
新的配置
config/server-1.properties:
broker.id=1
port=9093
log.dir=/tmp/kafka-logs-1
config/server-2.properties:
broker.id=2
port=9094
log.dir=/tmp/kafka-logs-2
启动
JMX_PORT=9997 bin/kafka-server-start.sh config/server-1.properties &
JMX_PORT=9998 bin/kafka-server-start.sh config/server-2.properties &
创建topic
bin/kafka-create-topic.sh --zookeeper localhost:2181 --replica 3 --partition 1 --topic my-replicated-topic
list
bin/kafka-list-topic.sh --zookeeper localhost:2181
publish
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic my-replicated-topic
comsumer
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --from-beginning --topic my-replicated-topic
pkill -9 -f server-1.properties
参考:http://kafka.apache.org/08/quickstart.html