当前位置: 首页 > news >正文

kafka4.0集群部署

kafka4.0是最新版kafka,可在kafka官网下载,依赖的jdk版本要求在jdk17及jdk17以上

tar -xzf kafka_2.13-4.0.0.tgz

mv kafka_2.13-4.0.0 kafka

cd kafka

# 随便一台节点运行生成随机uuid,后面每台节点都要使用此uuid

bin/kafka-storage.sh random-uuid         生成的uuid(IyyjPwZcTa2LHKkV1rj5pg)

# 每个节点需要在config/server.properties中配置相关内容

node.id

controller.quorum.voters=1@192.168.10.10:9093,2@192.168.10.20:9093,3@192.168.10.30:9093

log.dirs=/opt/kafka/log/kraft-combined-logs

num.partitions=16

# 每台节点设置日志目录的格式,$KAFKA_CLUSTER_ID应为上面生成的值,每个节点都要用相同的uuid

bin/kafka-storage.sh format -t IyyjPwZcTa2LHKkV1rj5pg -c config/server.properties

# 启动 Kafka 服务,每台节点都执行

bin/kafka-server-start.sh -daemon  /opt/kafka/config/server.properties

# 测试kafka集群

# 创建主题名为cluster-topic存储事件

bin/kafka-topics.sh --bootstrap-server 192.168.10.10:9092 --create --topic cluster-topic1 --partitions 3 --replication-factor 3

# 在其他节点(9092)查询该topic

bin/kafka-topics.sh --describe --topic cluster-topic1 --bootstrap-server 192.168.10.20:9092

# 将事件写入主题

bin/kafka-console-producer.sh --topic cluster-topic1 --bootstrap-server 192.168.10.10:9092

This is my first event

This is my second event

# 读取事件

bin/kafka-console-consumer.sh --topic cluster-topic --from-beginning --bootstrap-server 192.168.10.10:9092

# 删除主题

bin/kafka-topics.sh --bootstrap-server 192.168.10.10:9092 --delete --topic cluster-topic

# 配置systemd服务

# 先关闭kafka服务

/opt/kafka/bin/kafka-server-stop.sh config/server.properties

# 配置服务

cat >>/etc/systemd/system/kafka.service << EOF[Unit]Description=Apache Kafka Service (KRaft Mode)After=network.target[Service]Type=simpleUser=rootGroup=rootExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.propertiesExecStop=/opt/kafka/bin/kafka-server-stop.shRestart=on-abnormalWorkingDirectory=/opt/kafkaEnvironment="JAVA_HOME=/usr/local/jdk-17.0.12"[Install]WantedBy=multi-user.targetEOFsystemctl daemon-reloadsystemctl start kafkasystemctl status kafka

http://www.dtcms.com/a/293321.html

相关文章:

  • Qt中QObject类的核心作用与使用
  • AG32 mcu+cpld 联合编程(概念及流程)
  • 从“点状用例”到“质量生态”:现代软件测试的演进、困局与破局
  • AUTOSAR进阶图解==>AUTOSAR_SWS_CANTransceiverDriver
  • 新版Qwen3深夜突袭:性能超越Kimi-K2、DeepSeek-V3
  • 自定义HAProxy 错误界面
  • 微调大语言模型(LLM)有多难?
  • 西门子博图FB引脚解析,与FC的区别
  • Zabbix 6.0+ 使用官方模板监控 Redis 数据库的完整配置指南
  • KIMI K2:开放式的智能体(Agentic)人工智能
  • 基于卷积神经网络与小波变换的医学图像超分辨率算法复现
  • 基础工具安装
  • API: return response as HTML table
  • Redis 八股面试题
  • 软件测试面试避坑
  • 【Unity Shader】Special Effects(十一)RgbOffset RGB偏移(UI)
  • 初识卷积神经网络CNN
  • jupyter使用
  • JAVA_ONE-NINE_ATM机案例
  • 秋招Day17 - Spring - 事务
  • 【JavaEE】认识计算机(二)
  • useOptimistic介绍和使用闭坑
  • 机器学习/归一化
  • MS523NA非接触式读卡器 IC
  • 如何在 Windows 10 下部署多个 PHP 版本7.4,8.2
  • adb的使用
  • Java(Set接口和HashSet的分析)
  • SpringBoot全局异常报错处理和信息返回
  • 米家打印机驱动:Wi-Fi 无线打印丝滑顺畅不卡顿,从此告别对打印机干瞪眼
  • Java基础 7.22