kafka-server-start.sh config/server.properties
This command will start a Kafka Broker and use config/server .properties
as configuration file.
kafka-server-start.sh config/server-1.properties kafka-server-start.sh config/server-2.properties kafka-server-start.sh config/server-3.properties
This command will start three Kafka Brokers and use config/server-1.properties
, config/server -2.properties
and config/server-3.properties
as configuration files.
zookeeper-server-start.sh config/zookeeper.properties
This command will start a ZooKeeper server and use config/zookeeper.properties
as the configuration file.
kafka-topics.sh --create --topic test --partitions 3 --replication-factor 2
This command will create a Topic named test
, which has 3 partitions and 2 replication factors.
kafka-console-producer.sh --topic test
This command will start a console producer that sends data to the test
Topic.
kafka-console-consumer.sh --topic test --from-beginning
This command will start a console consumer, which will consume data from the beginning of the test
Topic.
kafka-server-stop.sh
This command will stop all running Kafka Broker.
zookeeper-server-stop.sh
This command will stop the ZooKeeper server.
The following is a complete example that demonstrates how to start a Kafka cluster, create a Topic, produce data, consume data, and then stop the Kafka cluster.
# 启动ZooKeeper zookeeper-server-start.sh config/zookeeper.properties # 启动Kafka Broker kafka-server-start.sh config/server-1.properties kafka-server-start.sh config/server-2.properties kafka-server-start.sh config/server-3.properties # 创建Topic kafka-topics.sh --create --topic test --partitions 3 --replication-factor 2 # 生产数据 kafka-console-producer.sh --topic test # 消费数据 kafka-console-consumer.sh --topic test --from-beginning # 停止Kafka kafka-server-stop.sh # 停止ZooKeeper zookeeper-server-stop.sh
The above is the detailed content of In-depth analysis of Kafka startup commands to quickly master Kafka. For more information, please follow other related articles on the PHP Chinese website!