{"id":7511,"date":"2021-07-16T16:10:09","date_gmt":"2021-07-16T08:10:09","guid":{"rendered":"https:\/\/www.gbase8.cn\/?p=7511"},"modified":"2022-09-05T09:28:27","modified_gmt":"2022-09-05T01:28:27","slug":"kafka-%e5%a2%9e%e5%8a%a0topic%e5%88%86%e5%8c%bapartition%e6%95%b0%e9%87%8f%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/7511","title":{"rendered":"Kafka \u589e\u52a0TOPIC\u5206\u533apartition\u6570\u91cf\u7684\u65b9\u6cd5"},"content":{"rendered":"<p>\u672c\u6587\u4ecb\u7ecd\u5728kafka\u4e2d\uff0c\u589e\u52a0\u5206\u533apartition\u7684\u65b9\u6cd5\uff0c\u4e0d\u80fd\u51cf\u5c11\u5206\u533a\u6570\u91cf\uff0c\u53ea\u80fd\u589e\u52a0<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Directory Navigation<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2aaa9aaaf15\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2aaa9aaaf15\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/7511\/#%E5%8E%9F%E5%A7%8BTOPIC%E5%88%86%E5%8C%BApartition\" >\u539f\u59cbTOPIC\u5206\u533apartition<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/7511\/#%E5%A2%9E%E5%8A%A0%E5%88%86%E5%8C%BApartition\" >\u589e\u52a0\u5206\u533apartition<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/7511\/#%E6%9F%A5%E7%9C%8BTOPIC%E5%A2%9E%E5%8A%A0%E5%88%86%E5%8C%BApartition%E7%9A%84%E6%95%88%E6%9E%9C\" >\u67e5\u770bTOPIC\u589e\u52a0\u5206\u533apartition\u7684\u6548\u679c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.gbase8.cn\/en\/7511\/#%E5%87%8F%E5%B0%91TOPIC%E7%9A%84%E5%88%86%E5%8C%BApartition\" >\u51cf\u5c11TOPIC\u7684\u5206\u533apartition<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8E%9F%E5%A7%8BTOPIC%E5%88%86%E5%8C%BApartition\"><\/span>\u539f\u59cbTOPIC\u5206\u533apartition<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u6839\u672c\u6ca1\u5206\u533a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@rh7_210 kafka]#  bin\/kafka-topics.sh --describe --topic gbase8a --bootstrap-server localhost:9092\r\nTopic: gbase8a  TopicId: pGWySKY_SWehGsMXihJhkA PartitionCount: 1       ReplicationFactor: 1    Configs: segment.bytes=1073741824\r\n        Topic: gbase8a  Partition: 0    Leader: 0       Replicas: 0     Isr: 0\r\n&#91;root@rh7_210 kafka]#<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%A2%9E%E5%8A%A0%E5%88%86%E5%8C%BApartition\"><\/span>\u589e\u52a0\u5206\u533apartition<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u901a\u8fc7--alter\u547d\u4ee4\uff0c\u548c--partition \u53c2\u6570\u6307\u5b9a\u65b0\u5206\u533a\u6570\u91cf\u3002\u6ce8\u610f\u53ea\u80fd\u589e\u52a0\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@rh7_210 kafka]#  bin\/kafka-topics.sh --alter --partitions 3  --topic gbase8a --bootstrap-server localhost:9092<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%9F%A5%E7%9C%8BTOPIC%E5%A2%9E%E5%8A%A0%E5%88%86%E5%8C%BApartition%E7%9A%84%E6%95%88%E6%9E%9C\"><\/span>\u67e5\u770bTOPIC\u589e\u52a0\u5206\u533apartition\u7684\u6548\u679c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u53d8\u6210\u4e863\u4e2a\u5206\u533a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\r\n&#91;root@rh7_210 kafka]#  bin\/kafka-topics.sh --describe --topic gbase8a --bootstrap-server localhost:9092\r\nTopic: gbase8a  TopicId: pGWySKY_SWehGsMXihJhkA PartitionCount: 3       ReplicationFactor: 1    Configs: segment.bytes=1073741824\r\n        Topic: gbase8a  Partition: 0    Leader: 0       Replicas: 0     Isr: 0\r\n        Topic: gbase8a  Partition: 1    Leader: 0       Replicas: 0     Isr: 0\r\n        Topic: gbase8a  Partition: 2    Leader: 0       Replicas: 0     Isr: 0\r\n&#91;root@rh7_210 kafka]#<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%87%8F%E5%B0%91TOPIC%E7%9A%84%E5%88%86%E5%8C%BApartition\"><\/span>\u51cf\u5c11TOPIC\u7684\u5206\u533apartition<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u62a5\u9519\uff0c\u539f\u6709\u5206\u533a\u6570\u91cf\u5927\u4e8e\u8bf7\u6c42\u6570\u91cf\u3002Topic currently has 3 partitions, which is higher than the requested 2.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\r&#91;root@rh7_210 kafka]#  bin\/kafka-topics.sh --alter --partitions 2  --topic gbase8a --bootstrap-server localhost:9092\r\nError while executing topic command : Topic currently has 3 partitions, which is higher than the requested 2.\r\n&#91;2021-07-16 16:05:36,893] ERROR org.apache.kafka.common.errors.InvalidPartitionsException: Topic currently has 3 partitions, which is higher than the requested 2.\r\n (kafka.admin.TopicCommand$)\r\n&#91;root@rh7_210 kafka]<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>Kafka \u589e\u52a0TOPIC\u5206\u533apartition\u6570\u91cf\u7684\u65b9\u6cd5<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79],"tags":[106,80],"class_list":["post-7511","post","type-post","status-publish","format-standard","hentry","category-79","tag-kafka","tag-80"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/7511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=7511"}],"version-history":[{"count":4,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/7511\/revisions"}],"predecessor-version":[{"id":7515,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/7511\/revisions\/7515"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=7511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=7511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=7511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}