{"id":1152,"date":"2021-03-09T10:36:24","date_gmt":"2021-03-09T02:36:24","guid":{"rendered":"http:\/\/www.rain1024.com\/?p=1152"},"modified":"2023-08-07T20:57:23","modified_gmt":"2023-08-07T12:57:23","slug":"kafka%e4%b8%ad%e5%86%8d%e5%9d%87%e8%a1%a1%e7%9a%84%e5%8f%91%e7%94%9f%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"http:\/\/rain1024.com\/index.php\/2021\/03\/09\/kafka%e4%b8%ad%e5%86%8d%e5%9d%87%e8%a1%a1%e7%9a%84%e5%8f%91%e7%94%9f%e8%bf%87%e7%a8%8b\/","title":{"rendered":"Kafka\u4e2d\u518d\u5747\u8861\u7684\u53d1\u751f\u8fc7\u7a0b"},"content":{"rendered":"<h1>Kafka\u4e2d\u518d\u5747\u8861\u7684\u53d1\u751f\u8fc7\u7a0b<\/h1>\n<h4>Kafka\u4e2d\u6d88\u8d39\u8005\u4ee5\u6d88\u8d39\u7ec4\u7684\u5f62\u5f0f\u5b58\u5728\uff0c\u6d88\u8d39\u7ec4\u6765\u6d88\u8d39\u6bcf\u4e2a\u4e3b\u9898\u4e2d\u5206\u533a\u7684\u6570\u636e\uff0c\u56e0\u4e3a\u4e3b\u9898\u4e2d\u7684\u5206\u533a\u6570\u548c\u6d88\u8d39\u8005\u6570\u91cf\u5e76\u4e0d\u4e00\u4e00\u5bf9\u5e94\uff0c\u8fd9\u65f6\u5019\u5c31\u6d89\u53ca\u5230\u5982\u4f55\u4e3a\u6bcf\u4e2a\u6d88\u8d39\u8005\u5206\u914d\u5206\u533a\uff0c\u800c\u5f53\u6709\u6d88\u8d39\u8005\u5728\u4e2d\u9014\u9000\u51fa\u65f6\uff0c\u5c31\u4f1a\u89e6\u53d1\u518d\u5747\u8861\u7684\u53d1\u751f\uff0c\u518d\u91cd\u65b0\u4e3a\u5269\u4f59\u7684\u6d88\u8d39\u8005\u5206\u914d\u5206\u533a\u3002\u6bcf\u4e2a\u6d88\u8d39\u7ec4\u5728\u670d\u52a1\u7aef\u5bf9\u5e94\u4e00\u4e2aGroupCoordinator\u5bf9\u5176\u8fdb\u884c\u7ba1\u7406\uff0c\u800c\u6d88\u8d39\u8005\u5ba2\u6237\u7aef\u4e2d\u7684ConsumerCoordinator\u7ec4\u4ef6\u8d1f\u8d23\u4e0eGroupCoordinator\u8fdb\u884c\u4ea4\u4e92\uff0c\u5b83\u4eec\u8d1f\u8d23\u6267\u884c\u5206\u533a\u7684\u5206\u914d\uff0c\u4ee5\u53ca\u6d88\u8d39\u8005\u518d\u5747\u8861\u7684\u64cd\u4f5c\u3002<\/h4>\n<h4>\u76ee\u524d\u5728\u4ee5\u4e0b\u51e0\u79cd\u60c5\u51b5\u4f1a\u89e6\u53d1\u518d\u5747\u8861\u64cd\u4f5c\u3002<\/h4>\n<ol>\n<li>\n<h5>\u6709\u65b0\u7684\u6d88\u8d39\u8005\u52a0\u5165\u6d88\u8d39\u7ec4\u3002<\/h5>\n<\/li>\n<li>\n<h5>\u6d88\u8d39\u8005\u5b95\u673a\u4e0b\u7ebf\u3002\u6d88\u8d39\u8005\u5e76\u4e0d\u4e00\u5b9a\u9700\u8981\u771f\u6b63\u4e0b\u7ebf,\u4f8b\u5982\u9047\u5230\u957f\u65f6\u95f4\u7684GC\u3001\u7f51\u7edc\u5ef6\u8fdf\u7b49\u60c5\u51b5\uff0c\u5bfc\u81f4\u6d88\u8d39\u8005\u957f\u65f6\u95f4\u672a\u5411GroupCoordinator \u53d1\u9001\u5fc3\u8df3\uff0cGroupCoordinator\u8ba4\u4e3a\u6d88\u8d39\u8005\u5df2\u7ecf\u4e0b\u7ebf\u3002<\/h5>\n<\/li>\n<li>\n<h5>\u6709\u6d88\u8d39\u8005\u4e3b\u52a8\u9000\u51fa\u6d88\u8d39\u7ec4\u3002<\/h5>\n<\/li>\n<li>\n<h5>\u6d88\u8d39\u7ec4\u6240\u5bf9\u5e94\u7684GroupCoorinator \u8282\u70b9\u53d1\u751f\u4e86\u53d8\u66f4\u3002<\/h5>\n<\/li>\n<li>\n<h5>\u6d88\u8d39\u7ec4\u5185\u6240\u8ba2\u9605\u7684\u4efb\u4e00\u4e3b\u9898\u6216\u8005\u4e3b\u9898\u7684\u5206\u533a\u6570\u91cf\u53d1\u751f\u53d8\u5316\u3002<\/h5>\n<\/li>\n<\/ol>\n<h4>\u5728\u670d\u52a1\u521a\u542f\u52a8\u65f6\uff0c\u9700\u8981\u786e\u7acb\u6d88\u8d39\u8005\u534f\u8c03\u5668\u548c\u6d88\u8d39\u7ec4\u534f\u8c03\u5668\uff0c\u5e76\u6839\u636e\u5df2\u6709\u7684\u5206\u533a\u89c4\u5219\u8fdb\u884c\u5206\u914d\u3002<\/h4>\n<h4>1.\u67e5\u627eGroupCoordinator<\/h4>\n<h5>\u6d88\u8d39\u8005\u9700\u8981\u8fde\u63a5\u5b83\u6240\u5c5e\u7684GroupCoordinator\u6240\u5728broker\uff0c\u5982\u679c\u6ca1\u6709\u4fdd\u5b58\u5bf9\u5e94GroupCoordinator\u8282\u70b9\u4fe1\u606f\uff0c\u5219\u50cf\u96c6\u7fa4\u4e2d\u8d1f\u8f7d\u6700\u5c0f\u7684\u8282\u70b9\u53d1\u9001\u8bf7\u6c42\u6765\u67e5\u627e\uff0cKafka\u901a\u8fc7\u8ba1\u7b97\u53ef\u4ee5\u5728__consumer_offsets\u627e\u5230\u6b64\u5206\u533a\u5bf9\u5e94\u7684leader\u526f\u672c\u6240\u5728\u7684\u8282\u70b9\uff0c\u8fd9\u4e2abroker\u8282\u70b9\u5c31\u662fGroupCoordinator\u8282\u70b9\uff0c\u8ba9\u6b64broker\u8282\u70b9\u5373\u626e\u6f14GroupCoordinator\u8282\u53c8\u626e\u6f14\u4fdd\u5b58\u5206\u533a\u5206\u914d\u65b9\u6848\u548c\u7ec4\u5185\u6d88\u8d39\u8005\u4f4d\u79fb\u7684\u89d2\u8272\uff0c\u53ef\u4ee5\u7701\u53bb\u5f88\u591a\u4e0d\u5fc5\u8981\u7684\u4e2d\u95f4\u8f6e\u8f6c\u6240\u5e26\u6765\u7684\u5f00\u9500\u3002<\/h5>\n<h4>2.\u52a0\u5165GroupCoordinator<\/h4>\n<h5>\u5728\u5f97\u77e5GroupCoordinator\u8282\u70b9\u4f4d\u7f6e\u540e\uff0c\u6d88\u8d39\u8005\u4fbf\u53d1\u9001\u52a0\u5165\u8bf7\u6c42\uff0cGroupCoordinator\u8282\u70b9\u4f1a\u9009\u4e3e\u6d88\u8d39\u7ec4\u7684leader\uff0c\u6d88\u8d39\u7ec4leader\u4f1a\u8d1f\u8d23\u4e4b\u540e\u5177\u4f53\u5206\u533a\u5206\u914d\u7b56\u7565\u3002\u7531\u4e8e\u5404\u4e2a\u5ba2\u6237\u7aef\u7684\u5206\u533a\u7b56\u7565\u90fd\u53ef\u4ee5\u81ea\u5b9a\u4e49\u914d\u7f6e\uff0c\u8fd9\u65f6\u8fd8\u8981\u8fdb\u884c\u6295\u7968\u9009\u4e3e\uff0cKafka\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u79cd\u5206\u533a\u7b56\u7565\u3002<\/h5>\n<ul>\n<li>\n<h5>RangeAssignor\u5206\u914d\u7b56\u7565\uff1a\u6309\u7167\u6d88\u8d39\u8005\u603b\u6570\u548c\u5206\u533a\u603b\u6570\u8fdb\u884c\u6574\u9664\u8fd0\u7b97\u6765\u83b7\u5f97\u4e00\u4e2a\u8de8\u5ea6\uff0c\u7136\u540e\u5c06\u5206\u533a\u6309\u7167\u8de8\u5ea6\u8fdb\u884c\u5e73\u5747\u5206\u914d\uff0c\u4ee5\u4fdd\u8bc1\u5206\u533a\u5c3d\u53ef\u80fd\u5747\u5300\u5730\u5206\u914d\u7ed9\u6240\u6709\u7684\u6d88\u8d39\u8005\u3002<\/h5>\n<\/li>\n<li>\n<h5>RoundRobinAssignor\u5206\u914d\u7b56\u7565\uff1a\u5c06\u6d88\u8d39\u7ec4\u5185\u6240\u6709\u6d88\u8d39\u8005\u53ca\u6d88\u8d39\u8005\u8ba2\u9605\u7684\u6240\u6709\u4e3b\u9898\u7684\u5206\u533a\u6309\u7167\u5b57\u5178\u5e8f\u6392\u5e8f\uff0c\u7136\u540e\u901a\u8fc7\u8f6e\u8be2\u65b9\u5f0f\u9010\u4e2a\u5c06\u5206\u533a\u4f9d\u6b21\u5206\u914d\u7ed9\u6bcf\u4e2a\u6d88\u8d39\u8005\u3002<\/h5>\n<\/li>\n<li>\n<h5>StickyAssignor\u5206\u914d\u7b56\u7565\uff1aSticky\u7ffb\u8bd1\u4e3a\u9ecf\u6027\u7684\uff0c\u4e3b\u8981\u4fdd\u8bc1\u5206\u533a\u7684\u5206\u914d\u8981\u5c3d\u53ef\u80fd\u5747\u5300\uff0c\u5206\u533a\u7684\u5206\u914d\u5c3d\u53ef\u80fd\u4e0e\u4e0a\u6b21\u5206\u914d\u7684\u4fdd\u6301\u76f8\u540c\uff0c<\/h5>\n<\/li>\n<\/ul>\n<blockquote><p>\n  StickyAssignor\u8981\u6bd4\u524d\u4e24\u79cd\u7b56\u7565\u66f4\u52a0\u590d\u6742\uff0c\u5b83\u7684\u4f18\u52bf\u662f\uff0c\u5f53\u518d\u5747\u8861\u53d1\u751f\uff0c\u4e0d\u9700\u8981\u5c06\u6240\u6709\u6d88\u8d39\u8005\u5df2\u7ecf\u5206\u914d\u597d\u7684\u5206\u533a\uff0c\u518d\u91cd\u65b0\u6253\u4e71\u5206\u914d\u4e00\u8fb9\uff0c\u5c3d\u91cf\u4fdd\u8bc1\u4e0e\u4e0a\u4e00\u6b21\u7ed3\u679c\u76f8\u4f3c\u3002Kafka\u4e5f\u652f\u6301\u81ea\u5b9a\u4e49\u5206\u533a\u5206\u914d\u7b56\u7565\uff0c\u6839\u636e\u4e1a\u52a1\u9700\u8981\u6765\u8fdb\u884c\u52a0\u6743\u6216\u5176\u4ed6\u65b9\u9762\u7684\u8003\u8651\uff0c\u751a\u81f3\u8fd8\u53ef\u4ee5\u6253\u7834Kafka\u9ed8\u8ba4\u6d88\u8d39\u903b\u8f91\uff0c\u4e0d\u5fc5\u5c40\u9650\u4e8e\u4e00\u4e2a\u5206\u533a\u53ea\u80fd\u88ab\u540c\u4e00\u4e2a\u6d88\u8d39\u7ec4\u5185\u7684\u4e00\u4e2a\u6d88\u8d39\u8005\u6d88\u8d39\u3002\n<\/p><\/blockquote>\n<h4>3.\u6b63\u5e38\u5de5\u4f5c\u9636\u6bb5<\/h4>\n<h5>\u5f53\u6d88\u8d39\u7ec4\u7684leader\u901a\u8fc7GroupCoordinator\u5c06\u5206\u533a\u5206\u914d\u65b9\u6848\u540c\u6b65\u5230\u5404\u4e2a\u6d88\u8d39\u8005\u4e4b\u540e\uff0c\u6d88\u8d39\u8005\u786e\u5b9a\u597d\u62c9\u53d6\u6d88\u606f\u7684\u8d77\u59cb\u4f4d\u7f6e\uff0c\u5f00\u59cb\u6b63\u5e38\u5de5\u4f5c\uff0c\u6d88\u8d39\u8005\u901a\u8fc7\u5411GroupCoordinator\u53d1\u9001\u5fc3\u8df3\u6765\u7ef4\u6301\u5b83\u4eec\u4e0e\u6d88\u8d39\u7ec4\u5173\u7cfb\uff0c\u5728\u6b63\u5e38\u65f6\u95f4\u95f4\u9694\u5185\u53d1\u9001\u5fc3\u8df3\u5c31\u662f\u6d3b\u8dc3\u7684\uff0c\u53d1\u9001\u5fc3\u8df3\u662f\u4e00\u4e2a\u72ec\u7acb\u7684\u7ebf\u7a0b\uff0c\u4e5f\u53ef\u4ee5\u5728\u8f6e\u8be2\u6d88\u606f\u7684\u7a7a\u6863\u53d1\u9001\u5fc3\u8df3\u3002<\/h5>\n<h5>\u6d88\u8d39\u8005\u7684\u5fc3\u8df3\u95f4\u9694\u65f6\u95f4\u7531\u53c2\u6570heartbeat.interval.ms\u6307\u5b9a\uff0c\u8d85\u8fc7\u4e00\u5b9a\u65f6\u95f4\u672a\u53d1\u9001\u5fc3\u8df3\uff0c\u5c31\u4f1a\u88ab\u8ba4\u4e3a\u5df2\u7ecf\u6b7b\u4ea1\u3002<\/h5>\n<h5>\u5982\u679c\u6d88\u8d39\u8005\u53d1\u751f\u5d29\u6e83\uff0c\u5e76\u505c\u6b62\u8bfb\u53d6\u6d88\u606f,\u90a3\u4e48GroupCoordinator\u4f1a\u7b49\u5f85\u4e00\u5c0f\u6bb5\u65f6\u95f4\uff0c\u786e\u8ba4\u8fd9\u4e2a\u6d88\u8d39\u8005\u6b7b\u4ea1\u4e4b\u540e\u624d\u4f1a\u89e6\u53d1\u518d\u5747\u8861\u3002\u8fd9\u4e2a\u4e00\u5c0f\u6bb5\u65f6\u95f4\u7531session.timeout.ms\u53c2\u6570\u63a7\u5236\u3002<\/h5>\n<h5>GroupCoordinator\u8fd8\u4f1a\u5224\u65ad\u6d88\u8d39\u8005\u8c03\u7528poll()\u7684\u65f6\u95f4\u671f\u9650\uff0c\u5982\u679c\u8d85\u8fc7\u53c2\u6570max.poll.interval.ms\u8bbe\u5b9a\u7684\u503c\uff0c\u5219\u6d88\u8d39\u8005\u88ab\u89c6\u4e3a\u5931\u8d25\uff0c\u5e76\u4e14\u5206\u7ec4\u5c06\u91cd\u65b0\u5e73\u8861\uff0c\u4ee5\u4fbf\u5c06\u5206\u533a\u91cd\u65b0\u5206\u914d\u7ed9\u522b\u7684\u6210\u5458\u3002<\/h5>\n<h4>\u6700\u540e\uff0c\u9664\u4e86\u5f02\u5e38\u88ab\u52a8\u9000\u51fa\u6d88\u8d39\u7ec4\uff0c\u4e5f\u53ef\u4ee5\u8c03\u7528LeaveGroupRequest\u8bf7\u6c42\u4e3b\u52a8\u9000\u51fa\u6d88\u8d39\u8005\uff0c\u6216\u8005\u4f7f\u7528unsubscrible\u65b9\u6cd5\u53d6\u6d88\u5bf9\u67d0\u4e9b\u4e3b\u9898\u7684\u8ba2\u9605\uff0c\u90fd\u53ef\u4ee5\u89e6\u53d1\u518d\u5747\u8861\u3002<\/h4>\n","protected":false},"excerpt":{"rendered":"<p>Kafka\u4e2d\u6d88\u8d39\u8005\u4ee5\u6d88\u8d39\u7ec4\u7684\u5f62\u5f0f\u5b58\u5728\uff0c\u6d88\u8d39\u7ec4\u6765\u6d88\u8d39\u6bcf\u4e2a\u4e3b\u9898\u4e2d\u5206\u533a\u7684\u6570\u636e\uff0c\u56e0\u4e3a\u4e3b\u9898\u4e2d\u7684\u5206\u533a\u6570\u548c\u6d88\u8d39\u8005\u6570\u91cf\u5e76\u4e0d\u4e00\u4e00\u5bf9\u5e94\uff0c\u8fd9\u65f6\u5019\u5c31\u6d89\u53ca\u5230\u5982\u4f55\u4e3a\u6bcf\u4e2a\u6d88\u8d39\u8005\u5206\u914d\u5206\u533a\uff0c\u800c\u5f53\u6709\u6d88\u8d39\u8005\u5728\u4e2d\u9014\u9000\u51fa\u65f6\uff0c\u5c31\u4f1a\u89e6\u53d1\u518d\u5747\u8861\u7684\u53d1\u751f\uff0c\u518d\u91cd\u65b0\u4e3a\u5269\u4f59\u7684\u6d88\u8d39\u8005\u5206\u914d\u5206\u533a\u3002\u6bcf\u4e2a\u6d88\u8d39\u7ec4\u5728\u670d\u52a1\u7aef\u5bf9\u5e94\u4e00\u4e2aGroupCoordinator\u5bf9\u5176\u8fdb\u884c\u7ba1\u7406\uff0c\u800c\u6d88\u8d39\u8005\u5ba2\u6237\u7aef\u4e2d\u7684ConsumerCoordinator\u7ec4\u4ef6\u8d1f\u8d23\u4e0eGroupCoordinator\u8fdb\u884c\u4ea4\u4e92\uff0c\u5b83\u4eec\u8d1f\u8d23\u6267\u884c\u5206\u533a\u7684\u5206\u914d\uff0c\u4ee5\u53ca\u6d88\u8d39\u8005\u518d\u5747\u8861\u7684\u64cd\u4f5c\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,14],"tags":[],"class_list":["post-1152","post","type-post","status-publish","format-standard","hentry","category-kafka-hadoop","category-programme"],"_links":{"self":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/1152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/comments?post=1152"}],"version-history":[{"count":1,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/1152\/revisions"}],"predecessor-version":[{"id":1344,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/1152\/revisions\/1344"}],"wp:attachment":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/media?parent=1152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/categories?post=1152"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/tags?post=1152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}