log.retention.hours
is a property of a broker which is used as a default value when a topic is created. When you change configurations of currently running topic using kafka-topics.sh
, you should specify a topic-level property.
A topic-level property for log retention time is retention.ms
.
From Topic-level configuration in Kafka 0.8.1 documentation:
So the correct command depends on the version. Up to 0.8.2 (although docs still show its use up to 0.10.1) use kafka-topics.sh --alter
and after 0.10.2 (or perhaps from 0.9.0 going forward) use kafka-configs.sh --alter
$ bin/kafka-topics.sh --zookeeper zk.yoursite.com --alter --topic as-access --config retention.ms=86400000
You can check whether the configuration is properly applied with the following command.
$ bin/kafka-topics.sh --describe --zookeeper zk.yoursite.com --topic as-access
Then you will see something like below.
Topic:as-access PartitionCount:3 ReplicationFactor:3 Configs:retention.ms=86400000