Quantcast
Channel: DevOps tips & tricks
Viewing all articles
Browse latest Browse all 181

Apacha Kafka Partition replications

$
0
0
HOWTO 

 Partition replications 
Topic with one partition that is replicated 3 times
$ bin/kafka-topics.sh --bootstrap-server localhost:9094 --create --topic test_topic_2 --replication-factor 3
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.
Created topic test_topic_2.
[dave@dave kafka_2.12-3.5.1]$ bin/kafka-topics.sh --bootstrap-server localhost:9094 --describe --topic test_topic_2
Topic: test_topic_2    TopicId: q-EXSFY7RCq3RpSDblxW9Q    PartitionCount: 1    ReplicationFactor: 3    Configs: 
    Topic: test_topic_2    Partition: 0    Leader: 103    Replicas: 103,102,106    Isr: 103,102,106

server log
[2023-10-10 10:33:55,854] WARN [ReplicaFetcher replicaId=106, leaderId=103, fetcherId=0] Received UNKNOWN_TOPIC_ID from the leader for partition test_topic_2-0. This error may be returned transiently when the partition is being created or deleted, but it is not expected to persist. (kafka.server.ReplicaFetcherThread)

Topic with three partitions that are replicated
$ bin/kafka-topics.sh --bootstrap-server localhost:9094 --create --topic test_topic_3 --replication-factor 3 --partitions 3
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.
Created topic test_topic_3.

$ bin/kafka-topics.sh --bootstrap-server localhost:9094 --describe --topic test_topic_3
Topic: test_topic_3    TopicId: lMuEiHIXSZGtJnSkdxSdUg    PartitionCount: 3    ReplicationFactor: 3    Configs: 
    Topic: test_topic_3    Partition: 0    Leader: 106    Replicas: 106,103,102    Isr: 106,103,102
    Topic: test_topic_3    Partition: 1    Leader: 103    Replicas: 103,102,106    Isr: 103,102,106
    Topic: test_topic_3    Partition: 2    Leader: 102    Replicas: 102,106,103    Isr: 102,106,103

Kafka logs
$ ls  -lt /app/kafka/logs2/
total 32
-rw-r--r--. 1 dave dave  72 Oct 10 10:41 replication-offset-checkpoint
-rw-r--r--. 1 dave dave   4 Oct 10 10:40 log-start-offset-checkpoint
-rw-r--r--. 1 dave dave  72 Oct 10 10:40 recovery-point-offset-checkpoint
drwxr-xr-x. 1 dave dave 242 Oct 10 10:37 test_topic_3-0
drwxr-xr-x. 1 dave dave 242 Oct 10 10:37 test_topic_3-1
drwxr-xr-x. 1 dave dave 242 Oct 10 10:37 test_topic_3-2
drwxr-xr-x. 1 dave dave 242 Oct 10 10:33 test_topic_2-0
-rw-r--r--. 1 dave dave  91 Oct 10 10:04 meta.properties
-rw-r--r--. 1 dave dave   0 Oct 10 09:53 cleaner-offset-checkpoint

Specify replica assignments
$ bin/kafka-topics.sh --bootstrap-server localhost:9094 --create --topic test_topic_4 --replica-assignment 102:103,103:106
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.
[dave@dave kafka_2.12-3.5.1]$ bin/kafka-topics.sh --bootstrap-server localhost:9094 --create --topic test_topic_5 --replica-assignment 102:103:106
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.
Created topic test_topic_5.

describe topic
$ bin/kafka-topics.sh --bootstrap-server localhost:9094 --describe --topic test_topic_3
Topic: test_topic_3    TopicId: lMuEiHIXSZGtJnSkdxSdUg    PartitionCount: 3    ReplicationFactor: 3    Configs: 
    Topic: test_topic_3    Partition: 0    Leader: 106    Replicas: 106,103,102    Isr: 106,103,102
    Topic: test_topic_3    Partition: 1    Leader: 103    Replicas: 103,102,106    Isr: 103,102,106
    Topic: test_topic_3    Partition: 2    Leader: 102    Replicas: 102,106,103    Isr: 102,106,103


Viewing all articles
Browse latest Browse all 181

Trending Articles