Kafka_QucikStart

Kafka 常用命令记录贴

Start Server

1
2
3
4
5
6
# 开启系统集成的Zookeeper
# 简便做法,不推荐
bin/zookeeper-server-start.sh config/zookeeper.properties

# 开启Kafka Broker,使用指定properties
bin/kafka-server-start.sh config/server.properties

Topic

1
2
3
4
5
6
7
8
# 创建Topic 并设置命令行设置相关参数
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic ${topicName}

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

# Get Topic Detail
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic ${TopicName}

Producer||Consumer Command

1
2
3
4
# 命令行建立一个Producer
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
# 命令行建立一个Consumer
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic ${topicName} --from-beginning