[{"data":1,"prerenderedAt":184},["ShallowReactive",2],{"content:\u002Fposts\u002Fcentos-kafka-install":3,"surround:\u002Fposts\u002Fcentos-kafka-install":173},{"id":4,"title":5,"body":6,"categories":149,"date":151,"description":152,"draft":153,"extension":154,"image":155,"meta":156,"navigation":158,"path":159,"permalink":155,"pinned":153,"published":155,"readingTime":160,"recommend":155,"references":155,"seo":165,"sitemap":166,"stem":167,"tags":168,"type":171,"updated":151,"__hash__":172},"content\u002Fposts\u002Fposts\u002Fcentos-kafka-install.md","Kafka 跨平台安装与基础使用指南（Linux \u002F Windows）",{"type":7,"value":8,"toc":141},"minimark",[9,19,25,34,41,46,49,60,67,86,90,101,107,111,117,121,127,133],[10,11,15],"alert",{"type":12,"icon":13,"title":14},"info","tabler:robot","AI 迁移提示",[16,17,18],"p",{},"本文由 AI 协助从旧站迁移，尚未完成逐篇人工审校；内容如有疏漏，将在复核后修订。",[10,20,22],{"type":21},"warning",[16,23,24],{},"本文内容来源于参考教程整理，部分步骤未经实机验证，仅供参考。如有问题请以官方文档为准。",[16,26,27,28],{},"Kafka 下载地址：",[29,30,31],"a",{"href":31,"rel":32},"https:\u002F\u002Fkafka.apache.org\u002Fdownloads",[33],"nofollow",[16,35,36],{},[37,38],"img",{"alt":39,"src":40},"下载Kafka软件包",".\u002Fimages\u002Fcentos-all-345422.webp",[42,43,45],"h2",{"id":44},"一安装","一、安装",[16,47,48],{},"Linux 下载并解压：",[50,51,57],"pre",{"className":52,"code":54,"language":55,"meta":56},[53],"language-bash","# 解压到指定目录\ntar -zxvf kafka_2.13-3.5.1.tgz\nmv kafka_2.13-3.5.1 \u002Fopt\u002Fkafka\n","bash","",[58,59,54],"code",{"__ignoreMap":56},[16,61,62,63,66],{},"Windows 直接解压到合适路径即可（建议纯英文路径，如 ",[58,64,65],{"code":65},"D:\\env-java\\","）。",[10,68,69],{"type":12},[70,71,72,80],"ul",{},[73,74,75,76,79],"li",{},"Linux 命令在 ",[58,77,78],{"code":78},"bin\u002F"," 目录下执行",[73,81,82,83,79],{},"Windows 命令在 ",[58,84,85],{"code":85},"bin\\windows\\",[42,87,89],{"id":88},"二修改配置","二、修改配置",[16,91,92,93,96,97,100],{},"编辑 ",[58,94,95],{"code":95},"config\u002Fserver.properties"," 和 ",[58,98,99],{"code":99},"config\u002Fzookeeper.properties","：",[50,102,105],{"className":103,"code":104,"language":55,"meta":56},[53],"# Linux 配置示例\nbroker.id=1\nlog.dirs=\u002Fopt\u002Fkafka\u002Flogs\n\n# Windows 配置示例\nbroker.id=1\nlog.dirs=D:\u002Fenv-java\u002Fkafka_2.13-3.5.1\u002Fkafka-logs\n",[58,106,104],{"__ignoreMap":56},[42,108,110],{"id":109},"三启动服务","三、启动服务",[50,112,115],{"className":113,"code":114,"language":55,"meta":56},[53],"# 启动 ZooKeeper\n## Linux\nbin\u002Fzookeeper-server-start.sh -daemon config\u002Fzookeeper.properties\n## Windows\nbin\\windows\\zookeeper-server-start.bat config\\zookeeper.properties\n\n# 启动 Kafka\n## Linux（后台启动，推荐）\ncd \u002Fopt\u002Fkafka\nnohup bin\u002Fkafka-server-start.sh config\u002Fserver.properties 2>&1 &\n# 或者\nbin\u002Fkafka-server-start.sh -daemon config\u002Fserver.properties\n\n## Windows\nbin\\windows\\kafka-server-start.bat config\\server.properties\n",[58,116,114],{"__ignoreMap":56},[42,118,120],{"id":119},"四常用操作","四、常用操作",[50,122,125],{"className":123,"code":124,"language":55,"meta":56},[53],"# 创建 Topic\n## Linux\nbin\u002Fkafka-topics.sh --create --bootstrap-server localhost:9092 \\\n  --replication-factor 1 --partitions 1 --topic test\n\n# 查看 Topic 列表\nbin\u002Fkafka-topics.sh --list --bootstrap-server localhost:9092\n\n# 查看 Topic 详情\nbin\u002Fkafka-topics.sh --describe --bootstrap-server localhost:9092 --topic test\n\n# 删除 Topic\nbin\u002Fkafka-topics.sh --delete --bootstrap-server localhost:9092 --topic test\n\n# 启动 Producer（生产者）\nbin\u002Fkafka-console-producer.sh --broker-list localhost:9092 --topic test\n\n# 启动 Consumer（消费者，从头消费）\nbin\u002Fkafka-console-consumer.sh --bootstrap-server localhost:9092 \\\n  --topic test --from-beginning\n\n# 删除 Topic 数据（需要 delete_script.json 文件）\nbin\u002Fkafka-delete-records.sh --bootstrap-server localhost:9092 \\\n  --offset-json-file delete_script.json\n",[58,126,124],{"__ignoreMap":56},[16,128,129,132],{},[58,130,131],{"code":131},"delete_script.json"," 文件格式：",[50,134,139],{"className":135,"code":137,"language":138,"meta":56},[136],"language-json","{\n  \"partitions\": [\n    {\n      \"topic\": \"test\",\n      \"partition\": 0,\n      \"offset\": -1\n    }\n  ]\n}\n","json",[58,140,137],{"__ignoreMap":56},{"title":56,"searchDepth":142,"depth":142,"links":143},4,[144,146,147,148],{"id":44,"depth":145,"text":45},2,{"id":88,"depth":145,"text":89},{"id":109,"depth":145,"text":110},{"id":119,"depth":145,"text":120},[150],"服务","2026-01-15","介绍在 Linux 和 Windows 下安装 Apache Kafka，配置 ZooKeeper 与 Kafka Broker，并演示常用的 Topic 管理与消息生产消费命令。",false,"md",null,{"slots":157},{},true,"\u002Fposts\u002Fcentos-kafka-install",{"text":161,"minutes":162,"time":163,"words":164},"2 min read",1.615,96900,323,{"title":5,"description":152},{"loc":159},"posts\u002Fposts\u002Fcentos-kafka-install",[169,170],"Kafka","消息队列","tech","Sty3GpN0Te5i9ddI1g3tyfUsYbT2-mWQmZcn92vAMfE",[174,179],{"title":175,"path":176,"stem":177,"date":178,"type":171,"children":-1},"CentOS 编译安装 Redis 6.2 并配置 Systemd 服务","\u002Fposts\u002Fcentos-redis-install","posts\u002Fposts\u002Fcentos-redis-install","2026-01-14",{"title":180,"path":181,"stem":182,"date":183,"type":171,"children":-1},"CentOS 安装 MongoDB 3.4 并配置认证","\u002Fposts\u002Fcentos-mongodb-install","posts\u002Fposts\u002Fcentos-mongodb-install","2026-01-16",1788712225418]