Kafka启动关闭及其相关命令
时间: 2023-05-31 21:05:49 浏览: 412
启动与关闭进程
Kafka是一个分布式流处理平台,可以通过命令行来启动和关闭它。以下是相关的命令:
启动Kafka:
1. 运行Zookeeper:
```sh
bin/zookeeper-server-start.sh config/zookeeper.properties
```
2. 运行Kafka Broker:
```sh
bin/kafka-server-start.sh config/server.properties
```
关闭Kafka:
1. 关闭Kafka Broker:
```sh
bin/kafka-server-stop.sh
```
2. 关闭Zookeeper:
```sh
bin/zookeeper-server-stop.sh
```
其他常用的命令:
1. 创建一个Topic:
```sh
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
```
2. 查看所有Topic:
```sh
bin/kafka-topics.sh --list --zookeeper localhost:2181
```
3. 启动一个消费者:
```sh
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
```
4. 启动一个生产者:
```sh
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
```
阅读全文