Linux系統Kafka集羣搭建與簡單測試

Kafka安裝

  • Zookeeper集羣搭建,可參考Linux系統Zookeeper集羣配置
  • 上傳kafka安裝包並解壓
  • [root@localhost ~]# cd /home/listen
    [root@localhost listen]# ll
    total 8
    drwxr-xr-x.  3 listen listen   23 Apr 27 01:48 codis
    drwxr-xr-x.  3 root   root     19 May 18 19:37 dubbox
    drwxrwxr-x.  3 listen listen   48 Apr 26 20:16 go
    drwxrwxr-x.  4 listen listen   64 May 13 03:14 gradle
    drwxrwxr-x.  2 listen listen   35 Apr 26 19:53 jdk
    drwxr-xr-x.  3 root   root     64 May 18 18:46 maven
    drwxrwxr-x.  4 listen listen  100 May  3 00:52 nginx
    drwxrwxr-x.  4 listen listen   66 Apr 26 19:31 redis
    drwxrwxr-x.  3 listen listen   94 May 10 00:42 session
    drwxrwxr-x.  4 listen listen 4096 May 10 17:58 tomcat
    drwxrwxr-x. 10 listen listen 4096 May 11 03:22 zookeeper
    [root@localhost listen]# mkdir kafka
    [root@localhost listen]# cd kafka/
    [root@localhost kafka]# ll
    total 30840
    -rw-r--r--. 1 root root 31579147 May 30 00:36 kafka_2.11-0.10.0.0.tgz
    [root@localhost kafka]# tar -xvf kafka_2.11-0.10.0.0.tgz
  • 編輯配置文件

  • [root@localhost config]# pwd
    /home/listen/kafka/kafka_2.11-0.10.0.0/config
    [root@localhost config]# ls
    connect-console-sink.properties    connect-file-sink.properties    connect-standalone.properties  producer.properties     zookeeper.properties
    connect-console-source.properties  connect-file-source.properties  consumer.properties            server.properties
    connect-distributed.properties     connect-log4j.properties        log4j.properties               tools-log4j.properties
    [root@localhost config]# vi server.properties
     這個是server.properties文件內容
    # Licensed to the Apache Software Foundation (ASF) under one or more
    # contributor license agreements.  See the NOTICE file distributed with
    # this work for additional information regarding copyright ownership.
    # The ASF licenses this file to You under the Apache License, Version 2.0
    # (the "License"); you may not use this file except in compliance with
    # the License.  You may obtain a copy of the License at
    #
    #    http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    # see kafka.server.KafkaConfig for additional details and defaults
    
    ############################# Server Basics #############################
    
    # The id of the broker. This must be set to a unique integer for each broker.
    broker.id=0
    
    ############################# Socket Server Settings #############################
    
    # The address the socket server listens on. It will get the value returned from 
    # java.net.InetAddress.getCanonicalHostName() if not configured.
    #   FORMAT:
    #     listeners = security_protocol://host_name:port
    #   EXAMPLE:
    #     listeners = PLAINTEXT://your.host.name:9092
    listeners=PLAINTEXT://:9092
    
    # Hostname and port the broker will advertise to producers and consumers. If not set, 
    # it uses the value for "listeners" if configured.  Otherwise, it will use the value
    # returned from java.net.InetAddress.getCanonicalHostName().
    #advertised.listeners=PLAINTEXT://your.host.name:9092
    advertised.listeners=PLAINTEXT://192.168.75.141:9092
    
    port=9092
    host.name=192.168.75.141
    
    advertised.host.name=192.168.75.141
    advertised.port=9092
    # The number of threads handling network requests
    num.network.threads=3
    
    # The number of threads doing disk I/O
    num.io.threads=8
    
    # The send buffer (SO_SNDBUF) used by the socket server
    socket.send.buffer.bytes=102400
    
    # The receive buffer (SO_RCVBUF) used by the socket server
    socket.receive.buffer.bytes=102400
    
    # The maximum size of a request that the socket server will accept (protection against OOM)
    socket.request.max.bytes=104857600
    
    
    ############################# Log Basics #############################
    
    # A comma seperated list of directories under which to store log files
    log.dirs=/home/listen/kafka/kafka_2.11-0.10.0.0/logs/server0
    
    # The default number of log partitions per topic. More partitions allow greater
    # parallelism for consumption, but this will also result in more files across
    # the brokers.
    num.partitions=1
    
    # The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
    # This value is recommended to be increased for installations with data dirs located in RAID array.
    num.recovery.threads.per.data.dir=1
    
    ############################# Log Flush Policy #############################
    
    # Messages are immediately written to the filesystem but by default we only fsync() to sync
    # the OS cache lazily. The following configurations control the flush of data to disk.
    # There are a few important trade-offs here:
    #    1. Durability: Unflushed data may be lost if you are not using replication.
    #    2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
    #    3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to exceessive seeks.
    # The settings below allow one to configure the flush policy to flush data after a period of time or
    # every N messages (or both). This can be done globally and overridden on a per-topic basis.
    
    # The number of messages to accept before forcing a flush of data to disk
    #log.flush.interval.messages=10000
    
    # The maximum amount of time a message can sit in a log before we force a flush
    #log.flush.interval.ms=1000
    
    ############################# Log Retention Policy #############################
    
    # The following configurations control the disposal of log segments. The policy can
    # be set to delete segments after a period of time, or after a given size has accumulated.
    # A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
    # from the end of the log.
    
    # The minimum age of a log file to be eligible for deletion
    log.retention.hours=168
    
    # A size-based retention policy for logs. Segments are pruned from the log as long as the remaining
    # segments don't drop below log.retention.bytes.
    #log.retention.bytes=1073741824
    
    # The maximum size of a log segment file. When this size is reached a new log segment will be created.
    log.segment.bytes=1073741824
    
    # The interval at which log segments are checked to see if they can be deleted according
    # to the retention policies
    log.retention.check.interval.ms=300000
    
    ############################# Zookeeper #############################
    
    # Zookeeper connection string (see zookeeper docs for details).
    # This is a comma separated host:port pairs, each corresponding to a zk
    # server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
    # You can also append an optional chroot string to the urls to specify the
    # root directory for all kafka znodes.
    zookeeper.connect=192.168.75.141:2181,192.168.75.141:2182,192.168.75.141:2183,192.168.75.141:2184,192.168.75.141:2185
    
    # Timeout in ms for connecting to zookeeper
    zookeeper.connection.timeout.ms=6000

     

  • 增長集羣的配置文件server1.properties
  • [root@localhost config]# cp server.properties server1.properties 
    [root@localhost config]# vi server1.properties
     修改配置
    broker.id=1
    listeners=PLAINTEXT://:9093
    advertised.listeners=PLAINTEXT://192.168.75.141:9093
    port=9093
    host.name=192.168.75.141
    advertised.host.name=192.168.75.141
    advertised.port=9093
    log.dirs=/home/listen/kafka/kafka_2.11-0.10.0.0/logs/server1
    #其餘配置和server.properties同樣

     

  •  增長集羣的配置文件server2.properties
  • [root@localhost config]# cp server.properties server2.properties 
    [root@localhost config]# vi server2.properties

    修改配置java

  • broker.id=2
    listeners=PLAINTEXT://:9094
    advertised.listeners=PLAINTEXT://192.168.75.141:9094
    port=9094
    host.name=192.168.75.141
    advertised.host.name=192.168.75.141
    advertised.port=9094
    log.dirs=/home/listen/kafka/kafka_2.11-0.10.0.0/logs/server2
    #其餘配置和server.properties同樣

     

  • 建立日誌文件目錄
  • [root@localhost ~]# cd /home/listen/kafka/
    [root@localhost kafka]# ll
    total 30840
    drwxr-xr-x. 6 root root       83 May 17 21:32 kafka_2.11-0.10.0.0
    -rw-r--r--. 1 root root 31579147 May 30 00:36 kafka_2.11-0.10.0.0.tgz
    [root@localhost kafka]# cd kafka_2.11-0.10.0.0/
    [root@localhost kafka_2.11-0.10.0.0]# ll
    total 48
    drwxr-xr-x. 3 root root  4096 May 17 21:32 bin
    drwxr-xr-x. 2 root root  4096 May 30 00:39 config
    drwxr-xr-x. 2 root root  4096 May 30 00:36 libs
    -rw-r--r--. 1 root root 28824 May 17 21:26 LICENSE
    -rw-r--r--. 1 root root   336 May 17 21:26 NOTICE
    drwxr-xr-x. 2 root root    46 May 17 21:32 site-docs
    [root@localhost kafka_2.11-0.10.0.0]# pwd
    /home/listen/kafka/kafka_2.11-0.10.0.0
    [root@localhost kafka_2.11-0.10.0.0]# mkdir logs
    [root@localhost kafka_2.11-0.10.0.0]# cd logs
    [root@localhost logs]# mkdir server0
    [root@localhost logs]# mkdir server1
    [root@localhost logs]# mkdir server2
    [root@localhost logs]# pwd
    /home/listen/kafka/kafka_2.11-0.10.0.0/logs
    [root@localhost logs]#
  • 先啓動Zookeeper集羣

  • 具體操做方法請查看Linux系統Zookeeper集羣配置
  • 而後啓動Kafka集羣

  • [root@localhost kafka_2.11-0.10.0.0]# pwd
    /home/listen/kafka/kafka_2.11-0.10.0.0
    [root@localhost kafka_2.11-0.10.0.0]# bin/kafka-server-start.sh -daemon config/server.properties 
    [root@localhost kafka_2.11-0.10.0.0]# pwd
    /home/listen/kafka/kafka_2.11-0.10.0.0
    [root@localhost kafka_2.11-0.10.0.0]# bin/kafka-server-start.sh -daemon config/server1.properties 
    [root@localhost kafka_2.11-0.10.0.0]# pwd
    /home/listen/kafka/kafka_2.11-0.10.0.0
    [root@localhost kafka_2.11-0.10.0.0]# bin/kafka-server-start.sh -daemon config/server2.properties 
    #以上是在後臺啓動,若是須要在console控制檯啓動看到運行信息,可參考下面的方式,這種方式須要開多窗口,不然沒法啓動第二個第三個節點
    [root@localhost kafka_2.11-0.10.0.0]# pwd
    /home/listen/kafka/kafka_2.11-0.10.0.0
    [root@localhost kafka_2.11-0.10.0.0]# bin/kafka-server-start.sh config/server.properties 
    [root@localhost kafka_2.11-0.10.0.0]# pwd
    /home/listen/kafka/kafka_2.11-0.10.0.0
    [root@localhost kafka_2.11-0.10.0.0]# bin/kafka-server-start.sh config/server1.properties 
    [root@localhost kafka_2.11-0.10.0.0]# pwd
    /home/listen/kafka/kafka_2.11-0.10.0.0
    [root@localhost kafka_2.11-0.10.0.0]# bin/kafka-server-start.sh config/server2.properties
  • 啓動成功,鏈接Zookeeper查看Kafka相關信息
  • [root@localhost zookeeper]# pwd
    /home/listen/zookeeper
    [root@localhost zookeeper]# zookeeper-2181/bin/zkCli.sh -server 192.168.75.141:2181
    [zk: 192.168.75.141:2181(CONNECTED) 0] ls /
    [dubbo, isr_change_notification, admin, zookeeper, consumers, config, controller, zk, brokers, controller_epoch]
    [zk: 192.168.75.141:2181(CONNECTED) 1] ls /brokers
    [seqid, topics, ids]
    [zk: 192.168.75.141:2181(CONNECTED) 2] ls /brokers/seqid
    []
    [zk: 192.168.75.141:2181(CONNECTED) 3] ls /brokers/topics
    []
    [zk: 192.168.75.141:2181(CONNECTED) 4] ls /brokers/ids   
    [2, 1, 0]
    [zk: 192.168.75.141:2181(CONNECTED) 5]
      
  • Kafka經常使用命令操做
  • #手動建立topic,默認的topic只有一個分區,因此手動建立最佳
    [root@localhost ~]# cd /home/listen/kafka/kafka_2.11-0.10.0.0/
    #建立備份2個,分區2個,名稱爲meng的topic
    [root@localhost kafka_2.11-0.10.0.0]# bin/kafka-topics.sh --create --zookeeper 192.168.75.141:2181,192.168.75.141:2182,192.168.75.141:2183,192.168.75.141:2184,192.168.75.141:2185 --replication-factor 2 --partitions 2 --topic meng
    Created topic "meng".
    [root@localhost kafka_2.11-0.10.0.0]#
    #建立備份2個,分區8個,名稱爲t-meng的topic
    [root@localhost bin]# ./kafka-topics.sh --create --zookeeper 192.168.75.141:2181,192.168.75.141:2182,192.168.75.141:2183,192.168.75.141:2184,192.168.75.141:2185 --replication-factor 2 --partitions 8 --topic t-meng
    Created topic "t-meng".
    [root@localhost bin]#
    #將剛纔的t-meng topic的分區修改成10個,即增長2個
    [root@localhost bin]# ./kafka-topics.sh --alter --zookeeper 192.168.75.141:2181,192.168.75.141:2182,192.168.75.141:2183,192.168.75.141:2184,192.168.75.141:2185 --partitions 10 --topic t-meng
    
    WARNING: If partitions are increased for a topic that has a key, the partition logic or ordering of the messages will be affected
    Adding partitions succeeded!
    [root@localhost bin]#
    #減小分區,報錯,分區只能增長不能減小
    [root@localhost bin]# ./kafka-topics.sh --alter --zookeeper 192.168.75.141:2181,192.168.75.141:2182,192.168.75.141:2183,192.168.75.141:2184,192.168.75.141:2185 --partitions 6 --topic t-meng
    WARNING: If partitions are increased for a topic that has a key, the partition logic or ordering of the messages will be affected
    Error while executing topic command : The number of partitions for a topic can only be increased
    [2016-06-02 00:58:31,143] ERROR kafka.admin.AdminOperationException: The number of partitions for a topic can only be increased
    	at kafka.admin.AdminUtils$.addPartitions(AdminUtils.scala:262)
    	at kafka.admin.TopicCommand$$anonfun$alterTopic$1.apply(TopicCommand.scala:148)
    	at kafka.admin.TopicCommand$$anonfun$alterTopic$1.apply(TopicCommand.scala:125)
    	at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
    	at kafka.admin.TopicCommand$.alterTopic(TopicCommand.scala:125)
    	at kafka.admin.TopicCommand$.main(TopicCommand.scala:63)
    	at kafka.admin.TopicCommand.main(TopicCommand.scala)
     (kafka.admin.TopicCommand$)
    [root@localhost bin]#
    #查看分區信息
    [root@localhost kafka_2.11-0.10.0.0]# bin/kafka-topics.sh --describe --zookeeper 192.168.75.141:2181,192.168.75.141:2182,192.168.75.141:2183,192.168.75.141:2184,192.168.75.141:2185  --topic meng
    Topic:meng	PartitionCount:2	ReplicationFactor:2	Configs:
    	Topic: meng	Partition: 0	Leader: 1	Replicas: 1,2	Isr: 1,2
    	Topic: meng	Partition: 1	Leader: 2	Replicas: 2,0	Isr: 2,0
    [root@localhost kafka_2.11-0.10.0.0]#
    
    #列出全部的topic
    [root@localhost bin]# ./kafka-topics.sh --zookeeper 192.168.75.141:2181,192.168.75.141:2182,192.168.75.141:2183,192.168.75.141:2184,192.168.75.141:2185 --list
    __consumer_offsets
    bar
    foo
    meng
    my-topic
    qiang
    t-zhou
    t-zhou-2
    t-zhou-3
    test
    zhou
    [root@localhost bin]#
    #刪除一個topic,慎用
    [root@localhost bin]# ./kafka-topics.sh --delete --topic t-meng --zookeeper 192.168.75.141:2181,192.168.75.141:2182,192.168.75.141:2183,192.168.75.141:2184,192.168.75.141:2185
    Topic t-meng is marked for deletion.
    Note: This will have no impact if delete.topic.enable is not set to true.
    [root@localhost bin]# ./kafka-topics.sh --list --zookeeper 192.168.75.141:2181,192.168.75.141:2182,192.168.75.141:2183,192.168.75.141:2184,192.168.75.141:2185
    __consumer_offsets
    bar
    foo
    meng
    my-topic
    qiang
    t-meng - marked for deletion
    t-zhou
    t-zhou-2
    t-zhou-3
    test
    zhou
    #marked for deletion標示爲刪除的標記,意思爲邏輯刪除,真正須要刪除須要在server.properties文件中配置,標記爲刪除的topic其實還可使用,沒有任何的區別。
    #delete.topic.enable=true #是否真正的刪除指定的topic,默認爲false,可選配置
    
    #查看全部topic的分佈描述
    [root@localhost bin]# ./kafka-topics.sh  --zookeeper 192.168.75.141:2181,192.168.75.141:2182,192.168.75.141:2183,192.168.75.141:2184,192.168.75.141:2185 --describe
    Topic:__consumer_offsets	PartitionCount:50	ReplicationFactor:3	Configs:segment.bytes=104857600,cleanup.policy=compact,compression.type=uncompressed
    	Topic: __consumer_offsets	Partition: 0	Leader: 1	Replicas: 1,2,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 1	Leader: 2	Replicas: 2,0,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 2	Leader: 0	Replicas: 0,1,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 3	Leader: 1	Replicas: 1,0,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 4	Leader: 2	Replicas: 2,1,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 5	Leader: 0	Replicas: 0,2,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 6	Leader: 1	Replicas: 1,2,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 7	Leader: 2	Replicas: 2,0,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 8	Leader: 0	Replicas: 0,1,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 9	Leader: 1	Replicas: 1,0,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 10	Leader: 2	Replicas: 2,1,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 11	Leader: 0	Replicas: 0,2,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 12	Leader: 1	Replicas: 1,2,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 13	Leader: 2	Replicas: 2,0,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 14	Leader: 0	Replicas: 0,1,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 15	Leader: 1	Replicas: 1,0,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 16	Leader: 2	Replicas: 2,1,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 17	Leader: 0	Replicas: 0,2,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 18	Leader: 1	Replicas: 1,2,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 19	Leader: 2	Replicas: 2,0,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 20	Leader: 0	Replicas: 0,1,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 21	Leader: 1	Replicas: 1,0,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 22	Leader: 2	Replicas: 2,1,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 23	Leader: 0	Replicas: 0,2,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 24	Leader: 1	Replicas: 1,2,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 25	Leader: 2	Replicas: 2,0,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 26	Leader: 0	Replicas: 0,1,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 27	Leader: 1	Replicas: 1,0,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 28	Leader: 2	Replicas: 2,1,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 29	Leader: 0	Replicas: 0,2,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 30	Leader: 1	Replicas: 1,2,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 31	Leader: 2	Replicas: 2,0,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 32	Leader: 0	Replicas: 0,1,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 33	Leader: 1	Replicas: 1,0,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 34	Leader: 2	Replicas: 2,1,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 35	Leader: 0	Replicas: 0,2,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 36	Leader: 1	Replicas: 1,2,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 37	Leader: 2	Replicas: 2,0,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 38	Leader: 0	Replicas: 0,1,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 39	Leader: 1	Replicas: 1,0,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 40	Leader: 2	Replicas: 2,1,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 41	Leader: 0	Replicas: 0,2,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 42	Leader: 1	Replicas: 1,2,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 43	Leader: 2	Replicas: 2,0,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 44	Leader: 0	Replicas: 0,1,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 45	Leader: 1	Replicas: 1,0,2	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 46	Leader: 2	Replicas: 2,1,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 47	Leader: 0	Replicas: 0,2,1	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 48	Leader: 1	Replicas: 1,2,0	Isr: 0,1,2
    	Topic: __consumer_offsets	Partition: 49	Leader: 2	Replicas: 2,0,1	Isr: 0,1,2
    Topic:bar	PartitionCount:1	ReplicationFactor:1	Configs:
    	Topic: bar	Partition: 0	Leader: 2	Replicas: 2	Isr: 2
    Topic:foo	PartitionCount:1	ReplicationFactor:1	Configs:
    	Topic: foo	Partition: 0	Leader: 1	Replicas: 1	Isr: 1
    Topic:meng	PartitionCount:2	ReplicationFactor:2	Configs:
    	Topic: meng	Partition: 0	Leader: 1	Replicas: 1,2	Isr: 1,2
    	Topic: meng	Partition: 1	Leader: 2	Replicas: 2,0	Isr: 0,2
    Topic:my-topic	PartitionCount:1	ReplicationFactor:1	Configs:
    	Topic: my-topic	Partition: 0	Leader: 0	Replicas: 0	Isr: 0
    Topic:qiang	PartitionCount:1	ReplicationFactor:1	Configs:
    	Topic: qiang	Partition: 0	Leader: 0	Replicas: 0	Isr: 0
    Topic:t-meng	PartitionCount:10	ReplicationFactor:2	Configs:
    	Topic: t-meng	Partition: 0	Leader: 0	Replicas: 0,2	Isr: 0,2
    	Topic: t-meng	Partition: 1	Leader: 1	Replicas: 1,0	Isr: 1,0
    	Topic: t-meng	Partition: 2	Leader: 2	Replicas: 2,1	Isr: 2,1
    	Topic: t-meng	Partition: 3	Leader: 0	Replicas: 0,1	Isr: 0,1
    	Topic: t-meng	Partition: 4	Leader: 1	Replicas: 1,2	Isr: 1,2
    	Topic: t-meng	Partition: 5	Leader: 2	Replicas: 2,0	Isr: 2,0
    	Topic: t-meng	Partition: 6	Leader: 0	Replicas: 0,2	Isr: 0,2
    	Topic: t-meng	Partition: 7	Leader: 1	Replicas: 1,0	Isr: 1,0
    	Topic: t-meng	Partition: 8	Leader: 2	Replicas: 2,0	Isr: 2,0
    	Topic: t-meng	Partition: 9	Leader: 0	Replicas: 0,2	Isr: 0,2
    Topic:t-zhou	PartitionCount:1	ReplicationFactor:1	Configs:
    	Topic: t-zhou	Partition: 0	Leader: 2	Replicas: 2	Isr: 2
    Topic:t-zhou-2	PartitionCount:1	ReplicationFactor:1	Configs:
    	Topic: t-zhou-2	Partition: 0	Leader: 0	Replicas: 0	Isr: 0
    Topic:t-zhou-3	PartitionCount:1	ReplicationFactor:1	Configs:
    	Topic: t-zhou-3	Partition: 0	Leader: 0	Replicas: 0	Isr: 0
    Topic:test	PartitionCount:1	ReplicationFactor:1	Configs:
    	Topic: test	Partition: 0	Leader: 1	Replicas: 1	Isr: 1
    Topic:zhou	PartitionCount:1	ReplicationFactor:1	Configs:
    	Topic: zhou	Partition: 0	Leader: 0	Replicas: 0	Isr: 0
    [root@localhost bin]#
    
    #查看指定的topic信息
    [root@localhost bin]# ./kafka-topics.sh  --zookeeper 192.168.75.141:2181,192.168.75.141:2182,192.168.75.141:2183,192.168.75.141:2184,192.168.75.141:2185 --describe --topic t-meng
    Topic:t-meng	PartitionCount:10	ReplicationFactor:2	Configs:
    	Topic: t-meng	Partition: 0	Leader: 0	Replicas: 0,2	Isr: 0,2
    	Topic: t-meng	Partition: 1	Leader: 1	Replicas: 1,0	Isr: 1,0
    	Topic: t-meng	Partition: 2	Leader: 2	Replicas: 2,1	Isr: 2,1
    	Topic: t-meng	Partition: 3	Leader: 0	Replicas: 0,1	Isr: 0,1
    	Topic: t-meng	Partition: 4	Leader: 1	Replicas: 1,2	Isr: 1,2
    	Topic: t-meng	Partition: 5	Leader: 2	Replicas: 2,0	Isr: 2,0
    	Topic: t-meng	Partition: 6	Leader: 0	Replicas: 0,2	Isr: 0,2
    	Topic: t-meng	Partition: 7	Leader: 1	Replicas: 1,0	Isr: 1,0
    	Topic: t-meng	Partition: 8	Leader: 2	Replicas: 2,0	Isr: 2,0
    	Topic: t-meng	Partition: 9	Leader: 0	Replicas: 0,2	Isr: 0,2
    [root@localhost bin]#
  • 客戶端測試Kafka

  • 可參考 Kafka集羣簡單測試
相關文章
相關標籤/搜索