Kafka 安装与使用

安装 Kafka

cd kafka_2.12-2.1.0

  • 修改 kafka-server 配置
    kafka_2.12-2.1.0/config/server.properties
broker.id=1
log.dir=/kafka/logs

使用 Kafka

功能启动命令备注
启动 ZKbin/zookeeper-server-start.sh -daemon config/zookeeper.propertiesKafka 安装包自带 ZK,可以单节点启动
启动 Kafka 服务器bin/kafka-server-start.sh config/server.properties
创建 Topic(test)bin/kafka-topics.sh –create –zookeeper localhost:2181 –replication-factor 1 –partitions 1 –topic test
Topic 列表bin/kafka-topics.sh –list –zookeeper localhost:2181
启动 Producerbin/kafka-console-producer.sh –broker-list localhost:9092 –topic test
启动 Consumerbin/kafka-console-consumer.sh –bootstrap-server localhost:9092 –topic test –from-beginning
Topic 相关信息(test)bin/kafka-topics.sh –describe –zookeeper localhost:2181 –topic test
点赞