Back

KAFKA

Open topic to write messages:
./kafka-console-producer.sh --broker-list <broker1>:6670,<broker2>:6670,<broker3>:6670 --topic <topic name> --security-protocol SASL_PLAINTEXT
Open topic to read messages
./kafka-console-consumer.sh --zookeeper <zookeeper host1>:2181,<zookeeper host2>:2181,<zookeeper host3>:2181 --from-beginning --topic <topic name> --security-protocol SASL_PLAINTEXT


Clearing A Topic

--set retention.ms to a small value, then wait a minute
kafka-configs --zookeeper <zookeeper host1>:2181,<zookeeper host2>:2181,<zookeeper host3>:2181 --entity-type topics --alter --add-config retention.ms=1000 --entity-name <topic name>

–check if the value set successfully:

kafka-configs --zookeeper <zookeeper host1>:2181,<zookeeper host2>:2181,<zookeeper host3>:2181 --entity-type topics --describe --entity-name <topic name>

–Check if topic is empty by consuming:

–restore the default retention.ms value

kafka-configs --zookeeper <zookeeper host1>:2181,<zookeeper host2>:2181,<zookeeper host3>:2181 --entity-type topics --alter --delete-config retention.ms --entity-name <topic name>