22
loading...
This website collects cookies to deliver better user experience
wget https://apachemirror.wuchna.com/kafka/2.8.0/kafka_2.12-2.8.0.tgz
tar xzf kafka_2.12-2.8.0.tgz
cd kafka_2.12-2.8.0
config/kraft
folder inside the kafka home directory, you will see a file called server.properties
. This is a sample file which is provided by kafka, to show how kafka can be started without zookeepercd config/kraft
cp server.properties server1.properties
cp server.properties server2.properties
cp server.properties server3.properties
node.id=1
process.roles=broker,controller
inter.broker.listener.name=PLAINTEXT
controller.listener.names=CONTROLLER
listeners=PLAINTEXT://:9092,CONTROLLER://:19092
log.dirs=/tmp/server1/kraft-combined-logs
listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
controller.quorum.voters=1@localhost:19092,2@localhost:19093,3@localhost:19094
node.id=2
process.roles=broker,controller
controller.quorum.voters=1@localhost:19092,2@localhost:19093,3@localhost:19094
listeners=PLAINTEXT://:9093,CONTROLLER://:19093
inter.broker.listener.name=PLAINTEXT
controller.listener.names=CONTROLLER
log.dirs=/tmp/server2/kraft-combined-logs
listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
node.id=3
process.roles=broker,controller
controller.quorum.voters=1@localhost:19092,2@localhost:19093,3@localhost:19094
listeners=PLAINTEXT://:9094,CONTROLLER://:19094
inter.broker.listener.name=PLAINTEXT
controller.listener.names=CONTROLLER
log.dirs=/tmp/server3/kraft-combined-logs
listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
./bin/kafka-storage.sh random-uuid
./bin/kafka-storage.sh random-uuid
9dJzdGvfTPaCY4e8klXaDQ
./bin/kafka-storage.sh format -t <uuid> -c <server_config_location>
<uuid>
with the uuid that you got in the previous step. Replace <server_config_location>
with the server property files./bin/kafka-storage.sh format -t 9dJzdGvfTPaCY4e8klXaDQ -c ./config/kraft/server1.properties
./bin/kafka-storage.sh format -t 9dJzdGvfTPaCY4e8klXaDQ -c ./config/kraft/server2.properties
./bin/kafka-storage.sh format -t 9dJzdGvfTPaCY4e8klXaDQ -c ./config/kraft/server3.properties
$ ./bin/kafka-storage.sh format -t 9dJzdGvfTPaCY4e8klXaDQ -c ./config/kraft/server1.properties
Formatting /tmp/server1/kraft-combined-logs
$ ./bin/kafka-storage.sh format -t 9dJzdGvfTPaCY4e8klXaDQ -c ./config/kraft/server2.properties
Formatting /tmp/server2/kraft-combined-logs
$ ./bin/kafka-storage.sh format -t 9dJzdGvfTPaCY4e8klXaDQ -c ./config/kraft/server3.properties
Formatting /tmp/server3/kraft-combined-logs
export KAFKA_HEAP_OPTS="-Xmx200M –Xms100M"
./bin/kafka-server-start.sh -daemon ./config/kraft/server1.properties
./bin/kafka-server-start.sh -daemon ./config/kraft/server2.properties
./bin/kafka-server-start.sh -daemon ./config/kraft/server3.properties
./bin/kafka-topics.sh --create --topic kraft-test --partitions 3 --replication-factor 3 --bootstrap-server localhost:9092
bin/kafka-topics.sh --bootstrap-server localhost:9093 --list
$ bin/kafka-topics.sh --bootstrap-server localhost:9093 --list
kraft-test
bin/kafka-topics.sh --bootstrap-server localhost:9093 --describe --topic kraft-test
$ bin/kafka-topics.sh --bootstrap-server localhost:9093 --describe --topic kraft-test
Topic: kraft-test TopicId: vZKswHHlQk2mEOw0yzAGAA PartitionCount: 3 ReplicationFactor: 3 Configs: segment.bytes=1073741824
Topic: kraft-test Partition: 0 Leader: 3 Replicas: 3,2,1 Isr: 3,2,1
Topic: kraft-test Partition: 1 Leader: 2 Replicas: 2,3,1 Isr: 2,3,1
Topic: kraft-test Partition: 2 Leader: 2 Replicas: 2,3,1 Isr: 2,3,1
./bin/kafka-metadata-shell.sh --snapshot /tmp/server1/kraft-combined-logs/\@metadata-0/00000000000000000000.log
ls brokers/
>> ls brokers/
1 2 3
ls topics/
>> ls topics/
kraft-test
cat topics/kraft-test/0/data
>> cat topics/kraft-test/0/data
{
"partitionId" : 0,
"topicId" : "vZKswHHlQk2mEOw0yzAGAA",
"replicas" : [ 3, 2, 1 ],
"isr" : [ 3, 2, 1 ],
"removingReplicas" : null,
"addingReplicas" : null,
"leader" : 3,
"leaderEpoch" : 0,
"partitionEpoch" : 0
}
cat metadataQuorum/leader
>> cat metadataQuorum/leader
MetaLogLeader(nodeId=2, epoch=4)
exit
to get out of the metadata shellbin/kafka-console-producer.sh --broker-list localhost:9092 --topic kraft-test
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic kraft-test
$ bin/kafka-console-producer.sh --broker-list localhost:9092 --topic kraft-test
>message 1
>message 2
>message 3
>hello
>bye
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic kraft-test
message 1
message 2
message 3
hello
bye