# kafka消费与生产(命令行)
### 创建主体
```shell
/usr/local/kafka_2.11-2.4.0/bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic gosuncn --partitions 2 --replication-factor 1
```
### 列出所有主题
```shell
/usr/local/kafka_2.11-2.4.0/bin/kafka-topics.sh --zookeeper localhost:2181 --list
```
### 查看主题详情
```shell
/usr/local/kafka_2.11-2.4.0/bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic gosuncn
```
### 启动消费端接收主题
```shell
/usr/local/kafka_2.11-2.4.0/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic gosuncn
```
### 启动生产端发送主题
```shell
/usr/local/kafka_2.11-2.4.0/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic gosuncn
```