{"id":33020,"date":"2025-04-26T10:27:04","date_gmt":"2025-04-26T02:27:04","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/33020.html"},"modified":"2025-04-26T10:27:04","modified_gmt":"2025-04-26T02:27:04","slug":"kafka%e5%b8%b8%e8%a7%81%e9%97%ae%e9%a2%98%e5%8f%8a%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/33020.html","title":{"rendered":"Kafka\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Kafka \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5206\u5e03\u5f0f\u6d41\u5904\u7406\u5e73\u53f0&#xff0c;\u5e7f\u6cdb\u7528\u4e8e\u9ad8\u541e\u5410\u91cf\u7684\u6570\u636e\u6d41\u5904\u7406&#xff0c;\u4f46\u5728\u5b9e\u9645\u4f7f\u7528\u8fc7\u7a0b\u4e2d&#xff0c;\u4e5f\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684 Kafka \u95ee\u9898\u53ca\u5176\u5bf9\u5e94\u7684\u89e3\u51b3\u529e\u6cd5\u7684\u8be6\u7ec6\u89e3\u7b54&#xff1a;<\/p>\n<h2 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u6d88\u606f\u4e22\u5931<\/h2>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u4e00\u3001\u539f\u56e0<\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">1.\u751f\u4ea7\u7aef<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u7f51\u7edc\u6545\u969c\u3001\u751f\u4ea7\u8005\u8d85\u65f6\u5bfc\u81f4\u6d88\u606f\u53d1\u9001\u5931\u8d25\u3002<\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">2.Broker\u7aef<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Broker\u5b95\u673a\u3001\u526f\u672c\u540c\u6b65\u4e0d\u8db3\u6216\u78c1\u76d8\u6545\u969c&#xff1b;<\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">3.\u6d88\u8d39\u8005\u7aef<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6d88\u8d39\u8005\u6545\u969c\u6216\u672a\u6b63\u786e\u63d0\u4ea4Offset\u3002<\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u4e8c\u3001\u89e3\u51b3\u65b9\u6848<\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">1.\u751f\u4ea7\u8005\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u6d88\u606f\u538b\u7f29<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u542f\u7528\u6d88\u606f\u538b\u7f29&#xff08;compression.type&#061;gzip&#xff09;&#xff0c;\u51cf\u5c11\u7f51\u7edc\u5e26\u5bbd\u7684\u6d88\u8017\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;2&#xff09;ACK\u673a\u5236<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8bbe\u7f6eacks&#061;all&#xff0c;\u786e\u4fdd\u6d88\u606f\u6301\u4e45\u5316\u5230\u6240\u6709ISR&#xff08;\u540c\u6b65\u526f\u672c&#xff09;\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;3&#xff09;\u91cd\u8bd5\u673a\u5236<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u542f\u7528\u91cd\u8bd5\u673a\u5236&#xff0c;\u6307\u5b9a\u53d1\u9001\u5931\u8d25\u540e\u91cd\u8bd5\u6b21\u6570&#xff0c;\u907f\u514d\u56e0\u7f51\u7edc\u6296\u52a8\u5bfc\u81f4\u6d88\u606f\u4e22\u5931\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;4&#xff09;\u7f13\u51b2\u533a<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u751f\u4ea7\u8005\u5728\u53d1\u9001\u6d88\u606f\u65f6\u4f1a\u5c06\u6d88\u606f\u7f13\u5b58\u5728\u7f13\u51b2\u533a&#xff08;buffer.memory&#xff09;&#xff0c;\u76f4\u5230\u6ee1\u8db3\u6279\u91cf\u53d1\u9001\u7684\u6761\u4ef6\u3002\u5982\u679c\u751f\u4ea7\u8005\u53d1\u9001\u7684\u901f\u5ea6\u8fc7\u5feb&#xff0c;\u5bfc\u81f4\u7f13\u51b2\u533a\u7a7a\u95f4\u4e0d\u8db3&#xff0c;\u53ef\u80fd\u4f1a\u4e22\u5931\u6d88\u606f\u3002\u901a\u8fc7\u8c03\u6574\u7f13\u51b2\u533a\u53c2\u6570\u7684\u503c\u6765\u589e\u52a0\u7f13\u51b2\u533a\u5927\u5c0f&#xff0c;\u53ef\u4ee5\u51cf\u5c11\u56e0\u5185\u5b58\u4e0d\u8db3\u5bfc\u81f4\u7684\u6d88\u606f\u4e22\u5931\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;5&#xff09;\u542f\u7528\u751f\u4ea7\u8005\u4e8b\u52a1<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Kafka \u63d0\u4f9b\u4e86\u4e8b\u52a1\u673a\u5236&#xff0c;\u53ef\u4ee5\u786e\u4fdd\u4e00\u7ec4\u6d88\u606f\u8981\u4e48\u5b8c\u5168\u63d0\u4ea4&#xff0c;\u8981\u4e48\u5b8c\u5168\u56de\u6eda\u3002\u751f\u4ea7\u8005\u5728\u53d1\u9001\u6d88\u606f\u65f6\u542f\u7528\u4e8b\u52a1&#xff0c;\u53ef\u4ee5\u51cf\u5c11\u6d88\u606f\u4e22\u5931\u6216\u91cd\u590d\u7684\u53ef\u80fd\u6027\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u914d\u7f6e\u4e8b\u52a1\u7684\u6b65\u9aa4&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8bbe\u7f6e\u00a0transactional.id&#xff0c;\u5f00\u542f\u4e8b\u52a1\u529f\u80fd\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5728\u4e1a\u52a1\u903b\u8f91\u4e2d\u4f7f\u7528\u00a0commitTransaction()\u00a0\u548c\u00a0abortTransaction()\u00a0\u6765\u786e\u4fdd\u6d88\u606f\u7684\u4e00\u81f4\u6027\u3002<\/p>\n<h5 style=\"background-color:transparent;margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;6&#xff09;\u603b\u914d\u7f6e\u793a\u4f8b<\/h5>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0produce:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 compression-type: gzip\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u6d88\u606f\u538b\u7f29&#xff0c;\u53ef\u9009\u503c&#xff1a;gzip\u3001snappy\u3001lz4\u3001zstd<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0acks: all\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u526f\u672c\u540c\u6b65 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0retries: 3\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # \u53d1\u9001\u5931\u8d25\u540e\u91cd\u8bd5\u6b21\u6570<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0\u00a0enable-idempotence: true\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u542f\u7528\u5e42\u7b49\u6027<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 buffer-memory: 67108864\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0# \u7f13\u51b2\u533a\u5185\u5b58\u5927\u5c0f&#xff0c;\u5355\u4f4d\u5b57\u8282<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 transactional-id-prefix: tx-\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u4e8b\u52a1ID\u524d\u7f00&#xff0c;\u542f\u7528\u4e8b\u52a1\u65f6\u8bbe\u7f6e<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">2.Broker\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u526f\u672c\u673a\u5236<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u914d\u7f6e\u591a\u526f\u672c\u673a\u5236&#xff08;replication-factor&#xff09;&#xff0c;\u8bbe\u7f6e\u6bcf\u4e2a\u5206\u533a\u7684\u526f\u672c\u6570\u3002\u5206\u533a\u7684\u526f\u672c\u6570\u8d8a\u591a&#xff0c;\u6570\u636e\u7684\u5bb9\u9519\u80fd\u529b\u8d8a\u5f3a&#xff0c;\u4fdd\u8bc1Broker\u5b95\u673a\u65f6\u6570\u636e\u4e0d\u4e22\u5931\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0admin:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u9ed8\u8ba4\u4e3b\u9898\u5206\u533a\u7b56\u7565<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 default-topic:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 \u00a0 replication-factor: 3\u00a0\u00a0\u00a0# \u9ed8\u8ba4\u5206\u533a\u7684\u526f\u672c\u6570<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;2&#xff09;Leader\u9009\u4e3e\u673a\u5236<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8bbe\u7f6e\u7981\u7528\u810f\u9009\u4e3e&#xff08;unclean.leader.election.enable&#061;false&#xff09;&#xff0c;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u7981\u7528\u6ca1\u6709\u540c\u6b65\u6240\u6709\u65e5\u5fd7\u7684\u526f\u672c\u53c2\u4e0e\u9009\u4e3e&#xff0c;\u907f\u514d\u51fa\u73b0\u6570\u636e\u4e22\u5931\u7684\u60c5\u51b5\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 # \u526f\u672c\u673a\u5236<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 replication:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u526f\u672c\u843d\u540e\u8d85\u8fc7\u6b64\u65f6\u95f4&#xff08;\u6beb\u79d2&#xff09;\u4f1a\u88ab\u79fb\u51fa ISR \u5217\u8868<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 replica_lag_time_max_ms: 10000\u00a0 \u00a0 \u00a0# \u9ed8\u8ba4\u4e3a 10000 \u6beb\u79d2&#xff0c;\u5373 10 \u79d2<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u6700\u5c11\u9700\u8981\u591a\u5c11\u4e2a\u540c\u6b65\u526f\u672c\u624d\u80fd\u8fdb\u884c\u5199\u5165<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 min_insync_replicas: 2\u00a0 \u00a0 \u00a0# \u9ed8\u8ba4\u4e3a 1<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u662f\u5426\u5141\u8bb8\u5728\u6ca1\u6709\u8db3\u591f ISR \u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u9886\u5bfc\u8005\u9009\u4e3e<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 unclean_leader_election_enable: false\u00a0 \u00a0 \u00a0# \u9ed8\u8ba4\u4e3a false&#xff0c;\u9632\u6b62\u6570\u636e\u4e22\u5931<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;3&#xff09;\u65e5\u5fd7\u6bb5\u548c\u65e5\u5fd7\u4fdd\u7559\u914d\u7f6e<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8bbe\u7f6e\u65e5\u5fd7\u6bb5\u548c\u65e5\u5fd7\u4fdd\u7559&#xff0c;log.retention.ms \u6216 log.retention.bytes&#xff0c;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u786e\u4fdd\u6d88\u606f\u5728\u65e5\u5fd7\u4e2d\u5b58\u50a8\u8db3\u591f\u957f\u7684\u65f6\u95f4&#xff0c;\u907f\u514d\u56e0\u65e5\u5fd7\u6eda\u52a8\u800c\u4e22\u5931\u672a\u88ab\u6d88\u8d39\u7684\u6d88\u606f\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0# \u65e5\u5fd7\u673a\u5236<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0log:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u8bbe\u7f6e\u6bcf\u4e2a\u65e5\u5fd7\u6bb5\u7684\u5927\u5c0f<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 segment:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 \u00a0 bytes: 1073741824\u00a0 \u00a0# \u9ed8\u8ba4\u4e3a 1GB<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u8bbe\u7f6e\u65e5\u5fd7\u4fdd\u7559\u65f6\u95f4&#xff08;\u6beb\u79d2&#xff09;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 retention:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 \u00a0 \u00a0ms: 604800000\u00a0 \u00a0# 7\u5929&#xff0c;\u5355\u4f4d\u662f\u6beb\u79d2<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u8bbe\u7f6e\u65e5\u5fd7\u7684\u6700\u5927\u4fdd\u7559\u5927\u5c0f<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 retention_bytes: 10737418240\u00a0 \u00a0# \u9ed8\u8ba4\u4e3a 10GB<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u8bbe\u7f6e\u65e5\u5fd7\u6e05\u7406\u7b56\u7565&#xff08;delete \u6216 compact&#xff09;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 cleanup_policy: &#034;delete&#034;\u00a0 \u00a0# \u53ef\u9009&#xff1a;delete \u6216 compact<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u8bbe\u7f6e\u65e5\u5fd7\u7d22\u5f15\u95f4\u9694\u5927\u5c0f<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 index_interval_bytes: 4096\u00a0 \u00a0# \u9ed8\u8ba4\u4e3a 4096<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;4&#xff09;\u78c1\u76d8\u68c0\u67e5<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5b9a\u671f\u76d1\u63a7\u78c1\u76d8\u5065\u5eb7\u72b6\u6001&#xff0c;\u907f\u514d\u65e5\u5fd7\u76ee\u5f55\u5199\u6ee1\u5bfc\u81f4\u6570\u636e\u4e0d\u53ef\u7528\u3002<\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">3.\u6d88\u8d39\u8005\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u6d88\u606f\u504f\u79fb\u91cf\u63d0\u4ea4\u7b56\u7565<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5173\u95ed\u81ea\u52a8\u63d0\u4ea4\u6d88\u606f\u504f\u79fb\u91cf&#xff08;enable-auto-commit&#xff09;&#xff0c;\u53ef\u4ee5\u5728\u6bcf\u6b21\u5904\u7406\u5b8c\u6d88\u606f\u540e\u663e\u5f0f\u63d0\u4ea4\u504f\u79fb\u91cf&#xff0c;\u786e\u4fdd\u6d88\u8d39\u7684\u6d88\u606f\u4e0d\u4f1a\u4e22\u5931\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;2&#xff09;\u91cd\u65b0\u6d88\u8d39\u7b56\u7565<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5982\u679c\u6d88\u8d39\u8005\u542f\u52a8\u65f6\u672a\u627e\u5230\u5bf9\u5e94\u7684\u504f\u79fb\u91cf&#xff0c;auto.offset.reset\u00a0\u53c2\u6570\u51b3\u5b9a\u4e86\u5982\u4f55\u5904\u7406\u3002earliest\u00a0\u4f1a\u8ba9\u6d88\u8d39\u8005\u4ece\u6700\u65e9\u7684\u6d88\u606f\u5f00\u59cb\u6d88\u8d39&#xff0c;latest\u00a0\u4f1a\u8ba9\u6d88\u8d39\u8005\u4ece\u6700\u65b0\u7684\u6d88\u606f\u5f00\u59cb\u6d88\u8d39\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6839\u636e\u9700\u6c42\u5408\u7406\u914d\u7f6e auto.offset.reset&#xff0c;\u907f\u514d\u6d88\u8d39\u8005\u9519\u8fc7\u6d88\u606f\u6216\u4ece\u9519\u8bef\u7684\u4f4d\u7f6e\u5f00\u59cb\u6d88\u8d39\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;3&#xff09;\u542f\u7528\u6d88\u8d39\u8005\u4e8b\u52a1<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Kafka \u6d88\u8d39\u8005\u4e5f\u652f\u6301\u4e8b\u52a1\u529f\u80fd&#xff0c;\u542f\u7528\u6d88\u8d39\u8005\u4e8b\u52a1\u53ef\u4ee5\u786e\u4fdd\u6d88\u606f\u7684\u539f\u5b50\u6027\u548c\u4e00\u81f4\u6027\u3002\u5373\u4f7f\u6d88\u8d39\u8005\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u6545\u969c&#xff0c;\u4e8b\u52a1\u4e5f\u4f1a\u786e\u4fdd\u6d88\u606f\u7684\u6b63\u786e\u6d88\u8d39\u6216\u56de\u6eda\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u901a\u8fc7 isolation.level&#061;read_committed \u914d\u7f6e\u6d88\u8d39\u8005\u4e8b\u52a1&#xff0c;\u786e\u4fdd\u6d88\u606f\u7684\u5b8c\u6574\u6027\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 consumer:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 enable-auto-commit: false\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # \u624b\u52a8\u63d0\u4ea4\u6d88\u606f\u504f\u79fb\u91cf<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 auto-offset-reset: earliest\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u4ece\u6700\u65e9\u7684\u6d88\u606f\u5f00\u59cb\u6d88\u8d39<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 isolation-level: read_committed\u00a0 \u00a0# \u53ea\u8bfb\u53d6\u5df2\u63d0\u4ea4\u7684\u6d88\u606f<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u6d88\u606f\u91cd\u590d\u6d88\u8d39<\/h2>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u4e00\u3001\u539f\u56e0<\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">1.\u751f\u4ea7\u8005\u7aef<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6d88\u606f\u53d1\u9001\u6ca1\u6709\u4fdd\u8bc1\u5e42\u7b49\u6027&#xff0c;\u5982&#xff1a;\u6d88\u606f\u53d1\u9001\u5931\u8d25&#xff0c;\u591a\u6b21\u91cd\u8bd5\u53d1\u9001&#xff0c;\u5bfc\u81f4\u6d88\u606f\u91cd\u590d\u6295\u9012\u3002<\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">2.Broker\u7aef<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Broker\u7ef4\u62a4\u6d88\u8d39\u8005\u8d1f\u8f7d\u5747\u8861&#xff0c;\u5982\u679c\u4e00\u4e2a\u6d88\u8d39\u8005\u5d29\u6e83&#xff0c;Broker\u4f1a\u5c06\u5176\u5206\u914d\u7684\u5206\u533a\u91cd\u65b0\u5206\u914d\u7ed9\u5176\u4ed6\u6d88\u8d39\u8005\u3002\u5982\u679c\u5728\u91cd\u65b0\u5206\u914d\u65f6\u672a\u80fd\u6b63\u786e\u5904\u7406\u504f\u79fb\u91cf&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u91cd\u65b0\u6d88\u8d39\u67d0\u4e9b\u6d88\u606f\u3002<\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">3.\u6d88\u8d39\u8005\u7aef<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6d88\u8d39\u8005\u5d29\u6e83\u548c\u5f02\u5e38\u9000\u51fa&#xff0c;\u6216\u6d88\u8d39\u8005\u504f\u79fb\u91cf\u63d0\u4ea4\u7b56\u7565\u4e0d\u5f53&#xff0c;\u5bfc\u81f4\u6d88\u8d39\u8005\u504f\u79fb\u91cf&#xff08;Offset&#xff09;\u6ca1\u6709\u6b63\u786e\u63d0\u4ea4\u3002\u6d88\u8d39\u8005\u53ef\u80fd\u5728\u4e0b\u4e00\u6b21\u62c9\u53d6\u6d88\u606f\u65f6\u4ece\u4e0a\u6b21\u672a\u63d0\u4ea4\u7684\u4f4d\u7f6e\u5f00\u59cb&#xff0c;\u5bfc\u81f4\u91cd\u590d\u6d88\u8d39\u3002<\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u4e8c\u3001\u89e3\u51b3\u65b9\u6848<\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">1.\u751f\u4ea7\u8005\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u751f\u4ea7\u8005\u5e42\u7b49\u6027<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u786e\u4fdd\u751f\u4ea7\u8005\u53d1\u9001\u7684\u6d88\u606f\u5177\u6709\u5e42\u7b49\u6027\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u542f\u7528\u5e42\u7b49\u6027&#xff0c;Kafka \u4f1a\u4e3a\u6bcf\u4e2a\u6d88\u606f\u751f\u6210\u552f\u4e00\u7684 ID&#xff0c;\u5373\u4f7f\u56e0\u4e3a\u7f51\u7edc\u95ee\u9898\u5bfc\u81f4\u751f\u4ea7\u8005\u91cd\u8bd5\u53d1\u9001\u6d88\u606f&#xff0c;\u4e5f\u80fd\u786e\u4fdd\u6bcf\u6761\u6d88\u606f\u53ea\u88ab\u5199\u5165\u4e00\u6b21\u3002<\/p>\n<p style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0produce:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 enable-idempotence: true\u00a0 \u00a0 \u00a0# \u542f\u7528\u5e42\u7b49\u6027<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">2.Broker\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u5206\u533a\u518d\u5206\u914d\u4e0e\u504f\u79fb\u91cf\u7ba1\u7406<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Kafka \u9ed8\u8ba4\u5728\u6d88\u8d39\u8005\u53d1\u751f\u6545\u969c\u6216\u91cd\u542f\u65f6\u4f1a\u8fdb\u884c\u5206\u533a\u91cd\u65b0\u5206\u914d\u3002\u4e3a\u4e86\u907f\u514d\u91cd\u65b0\u6d88\u8d39\u5df2\u5904\u7406\u7684\u6d88\u606f&#xff0c;\u6d88\u8d39\u8005\u5e94\u5c3d\u91cf\u907f\u514d\u5728\u6d88\u8d39\u8005\u5206\u914d\u65f6\u66f4\u65b0\u504f\u79fb\u91cf&#xff0c;\u800c\u662f\u6839\u636e\u6d88\u8d39\u8005\u7684\u5904\u7406\u903b\u8f91\u6765\u786e\u8ba4\u6b63\u786e\u7684\u504f\u79fb\u91cf\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u9632\u6b62\u5206\u533a\u518d\u5206\u914d\u65f6\u91cd\u590d\u6d88\u8d39\u7684\u7b56\u7565&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u751f\u4ea7\u7aef\u4f7f\u7528\u4e8b\u52a1\u6216\u5176\u4ed6\u624b\u6bb5\u786e\u4fdd\u6d88\u606f\u7684\u539f\u5b50\u6027\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u6d88\u8d39\u7aef\u901a\u8fc7\u8bbe\u7f6e\u00a0max.poll.records&#xff0c;\u51cf\u5c11\u6bcf\u6b21\u62c9\u53d6\u7684\u6d88\u606f\u6570\u91cf&#xff0c;\u786e\u4fdd\u6bcf\u6b21\u62c9\u53d6\u7684\u6d88\u606f\u90fd\u80fd\u591f\u88ab\u5904\u7406\u5b8c\u3002<\/p>\n<p style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0consumer:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 max-poll-records: 1000\u00a0 \u00a0 \u00a0# \u6bcf\u6b21poll\u7684\u6700\u5927\u8bb0\u5f55\u6570 \u00a0<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">3.\u6d88\u8d39\u8005\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u504f\u79fb\u91cf\u63d0\u4ea4\u7b56\u7565<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5728\u6d88\u8d39\u8005\u6210\u529f\u5904\u7406\u5b8c\u4e00\u6761\u6d88\u606f\u540e&#xff0c;\u663e\u5f0f\u5730\u624b\u52a8\u63d0\u4ea4\u504f\u79fb\u91cf\u3002\u53ef\u4ee5\u786e\u4fdd\u6d88\u8d39\u8005\u5728\u5d29\u6e83\u65f6\u4e0d\u4f1a\u4e22\u5931\u6216\u91cd\u590d\u6d88\u8d39\u6d88\u606f\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6d88\u8d39\u8005\u624b\u52a8\u63d0\u4ea4\u504f\u79fb\u91cf\u7684\u65b9\u5f0f&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u540c\u6b65\u63d0\u4ea4\u504f\u79fb\u91cf&#xff1a;\u6bcf\u6b21\u6d88\u8d39\u6d88\u606f\u540e\u540c\u6b65\u63d0\u4ea4\u504f\u79fb\u91cf\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u5f02\u6b65\u63d0\u4ea4\u504f\u79fb\u91cf&#xff1a;\u5f02\u6b65\u63d0\u4ea4\u504f\u79fb\u91cf&#xff0c;\u4e0d\u4f1a\u963b\u585e\u6d88\u606f\u5904\u7406\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 consumer:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 enable-auto-commit: false \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# \u624b\u52a8\u63d0\u4ea4\u6d88\u606f\u504f\u79fb\u91cf<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;2&#xff09;\u6d88\u8d39\u8005\u5e42\u7b49\u6027<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u786e\u4fdd\u6d88\u8d39\u8005\u7684\u5904\u7406\u64cd\u4f5c\u662f\u5e42\u7b49\u7684\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5e42\u7b49\u6027\u610f\u5473\u7740\u65e0\u8bba\u6d88\u606f\u5904\u7406\u591a\u5c11\u6b21&#xff0c;\u6700\u7ec8\u7ed3\u679c\u90fd\u5e94\u8be5\u662f\u4e00\u6837\u7684\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6d88\u8d39\u8005\u5e42\u7b49\u6027\u7b56\u7565&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u6570\u636e\u5e93\u552f\u4e00\u6027\u7ea6\u675f&#xff0c;\u9632\u6b62\u76f8\u540c\u7684\u6d88\u606f\u5199\u5165\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u53bb\u91cd\u8868&#xff0c;\u68c0\u67e5\u6d88\u606f\u662f\u5426\u5904\u7406\u8fc7\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 Redis\u539f\u5b50\u64cd\u4f5c&#xff0c;setnx()\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u4e50\u89c2\u9501&#xff08;CAS\u673a\u5236&#xff09;\u3002<\/p>\n<h2 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u6d88\u606f\u5806\u79ef<\/h2>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u4e00\u3001\u539f\u56e0<\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">1.\u751f\u4ea7\u8005\u7aef<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u751f\u4ea7\u8005\u751f\u4ea7\u901f\u5ea6\u8fc7\u5feb&#xff0c;\u8fdc\u8d85\u6d88\u8d39\u8005\u7684\u6d88\u8d39\u901f\u5ea6&#xff0c;\u5bfc\u81f4\u6d88\u606f\u5806\u79ef\u3002<\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">2.Broker\u7aef<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">&#xff08;1&#xff09;\u5206\u533a\u6570\u4e0d\u8db3<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5206\u533a\u7684\u6570\u91cf\u548c\u6d88\u8d39\u8005\u7684\u6570\u91cf\u5e94\u8be5\u9002\u914d\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5982\u679c Kafka \u96c6\u7fa4\u7684\u5206\u533a\u6570\u91cf\u592a\u5c11&#xff0c;\u800c\u6d88\u8d39\u7aef\u6d88\u8d39\u8005\u6570\u91cf\u8f83\u591a&#xff0c;\u591a\u4e2a\u6d88\u8d39\u8005\u4f1a\u4e89\u593a\u8f83\u5c11\u7684\u5206\u533a\u8d44\u6e90&#xff0c;\u5bfc\u81f4\u6d88\u8d39\u80fd\u529b\u4e0d\u8db3&#xff0c;\u6d88\u606f\u5806\u79ef\u3002<\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">3.\u6d88\u8d39\u8005\u7aef<\/h4>\n<h5 style=\"background-color:transparent;margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u6d88\u8d39\u8005\u6d88\u8d39\u80fd\u529b\u4e0d\u8db3<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6d88\u8d39\u8005\u6570\u91cf\u4e0d\u8db3&#xff0c;\u65e0\u6cd5\u6ee1\u8db3\u9ad8\u5e76\u53d1\u7684\u6d88\u606f\u5904\u7406\u9700\u6c42\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6d88\u8d39\u8005\u7684\u786c\u4ef6\u6027\u80fd&#xff08;\u4f8b\u5982 CPU\u3001\u5185\u5b58\u3001\u78c1\u76d8 IO&#xff09;\u4e0d\u8db3\u4ee5\u652f\u6491\u9ad8\u541e\u5410\u91cf\u7684\u6d88\u8d39\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6d88\u8d39\u8005\u7684\u5904\u7406\u903b\u8f91&#xff08;\u4f8b\u5982\u7f51\u7edc\u8bf7\u6c42\u3001\u6570\u636e\u5e93\u64cd\u4f5c\u7b49&#xff09;\u8f83\u6162&#xff0c;\u5bfc\u81f4\u6d88\u8d39\u901f\u5ea6\u8fdc\u4f4e\u4e8e\u6d88\u606f\u751f\u4ea7\u901f\u5ea6\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;2&#xff09;\u6d88\u8d39\u7ebf\u7a0b\u6216\u5e76\u53d1\u5ea6\u4e0d\u8db3<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6d88\u8d39\u8005\u5982\u679c\u662f\u5355\u7ebf\u7a0b\u6a21\u578b&#xff0c;\u6216\u8005\u6bcf\u4e2a\u6d88\u8d39\u8005\u5b9e\u4f8b\u53ea\u4f7f\u7528\u4e00\u4e2a\u7ebf\u7a0b\u6765\u5904\u7406\u6d88\u606f&#xff0c;\u90a3\u4e48\u5f53\u6d88\u606f\u91cf\u8f83\u5927\u65f6&#xff0c;\u6d88\u8d39\u8005\u65e0\u6cd5\u5e76\u884c\u6d88\u8d39&#xff0c;\u5bfc\u81f4\u5806\u79ef\u95ee\u9898\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;3&#xff09;\u6d88\u8d39\u8005\u504f\u79fb\u91cf<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5982\u679c\u6d88\u8d39\u8005\u6ca1\u6709\u6b63\u786e\u7ba1\u7406\u504f\u79fb\u91cf&#xff08;\u4f8b\u5982&#xff0c;\u6ca1\u6709\u63d0\u4ea4\u6d88\u8d39\u7684\u504f\u79fb\u91cf&#xff09;&#xff0c;\u53ef\u80fd\u5bfc\u81f4\u6d88\u8d39\u8005\u91cd\u65b0\u6d88\u8d39\u65e7\u6d88\u606f\u6216\u8005\u4e22\u5931\u672a\u6d88\u8d39\u7684\u6d88\u606f&#xff0c;\u9020\u6210\u5806\u79ef\u548c\u6d88\u8d39\u6ede\u540e\u3002<\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u4e8c\u3001\u89e3\u51b3\u65b9\u6848<\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">1.\u751f\u4ea7\u8005\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u63a7\u5236\u751f\u4ea7\u8005\u541e\u5410\u91cf<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5bf9\u751f\u4ea7\u8005\u7684\u541e\u5410\u91cf\u8fdb\u884c\u63a7\u5236&#xff0c;\u907f\u514d\u751f\u4ea7\u901f\u5ea6\u8fc7\u5feb\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8c03\u6574\u751f\u4ea7\u8005\u7684\u901f\u5ea6\u7684\u65b9\u5f0f&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u9650\u5236\u541e\u5410\u91cf&#xff0c;\u4f7f\u7528\u00a0acks\u00a0\u548c\u00a0batch.size\u00a0\u914d\u7f6e\u6765\u8c03\u6574\u6d88\u606f\u53d1\u9001\u7684\u7b56\u7565\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u63a7\u5236\u6d88\u606f\u6279\u91cf\u53d1\u9001\u7684\u65f6\u673a&#xff0c;\u8bbe\u7f6e\u00a0linger.ms\u548cbuffer-memory\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0produce:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 enable-idempotence: true\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u542f\u7528\u5e42\u7b49\u6027<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 acks: all\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # \u786e\u8ba4\u673a\u5236<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 batch-size: 32768\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u751f\u4ea7\u8005\u6bcf\u4e2a\u6279\u6b21\u53d1\u9001\u7684\u6700\u5927\u5b57\u8282\u6570<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 linger-ms: 5\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # \u5ef6\u8fdf\u53d1\u9001\u7684\u65f6\u95f4&#xff0c;\u5355\u4f4d\u6beb\u79d2<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 buffer-memory: 67108864\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # \u751f\u4ea7\u8005\u7f13\u51b2\u533a\u5185\u5b58\u5927\u5c0f&#xff0c;\u5355\u4f4d\u5b57\u8282<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">2.Broker\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u589e\u52a0\u5206\u533a\u6570<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u901a\u8fc7\u589e\u52a0\u5206\u533a\u6570&#xff0c;\u53ef\u4ee5\u63d0\u9ad8 Kafka \u6d88\u8d39\u7684\u5e76\u53d1\u5904\u7406\u80fd\u529b&#xff0c;\u51cf\u8f7b\u6d88\u606f\u5806\u79ef\u7684\u98ce\u9669\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6ce8\u610f&#xff0c;\u589e\u52a0\u540e\u7684\u5206\u533a\u6570\u4f1a\u5f71\u54cd Kafka \u7684\u8d1f\u8f7d\u5747\u8861&#xff0c;\u56e0\u6b64\u9700\u8981\u6839\u636e\u96c6\u7fa4\u7684\u5b9e\u9645\u60c5\u51b5\u6765\u8c03\u6574\u5206\u533a\u6570\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0admin:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 default-topic:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 \u00a0 partitions: 5\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # \u9ed8\u8ba4\u4e3b\u9898\u7684\u5206\u533a\u6570<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 \u00a0 replication-factor: 3\u00a0 \u00a0 \u00a0 \u00a0 # \u9ed8\u8ba4\u5206\u533a\u7684\u526f\u672c\u6570<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;2&#xff09;\u8bbe\u7f6e\u6d88\u606f\u8fc7\u671f\u7b56\u7565<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5f53\u6d88\u606f\u8d85\u8fc7\u914d\u7f6e\u7684\u4fdd\u7559\u65f6\u95f4\u540e&#xff0c;Kafka \u4f1a\u81ea\u52a8\u5220\u9664\u8fd9\u4e9b\u6d88\u606f\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u901a\u8fc7\u8bbe\u7f6e\u5408\u7406\u7684 log.retention.hours \u6216 log.retention.bytes \u53c2\u6570&#xff0c;\u53ef\u4ee5\u9650\u5236\u6d88\u606f\u7684\u4fdd\u7559\u65f6\u95f4&#xff0c;\u907f\u514d\u6d88\u606f\u5806\u79ef\u5bfc\u81f4\u5b58\u50a8\u95ee\u9898\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0log:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u8bbe\u7f6e\u6bcf\u4e2a\u65e5\u5fd7\u6bb5\u7684\u5927\u5c0f<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 segment:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 \u00a0 \u00a0 bytes: 1073741824\u00a0 \u00a0 \u00a0# \u9ed8\u8ba4\u4e3a 1GB<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u8bbe\u7f6e\u65e5\u5fd7\u4fdd\u7559\u65f6\u95f4&#xff08;\u6beb\u79d2&#xff09;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 retention:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 \u00a0 ms: 604800000\u00a0 \u00a0 \u00a0# 7\u5929&#xff0c;\u5355\u4f4d\u662f\u6beb\u79d2<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 # \u8bbe\u7f6e\u65e5\u5fd7\u7684\u6700\u5927\u4fdd\u7559\u5927\u5c0f<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 retention_bytes: 10737418240\u00a0 \u00a0 \u00a0# \u9ed8\u8ba4\u4e3a 10GB<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">3.\u6d88\u8d39\u8005\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u589e\u52a0\u6d88\u8d39\u8005\u6570\u91cf<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u589e\u52a0\u6d88\u8d39\u8005\u6570\u91cf&#xff0c;\u63d0\u9ad8\u6d88\u8d39\u4f53\u91cf&#xff0c;\u5206\u62c5 Kafka \u5206\u533a\u7684\u6d88\u8d39\u8d1f\u8f7d\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;2&#xff09;\u589e\u52a0\u6d88\u8d39\u8005\u5e76\u53d1\u6570<\/h5>\n<p>\u901a\u8fc7\u8bbe\u7f6e\u6d88\u8d39\u8005\u5e76\u53d1\u6570&#xff0c;\u5b9e\u73b0\u5e76\u53d1\u6d88\u8d39\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">kafka:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0consumer:<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 concurrency: 10\u00a0 \u00a0 \u00a0# \u8bbe\u7f6e\u6d88\u8d39\u8005\u5e76\u53d1\u6570 \u00a0<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;3&#xff09;\u589e\u52a0\u6d88\u8d39\u8005\u7684\u5e76\u53d1\u5ea6&#xff08;\u7ebf\u7a0b\u6c60&#xff09;<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u901a\u8fc7\u589e\u52a0\u6bcf\u4e2a\u6d88\u8d39\u8005\u7684\u7ebf\u7a0b\u6570\u91cf&#xff0c;\u6765\u63d0\u5347\u6d88\u8d39\u7684\u5e76\u53d1\u5ea6\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4f8b\u5982&#xff0c;\u5982\u679c\u6d88\u606f\u7684\u64cd\u4f5c\u662f CPU \u5bc6\u96c6\u578b\u7684&#xff0c;\u53ef\u4ee5\u91c7\u7528\u6d88\u8d39\u8005\u7ebf\u7a0b\u6c60&#xff0c;\u6765\u63d0\u5347\u5904\u7406\u80fd\u529b\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">public class KafkaConsumer {<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0private static final int NUM_THREADS &#061; 4;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 private ExecutorService executorService &#061; Executors.newFixedThreadPool(NUM_THREADS);<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0&#064;KafkaListener(topics &#061; &#034;my-topic&#034;, groupId &#061; &#034;my-group&#034;)<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0public void consume(List&lt;String&gt; messages) {<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0for (String message : messages) {<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0executorService.submit(() -&gt; processMessage(message));<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0}<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0private void processMessage(String message) {<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ \u5904\u7406\u6d88\u606f\u7684\u4e1a\u52a1\u903b\u8f91<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0}<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">}<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;4&#xff09;\u4f18\u5316\u6d88\u8d39\u8005\u7684\u5904\u7406\u901f\u5ea6<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8fc7\u6ee4\u975e\u5173\u952e\u6d88\u606f&#xff0c;\u51cf\u5c11\u6d88\u606f\u91cf<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6279\u91cf\u5904\u7406\u6d88\u606f&#xff0c;\u51cf\u5c11\u9891\u7e41\u7684\u6d88\u606f\u5904\u7406\u5f00\u9500\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5728\u6d88\u8d39\u8fc7\u7a0b\u4e2d\u907f\u514d\u590d\u6742\u8ba1\u7b97\u6216\u7e41\u91cd\u7684\u540c\u6b65\u64cd\u4f5c\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4f18\u5316\u6570\u636e\u5e93\u8bbf\u95ee&#xff0c;\u907f\u514d\u9891\u7e41\u7684\u7f51\u7edc\u8bf7\u6c42\u6216\u78c1\u76d8 I\/O \u64cd\u4f5c\u3002<\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">4.\u76d1\u63a7\u4e0e\u544a\u8b66\u673a\u5236<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u76d1\u63a7\u6307\u6807<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u901a\u8fc7\u76d1\u63a7\u6d88\u8d39\u8005\u7684\u6d88\u8d39\u5ef6\u8fdf\u3001Kafka Broker \u7684\u78c1\u76d8\u7a7a\u95f4\u3001\u7f51\u7edc\u5e26\u5bbd\u7b49\u6307\u6807&#xff0c;\u53ef\u4ee5\u53ca\u65f6\u53d1\u73b0\u95ee\u9898\u5e76\u91c7\u53d6\u63aa\u65bd\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4f8b\u5982&#xff1a;\u4f7f\u7528 Kafka \u63d0\u4f9b\u7684 consumer lag \u6307\u6807&#xff0c;\u76d1\u63a7\u6d88\u8d39\u8005\u7684\u6ede\u540e\u60c5\u51b5\u3002\u5982\u679c\u6ede\u540e\u8fc7\u591a&#xff0c;\u53ca\u65f6\u589e\u52a0\u6d88\u8d39\u8005\u6570\u91cf\u6216\u6269\u5c55\u6d88\u8d39\u8005\u7684\u5904\u7406\u80fd\u529b\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;2&#xff09;\u5e38\u7528\u76d1\u63a7\u5de5\u5177<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Kafka Manager&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u63d0\u4f9b Kafka \u96c6\u7fa4\u7684\u5b9e\u65f6\u76d1\u63a7\u3001\u7ba1\u7406\u529f\u80fd\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Prometheus &#043; Grafana&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u901a\u8fc7 Prometheus \u62c9\u53d6 Kafka \u7684\u76d1\u63a7\u6570\u636e&#xff0c;\u5e76\u4f7f\u7528 Grafana \u5c55\u793a\u76d1\u63a7\u56fe\u8868\u3002<\/p>\n<h2 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u6d88\u606f\u987a\u5e8f<\/h2>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u4e00\u3001\u539f\u56e0<\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">1.\u751f\u4ea7\u8005\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u6d88\u606f\u5206\u533a\u7b56\u7565<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Kafka \u5141\u8bb8\u751f\u4ea7\u8005\u5e76\u884c\u53d1\u9001\u6d88\u606f\u5230\u4e0d\u540c\u7684\u5206\u533a&#xff0c;\u8fd9\u53ef\u80fd\u5bfc\u81f4\u6d88\u606f\u987a\u5e8f\u95ee\u9898\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u751f\u4ea7\u8005\u5728\u6ca1\u6709\u660e\u786e\u6307\u5b9a\u5206\u533a\u7684\u60c5\u51b5\u4e0b&#xff0c;\u4f1a\u6839\u636e\u5206\u533a\u5668&#xff08;Partitioner&#xff09;\u7684\u7b56\u7565\u5c06\u6d88\u606f\u53d1\u9001\u5230\u4e0d\u540c\u7684\u5206\u533a\u3002\u5373\u4f7f\u5728\u540c\u4e00\u4e2a\u751f\u4ea7\u8005\u5b9e\u4f8b\u4e2d&#xff0c;\u6d88\u606f\u53d1\u9001\u5230\u4e0d\u540c\u7684\u5206\u533a\u4e5f\u53ef\u80fd\u5bfc\u81f4\u5b83\u4eec\u7684\u987a\u5e8f\u53d1\u751f\u53d8\u5316\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;2&#xff09;\u751f\u4ea7\u8005\u7684\u91cd\u8bd5\u673a\u5236<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5f53\u6d88\u606f\u53d1\u9001\u5931\u8d25\u65f6&#xff0c;\u751f\u4ea7\u8005\u4f1a\u8fdb\u884c\u91cd\u8bd5\u3002\u8fd9\u53ef\u80fd\u5bfc\u81f4\u6d88\u606f\u5728\u751f\u4ea7\u8fc7\u7a0b\u4e2d\u987a\u5e8f\u53d1\u751f\u53d8\u5316&#xff0c;\u7279\u522b\u662f\u5728\u751f\u4ea7\u8005\u5728\u591a\u4e2a\u5206\u533a\u4e0a\u5e76\u53d1\u5199\u5165\u6d88\u606f\u65f6\u3002<\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">2.Broker\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u5206\u533a\u987a\u5e8f<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Kafka \u662f\u57fa\u4e8e\u5206\u533a\u6765\u7ec4\u7ec7\u6d88\u606f\u7684&#xff0c;\u6d88\u606f\u7684\u987a\u5e8f\u4fdd\u8bc1\u662f\u5206\u533a\u7ea7\u522b\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u53ea\u80fd\u4fdd\u8bc1\u5355\u5206\u533a\u987a\u5e8f&#xff0c;\u4e0d\u80fd\u4fdd\u8bc1\u8de8\u5206\u533a\u987a\u5e8f\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u540c\u4e00\u5206\u533a&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u540c\u4e00\u4e2a\u5206\u533a\u4e2d\u7684\u6d88\u606f\u4f1a\u6309\u7167\u751f\u4ea7\u7684\u987a\u5e8f\u8fdb\u884c\u6d88\u8d39\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4e0d\u540c\u5206\u533a&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4e0d\u540c\u5206\u533a\u7684\u6d88\u606f\u4e4b\u95f4\u7684\u987a\u5e8f\u65e0\u6cd5\u4fdd\u8bc1&#xff0c;\u56e0\u4e3a\u4e0d\u540c\u7684\u5206\u533a\u53ef\u80fd\u88ab\u4e0d\u540c\u7684\u6d88\u8d39\u8005\u5e76\u884c\u5904\u7406\u3002<\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">3.\u6d88\u8d39\u8005\u7aef<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u591a\u4e2a\u6d88\u8d39\u8005\u5e76\u53d1\u6d88\u8d39\u591a\u4e2a\u5206\u533a\u65f6&#xff0c;\u7531\u4e8e\u6d88\u8d39\u8005\u53ef\u80fd\u5e76\u884c\u6d88\u8d39\u4e0d\u540c\u5206\u533a\u7684\u6d88\u606f&#xff0c;\u5bfc\u81f4\u591a\u4e2a\u5206\u533a\u5185\u7684\u6d88\u606f\u987a\u5e8f\u5f97\u5230\u4fdd\u8bc1&#xff0c;\u4f46\u8de8\u5206\u533a\u7684\u6d88\u606f\u987a\u5e8f\u5c31\u65e0\u6cd5\u4fdd\u8bc1\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4f8b\u5982&#xff0c;\u5206\u533a 0 \u4e2d\u7684\u6d88\u606f\u987a\u5e8f\u662f\u6709\u4fdd\u8bc1\u7684&#xff0c;\u5206\u533a 1 \u4e2d\u7684\u6d88\u606f\u987a\u5e8f\u4e5f\u662f\u6709\u4fdd\u8bc1\u7684&#xff0c;\u4f46\u5206\u533a 0 \u548c\u5206\u533a 1 \u4e4b\u95f4\u7684\u987a\u5e8f\u662f\u4e0d\u786e\u5b9a\u7684\u3002<\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u4e8c\u3001\u89e3\u51b3\u65b9\u6848<\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">1.\u751f\u4ea7\u8005\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u57fa\u4e8e\u6d88\u606f\u7684\u952e&#xff08;Key&#xff09;\u786e\u4fdd\u987a\u5e8f<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u901a\u8fc7\u8bbe\u7f6e\u6d88\u606f\u7684\u952e&#xff08;Key&#xff09;\u6765\u51b3\u5b9a\u6d88\u606f\u7684\u5206\u914d\u7684\u5206\u533a\u3002\u6d88\u606f\u5177\u6709\u76f8\u540c\u7684\u952e\u65f6&#xff0c;\u4f1a\u88ab\u53d1\u9001\u5230\u76f8\u540c\u7684\u5206\u533a&#xff0c;\u4ece\u800c\u4fdd\u8bc1\u4e86\u8fd9\u4e9b\u6d88\u606f\u7684\u987a\u5e8f\u6027\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">ProducerRecord&lt;String, String&gt; record &#061; new ProducerRecord&lt;&gt;(&#034;topic&#034;, &#034;userID123&#034;, &#034;orderMessage&#034;);<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">producer.send(record);<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;2&#xff09;\u786e\u4fdd\u6d88\u606f\u91cd\u8bd5\u65f6\u7684\u987a\u5e8f<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u901a\u8fc7\u914d\u7f6e\u751f\u4ea7\u8005\u7684 acks \u548c retries \u53c2\u6570\u6765\u63a7\u5236\u6d88\u606f\u91cd\u8bd5\u673a\u5236&#xff0c;\u4ece\u800c\u51cf\u5c11\u91cd\u8bd5\u5e26\u6765\u7684\u987a\u5e8f\u95ee\u9898\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">acks: \u786e\u4fdd\u6d88\u606f\u88ab\u6210\u529f\u5199\u5165\u526f\u672c\u540e\u624d\u786e\u8ba4\u8fd4\u56de&#xff0c;\u4ee5\u63d0\u9ad8\u6d88\u606f\u7684\u53ef\u9760\u6027\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">retries: \u63a7\u5236\u751f\u4ea7\u8005\u91cd\u8bd5\u6b21\u6570&#xff0c;\u9632\u6b62\u56e0\u91cd\u8bd5\u5bfc\u81f4\u7684\u987a\u5e8f\u95ee\u9898\u3002<\/p>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;3&#xff09;\u4f7f\u7528\u4e8b\u52a1\u786e\u4fdd\u987a\u5e8f<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Kafka \u652f\u6301\u751f\u4ea7\u8005\u4e8b\u52a1&#xff0c;\u53ef\u4ee5\u5728\u751f\u4ea7\u8005\u7aef\u542f\u7528\u4e8b\u52a1&#xff0c;\u786e\u4fdd\u4e00\u7ec4\u6d88\u606f\u7684\u987a\u5e8f\u6027\u548c\u539f\u5b50\u6027\u3002\u901a\u8fc7\u4e8b\u52a1&#xff0c;\u53ef\u4ee5\u4fdd\u8bc1\u4e00\u7ec4\u6d88\u606f\u8981\u4e48\u5168\u90e8\u63d0\u4ea4&#xff0c;\u8981\u4e48\u5168\u90e8\u56de\u6eda&#xff0c;\u4ece\u800c\u907f\u514d\u90e8\u5206\u6d88\u606f\u7684\u987a\u5e8f\u95ee\u9898\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Properties props &#061; new Properties();<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">props.put(&#034;acks&#034;, &#034;all&#034;);<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">props.put(&#034;transactional.id&#034;, &#034;my-transaction-id&#034;);<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">KafkaProducer&lt;String, String&gt; producer &#061; new KafkaProducer&lt;&gt;(props);<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">producer.initTransactions();<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">try {<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0producer.beginTransaction();<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0producer.send(new ProducerRecord&lt;&gt;(topic, &#034;key&#034;, &#034;value&#034;));<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0producer.commitTransaction();<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">} catch (ProducerFencedException | OutOfOrderSequenceException | AuthorizationException e) {<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\/\/ fatal errors, should not proceed<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0producer.close();<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">} catch (KafkaException e) {<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\/\/ transient errors, may be retried<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0producer.abortTransaction();<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">}<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">2.Broker\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u81ea\u5b9a\u4e49\u5206\u533a\u7b56\u7565<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Kafka \u63d0\u4f9b\u4e86\u5206\u533a\u5668&#xff08;Partitioner&#xff09;\u63a5\u53e3&#xff0c;\u5141\u8bb8\u7528\u6237\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u81ea\u5b9a\u4e49\u5206\u533a\u7b56\u7565\u3002\u53ef\u4ee5\u5b9e\u73b0\u81ea\u5b9a\u4e49\u7684\u5206\u533a\u5668&#xff0c;\u4f7f\u5f97\u5177\u6709\u76f8\u540c\u7279\u5f81&#xff08;\u5982\u540c\u4e00\u7528\u6237\u3001\u540c\u4e00\u8bbe\u5907&#xff09;\u7684\u6d88\u606f\u53d1\u9001\u5230\u76f8\u540c\u7684\u5206\u533a&#xff0c;\u4fdd\u8bc1\u540c\u4e00\u5206\u533a\u7684\u987a\u5e8f\u6027\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:426.1000pt\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">public class CustomPartitioner implements Partitioner {<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0&#064;Override<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0public void configure(Map&lt;String, ?&gt; configs) {<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0}<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0&#064;Override<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0public int partition(String topic, Object key, byte[] keyBytes, Object value, byte[] valueBytes,<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0 \u00a0 \u00a0 \u00a0 Cluster cluster) {<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ \u4f8b\u5982\u6839\u636e\u7528\u6237 ID \u505a\u5206\u533a<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Math.abs(key.hashCode()) % cluster.partitionCountForTopic(topic);<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0}<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0&#064;Override<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0public void close() {<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0}<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">}<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">3.\u6d88\u8d39\u8005\u7aef<\/h4>\n<h5 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">&#xff08;1&#xff09;\u63a7\u5236\u6d88\u8d39\u987a\u5e8f<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5f53\u6d88\u8d39\u8005\u5e76\u53d1\u6d88\u8d39\u591a\u4e2a\u5206\u533a\u65f6&#xff0c;\u65e0\u6cd5\u4fdd\u8bc1\u8de8\u5206\u533a\u7684\u987a\u5e8f\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6d88\u8d39\u7b56\u7565&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5355\u7ebf\u7a0b\u6d88\u8d39&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5c06\u6d88\u8d39\u8005\u914d\u7f6e\u4e3a\u5355\u7ebf\u7a0b\u6d88\u8d39&#xff0c;\u4ece\u800c\u907f\u514d\u5e76\u53d1\u6d88\u8d39\u5bfc\u81f4\u7684\u987a\u5e8f\u95ee\u9898\u3002\u4f46\u8fd9\u6837\u4f1a\u5f71\u54cd\u7cfb\u7edf\u7684\u541e\u5410\u91cf\u548c\u6027\u80fd&#xff0c;\u9002\u7528\u4e8e\u987a\u5e8f\u6027\u8981\u6c42\u6781\u9ad8\u7684\u573a\u666f\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6d88\u8d39\u8005\u6309\u5206\u533a\u987a\u5e8f\u5904\u7406&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u53ef\u4ee5\u5728\u6d88\u8d39\u8005\u7aef\u5bf9\u591a\u4e2a\u5206\u533a\u7684\u6d88\u606f\u8fdb\u884c\u6392\u5e8f\u5904\u7406&#xff0c;\u786e\u4fdd\u6309\u65f6\u95f4\u6216\u5176\u4ed6\u7ef4\u5ea6\u7684\u987a\u5e8f\u8fdb\u884c\u6d88\u8d39\u3002\u5bf9\u4e8e\u9ad8\u5e76\u53d1\u7684\u5e94\u7528&#xff0c;\u8fd9\u79cd\u65b9\u5f0f\u53ef\u80fd\u9700\u8981\u66f4\u590d\u6742\u7684\u903b\u8f91\u3002<\/p>\n<h2 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u603b\u7ed3<\/h2>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">Kafka\u95ee\u9898\u6392\u67e5\u9700\u7ed3\u5408\u65e5\u5fd7\u5206\u6790&#xff08;\u5982Broker\u7684server.log&#xff09;\u3001\u76d1\u63a7\u6307\u6807&#xff08;\u541e\u5410\u91cf\u3001\u5ef6\u8fdf\u3001Lag&#xff09;\u53ca\u96c6\u7fa4\u62d3\u6251\u3002\u5bf9\u5173\u952e\u573a\u666f&#xff08;\u5982\u91d1\u878d\u4ea4\u6613&#xff09;\u5efa\u8bae\u91c7\u7528\u7aef\u5230\u7aef\u4e8b\u52a1&#xff08;Exactly-Once\u8bed\u4e49&#xff09;\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027\u3002\u5bf9\u4e8e\u4e91\u539f\u751f\u73af\u5883&#xff0c;\u4f18\u5148\u9009\u62e9\u6258\u7ba1\u670d\u52a1&#xff08;\u5982Confluent Cloud&#xff09;\u51cf\u5c11\u8fd0\u7ef4\u8d1f\u62c5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb682\u6b21\uff0c\u70b9\u8d5e23\u6b21\uff0c\u6536\u85cf10\u6b21\u3002Kafka\u95ee\u9898\u6392\u67e5\u9700\u7ed3\u5408\u65e5\u5fd7\u5206\u6790\uff08\u5982Broker\u7684server.log\uff09\u3001\u76d1\u63a7\u6307\u6807\uff08\u541e\u5410\u91cf\u3001\u5ef6\u8fdf\u3001Lag\uff09\u53ca\u96c6\u7fa4\u62d3\u6251\u3002\u5bf9\u5173\u952e\u573a\u666f\uff08\u5982\u91d1\u878d\u4ea4\u6613\uff09\u5efa\u8bae\u91c7\u7528\u7aef\u5230\u7aef\u4e8b\u52a1\uff08Exactly-Once\u8bed\u4e49\uff09\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027\u3002\u5bf9\u4e8e\u4e91\u539f\u751f\u73af\u5883\uff0c\u4f18\u5148\u9009\u62e9\u6258\u7ba1\u670d\u52a1\uff08\u5982Confluent Cloud\uff09\u51cf\u5c11\u8fd0\u7ef4\u8d1f\u62c5\u3002_kafka\u6570\u636e\u5982\u4f55\u67e5\u8be2\u662f\u5426\u5165\u5e93<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1114,664],"topic":[],"class_list":["post-33020","post","type-post","status-publish","format-standard","hentry","category-server","tag-kafka","tag-664"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Kafka\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/33020.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Kafka\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb682\u6b21\uff0c\u70b9\u8d5e23\u6b21\uff0c\u6536\u85cf10\u6b21\u3002Kafka\u95ee\u9898\u6392\u67e5\u9700\u7ed3\u5408\u65e5\u5fd7\u5206\u6790\uff08\u5982Broker\u7684server.log\uff09\u3001\u76d1\u63a7\u6307\u6807\uff08\u541e\u5410\u91cf\u3001\u5ef6\u8fdf\u3001Lag\uff09\u53ca\u96c6\u7fa4\u62d3\u6251\u3002\u5bf9\u5173\u952e\u573a\u666f\uff08\u5982\u91d1\u878d\u4ea4\u6613\uff09\u5efa\u8bae\u91c7\u7528\u7aef\u5230\u7aef\u4e8b\u52a1\uff08Exactly-Once\u8bed\u4e49\uff09\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027\u3002\u5bf9\u4e8e\u4e91\u539f\u751f\u73af\u5883\uff0c\u4f18\u5148\u9009\u62e9\u6258\u7ba1\u670d\u52a1\uff08\u5982Confluent Cloud\uff09\u51cf\u5c11\u8fd0\u7ef4\u8d1f\u62c5\u3002_kafka\u6570\u636e\u5982\u4f55\u67e5\u8be2\u662f\u5426\u5165\u5e93\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/33020.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-26T02:27:04+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/33020.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/33020.html\",\"name\":\"Kafka\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-26T02:27:04+00:00\",\"dateModified\":\"2025-04-26T02:27:04+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/33020.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/33020.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/33020.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Kafka\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Kafka\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/33020.html","og_locale":"zh_CN","og_type":"article","og_title":"Kafka\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb682\u6b21\uff0c\u70b9\u8d5e23\u6b21\uff0c\u6536\u85cf10\u6b21\u3002Kafka\u95ee\u9898\u6392\u67e5\u9700\u7ed3\u5408\u65e5\u5fd7\u5206\u6790\uff08\u5982Broker\u7684server.log\uff09\u3001\u76d1\u63a7\u6307\u6807\uff08\u541e\u5410\u91cf\u3001\u5ef6\u8fdf\u3001Lag\uff09\u53ca\u96c6\u7fa4\u62d3\u6251\u3002\u5bf9\u5173\u952e\u573a\u666f\uff08\u5982\u91d1\u878d\u4ea4\u6613\uff09\u5efa\u8bae\u91c7\u7528\u7aef\u5230\u7aef\u4e8b\u52a1\uff08Exactly-Once\u8bed\u4e49\uff09\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027\u3002\u5bf9\u4e8e\u4e91\u539f\u751f\u73af\u5883\uff0c\u4f18\u5148\u9009\u62e9\u6258\u7ba1\u670d\u52a1\uff08\u5982Confluent Cloud\uff09\u51cf\u5c11\u8fd0\u7ef4\u8d1f\u62c5\u3002_kafka\u6570\u636e\u5982\u4f55\u67e5\u8be2\u662f\u5426\u5165\u5e93","og_url":"https:\/\/www.wsisp.com\/helps\/33020.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-26T02:27:04+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/33020.html","url":"https:\/\/www.wsisp.com\/helps\/33020.html","name":"Kafka\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-26T02:27:04+00:00","dateModified":"2025-04-26T02:27:04+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/33020.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/33020.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/33020.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Kafka\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/33020","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=33020"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/33020\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=33020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=33020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=33020"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=33020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}