Appunni M
Appunni M

Reputation: 93

Setting log.retentions.hours for broker in Kafka 0.10.2.x

I am trying to set log.retenton.hours for broker level configuration for kafka 0.10.2x. But I am getting this error for below command.

kafka-configs.sh  --zookeeper zookeeper:2181 --entity-type brokers --entity-name 0 --alter --add-config log.retention.hours=-1

Error while executing config command requirement failed: Unknown Dynamic Configuration 'log.retention.hours'.
java.lang.IllegalArgumentException: requirement failed: Unknown Dynamic Configuration 'log.retention.hours'.
    at scala.Predef$.require(Predef.scala:277)
    at kafka.server.DynamicConfig$.$anonfun$validate$1(DynamicConfig.scala:101)
    at kafka.server.DynamicConfig$.$anonfun$validate$1$adapted(DynamicConfig.scala:100)
    at scala.collection.Iterator.foreach(Iterator.scala:929)
    at scala.collection.Iterator.foreach$(Iterator.scala:929)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1406)
    at kafka.server.DynamicConfig$.kafka$server$DynamicConfig$$validate(DynamicConfig.scala:100)
    at kafka.server.DynamicConfig$Broker$.validate(DynamicConfig.scala:59)
    at kafka.admin.AdminUtils$.changeBrokerConfig(AdminUtils.scala:555)
    at kafka.admin.ConfigCommand$.alterConfig(ConfigCommand.scala:105)
    at kafka.admin.ConfigCommand$.main(ConfigCommand.scala:68)
    at kafka.admin.ConfigCommand.main(ConfigCommand.scala)

Upvotes: 1

Views: 308

Answers (2)

OneCricketeer
OneCricketeer

Reputation: 191831

As the error says, that property is not dynamic (cannot be modified while the broker is running)

Plus, that feature shouldn't be possible with your version

From Kafka version 1.1 onwards, some of the broker configs can be updated without restarting the broker

You can set retention per topic level, otherwise, you need to edit the server.properties file of every broker and gracefully reboot them

I'm sure you have a good reason for "disabling" retention, but I would suggest trying compacted topics first

Upvotes: 2

Nishu Tayal
Nishu Tayal

Reputation: 20860

log.retention.hours is read-only property at broker level, so it can't be changed using kafka-config.sh dynamically.

Change it in server.properties and restart the brokers.

Here are the details for readonly or dynamic broker config. https://kafka.apache.org/documentation/#dynamicbrokerconfigs

Upvotes: 2

Related Questions