---
title: "Kafka常用命令"
author: "fairy_xzc"
date: "2017-09-21T14:36:16Z"
tags: []
categories: ["编程语言"]
slug: "kafka"
draft: false
lastmod: "2017-09-21T14:43:08Z"
id: 2393974
url: "https://agilestyle.iteye.com/blog/2393974"
---

**原创转载请注明出处：[http://agilestyle.iteye.com/blog/2393974](/blog/2393974)**

 

### 启动zookeeper

./zkServer.sh start

 

### 启动Kafka

./kafka-server-start.sh ../config/server.properties 1&gt;/dev/null 2&gt;&1 & 

 

### 停止Kafka

./kafka-server-stop.sh

 

### 停止zookeeper

./zkServer.sh stop

 

### 创建topic

./kafka-topics.sh --create --zookeeper hadoop-0004:2181 --replication-factor 3 --partitions 1 --topic test

 

### 展示topic

./kafka-topics.sh --list --zookeeper hadoop-0004:2181

 

### 描述topic

./kafka-topics.sh --describe --zookeeper hadoop-0004:2181 --topic test

 

### 删除topic

./kafka-topics.sh --delete --zookeeper hadoop-0004:2181 --topic test

 

### 启动producer

./kafka-console-producer.sh --broker-list hadoop-0004:9092 --topic test

 

### 启动consumer

./kafka-console-consumer.sh --zookeeper hadoop-0004:2181 --topic test --from-beginning