Kafka-config User manual

The official instructions

Add/Remove entity config for a topic, client, user or broker.
Option                      Description
------                      -----------
--add-config <String>       Key Value pairs of configs to add. Square brackets
                              can be used to group values which contain commas:
                              'k1=v1,k2=[v1,v2,v2],k3=v3'. The following is a
                              list of valid configurations: For entity_type
                              'topics':
                            	cleanup.policy
                            	compression.type
                            	delete.retention.ms
                            	file.delete.delay.ms
                            	flush.messages
                            	flush.ms
                            	follower.replication.throttled.replicas
                            	index.interval.bytes
                            	leader.replication.throttled.replicas
                            	max.message.bytes
                            	message.format.version
                            	message.timestamp.difference.max.ms
                            	message.timestamp.type
                            	min.cleanable.dirty.ratio
                            	min.compaction.lag.ms
                            	min.insync.replicas
                            	preallocate
                            	retention.bytes
                            	retention.ms
                            	segment.bytes
                            	segment.index.bytes
                            	segment.jitter.ms
                            	segment.ms
                            	unclean.leader.election.enable
                            For entity_type 'brokers':
                            	follower.replication.throttled.rate
                            	leader.replication.throttled.rate
                            For entity_type 'users':
                            	request_percentage
                            	producer_byte_rate
                            	SCRAM-SHA-256
                            	SCRAM-SHA-512
                            	consumer_byte_rate
                            For entity_type 'clients':
                            	request_percentage
                            	producer_byte_rate
                            	consumer_byte_rate
                            Entity types 'users' and 'clients' may be specified
                              together to update config for clients of a
                              specific user.
--alter                     Alter the configuration for the entity.
--delete-config <String>    config keys to remove 'k1,k2'
--describe                  List configs for the given entity.
--entity-default            Default entity name for clients/users (applies to
                              corresponding entity type in command line)
--entity-name <String>      Name of entity (topic name/client id/user principal
                              name/broker id)
--entity-type <String>      Type of entity (topics/clients/users/brokers)
--force                     Suppress console prompts
--help                      Print usage information.
--zookeeper <String: urls>  REQUIRED: The connection string for the zookeeper
                              connection in the form host:port. Multiple URLS
                              can be given to allow fail-over.
Copy the code

Method of use

Kafka-config is more comprehensive in configuration modification than Kafka-topics. The user can specify the object of the config: topic, client, user or broker.

Modify topic parameters:

When creating a topic, you can use --config to configure the parameters of the specified item to override the default configuration:  > bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic my-topic --partitions 1 --replication-factor 1 --config max.message.bytes=64000 --config flush. Messages =1 --config max.message.bytes=64000 --config flush. Messages =1  > bin/kafka-configs.sh --zookeeper localhost:2181 --entity-type topics --entity-name my-topic --alter --add-config Max.message. bytes=128000 Check whether the file is successfully modified.  > bin/kafka-configs.sh --zookeeper localhost:2181 --entity-type topics --entity-name my-topic --describe You can also undo/delete certain specified configurations to reset the item to the default:  > bin/kafka-configs.sh --zookeeper localhost:2181 --entity-type topics --entity-name my-topic --alter --delete-config max.message.bytesCopy the code

Modify broker parameters:

Changes the values on the current broker 0logCleaner Threads can be implemented with the following command:  > bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-name 0 --alter --add-config Log.cleaner. threads=2 Check the current dynamic configuration parameters of Broker 0: > bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-name 0 --describe Delete broker Default configuration parameters/Settings on server 0:  > bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-name 0 --alter --delete-config Log.cleaner. threads updates parameters on all brokers in the cluster simultaneously (cluster-wide, consistent parameters on all brokers) :  > bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-default --alter --add-config Log.cleaner. threads=2 View the list of dynamic cluster-wide parameters in the current cluster:  > bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-default --describeCopy the code