Kafka-Kafka基本原理与集群快速搭建(实践)

Kafka单机搭建

下载Kafka Apache Download Mirrors

解压

复制代码
 tar -zxvf kafka_2.12-3.4.0.tgz  -C /usr/local/src/software/kafka

kafka内部bin目录下有个内置的zookeeper(用于单机)

启动zookeeper(在后台启动)

复制代码
nohup bin/zookeeper-server-start.sh config/zookeeper.properties &

启动kafka(后台启动)

复制代码
nohup bin/kafka-server-start.sh  config/server.properties &

查看创建topic的相关帮助

复制代码
bin/kafka-topics.sh  --help

简单发送消息

创建topic
复制代码
bin/kafka-topics.sh  --create --topic test --bootstrap-server localhost:9092
查看topic信息
复制代码
 bin/kafka-topics.sh --describe --topic test --bootstrap-server localhost:9092
查看生产者的相关命令
复制代码
bin/kafka-console-producer.sh  --help
生产者发送消息(指定topic)
复制代码
bin/kafka-console-producer.sh  --bootstrap-server localhost:9092 --topic test

发送消息

消费者消费实时消息
复制代码
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test
查看消费者相关命令
复制代码
bin/kafka-console-consumer.sh --help
消费之前的消息
复制代码
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic test
指定从哪里开始消费(partition指的是存储消息的实际队列)

如下:从partition 0 中的偏移量为4的记录开始消费

复制代码
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --partition 0 --offset 4 --topic test
指定消费者组
复制代码
#两个消费者实例属于同一个消费者组
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --consumer-property group.id=testGrroup --topic test
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --consumer-property group.id=testGrroup --topic test
#这个消费者实例属于不同的消费者组
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --consumer-property group.id=testGrroup2 --topic test
查看消费者组的消费进度详情
复制代码
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group testGroup

kafka集群搭建

相关推荐
飞鸟恋上鱼13 小时前
基于Spark的短视频推荐系统设计与实现
大数据·分布式·spark
@不误正业13 小时前
第09章-分布式硬件平台
分布式·架构·开源·开源鸿蒙
juniperhan13 小时前
Flink 系列第13篇:Flink 生产环境中的并行度与资源配置
java·大数据·数据仓库·分布式·flink
lzqk1200013 小时前
RabbitMQ 客户端 连接、发送、接收处理消息
分布式·rabbitmq·ruby
AILabNotes13 小时前
018、案例研究:Wikipedia镜像、Sci-Hub与分布式图书馆实践
分布式
孟意昶1 天前
Doris专题31-SQL手册-基础元素
大数据·数据库·数据仓库·分布式·sql·知识图谱·doris
2603_954708311 天前
交直流混合微电网架构:拓扑优化与功率交互设计
人工智能·分布式·物联网·架构·系统架构·能源
juniperhan1 天前
Flink 系列第12篇:Flink 维表关联详解
大数据·数据仓库·分布式·flink
Evand J1 天前
【雷达跟踪代码介绍】基于matlab卡尔曼滤波器雷达多目标跟踪(双雷达 多目标 分布式融合)
分布式·matlab·目标跟踪·多目标跟踪·雷达跟踪
indexsunny1 天前
互联网大厂Java面试实录:微服务+Spring Boot在电商场景中的应用
java·spring boot·redis·微服务·eureka·kafka·spring security