본문 바로가기
Kafka

kafka CLI 사용하기 - kafka-configs.(sh | bat)

by Soono991 2023. 4. 8.
💡 이번 포스팅에서는 kafka-configs.(sh | bat)에 대해 알아보도록 하겠습니다.

 

kafka에서 config는 크게 2 부분으로 나눌 수 있습니다.

✨ Broker, Topic 레벨의 Config
ㆍKafka 서버에서 설정되는 Config
ㆍTopic의 Config 값은 Broker 레벨에서 지정한 Config를 기본으로 설정하며 별도의 Topic 레벨 Config를 설정할 경우 이를 따름
ㆍ보통 server.properties에 있는 Config는 변경 시 Broker 재기동이 필요한 Static Config이며, Dynamic Config는 kafka-configs를 이용하여 동적으로 config 변경 가능

✨ Producer와 Consumer 레벨의 Config
ㆍKafka 클라이언트에서 설정되는 Config
ㆍClient 레벨에서 설정되므로 server.properties에 존재하지 않고, kafka-configs로 수정할 수 없으며 Client 수행 시마다 설정할 수 있음

 

따라서 이번 포스팅에서 알아볼 kafka-configs를 통해서는 Kafka 서버에서 설정되는 Config를 수정할 수 있습니다.

user@ubuntu:~$ kafka-configs --help
This tool helps to manipulate and describe entity config for a topic, client, user, broker or ip
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 
                                        local.retention.bytes                 
                                        local.retention.ms                    
                                        max.compaction.lag.ms                 
                                        max.message.bytes                     
                                        message.downconversion.enable         
                                        message.format.version                
                                        message.timestamp.difference.max.ms   
                                        message.timestamp.type                
                                        min.cleanable.dirty.ratio             
                                        min.compaction.lag.ms                 
                                        min.insync.replicas                   
                                        preallocate                           
                                        remote.storage.enable                 
                                        retention.bytes                       
                                        retention.ms                          
                                        segment.bytes                         
                                        segment.index.bytes                   
                                        segment.jitter.ms                     
                                        segment.ms                            
                                        unclean.leader.election.enable        
                                       For entity-type 'brokers':             
                                        advertised.listeners                  
                                        background.threads                    
                                        compression.type                      
                                        follower.replication.throttled.rate   
                                        leader.replication.throttled.rate     
                                        listener.security.protocol.map        
                                        listeners                             
                                        log.cleaner.backoff.ms                
                                        log.cleaner.dedupe.buffer.size        
                                        log.cleaner.delete.retention.ms       
                                        log.cleaner.io.buffer.load.factor     
                                        log.cleaner.io.buffer.size            
                                        log.cleaner.io.max.bytes.per.second   
                                        log.cleaner.max.compaction.lag.ms     
                                        log.cleaner.min.cleanable.ratio       
                                        log.cleaner.min.compaction.lag.ms     
                                        log.cleaner.threads                   
                                        log.cleanup.policy                    
                                        log.flush.interval.messages           
                                        log.flush.interval.ms                 
                                        log.index.interval.bytes              
                                        log.index.size.max.bytes              
                                        log.message.downconversion.enable     
                                        log.message.timestamp.difference.max. 
                                         ms                                   
                                        log.message.timestamp.type            
                                        log.preallocate                       
                                        log.retention.bytes                   
                                        log.retention.ms                      
                                        log.roll.jitter.ms                    
                                        log.roll.ms                           
                                        log.segment.bytes                     
                                        log.segment.delete.delay.ms           
                                        max.connection.creation.rate          
                                        max.connections                       
                                        max.connections.per.ip                
                                        max.connections.per.ip.overrides      
                                        message.max.bytes                     
                                        metric.reporters                      
                                        min.insync.replicas                   
                                        num.io.threads                        
                                        num.network.threads                   
                                        num.recovery.threads.per.data.dir     
                                        num.replica.fetchers                  
                                        principal.builder.class               
                                        replica.alter.log.dirs.io.max.bytes.  
                                         per.second                           
                                        sasl.enabled.mechanisms               
                                        sasl.jaas.config                      
                                        sasl.kerberos.kinit.cmd               
                                        sasl.kerberos.min.time.before.relogin 
                                        sasl.kerberos.principal.to.local.rules
                                        sasl.kerberos.service.name            
                                        sasl.kerberos.ticket.renew.jitter     
                                        sasl.kerberos.ticket.renew.window.    
                                         factor                               
                                        sasl.login.refresh.buffer.seconds     
                                        sasl.login.refresh.min.period.seconds 
                                        sasl.login.refresh.window.factor      
                                        sasl.login.refresh.window.jitter      
                                        sasl.mechanism.inter.broker.protocol  
                                        ssl.cipher.suites                     
                                        ssl.client.auth                       
                                        ssl.enabled.protocols                 
                                        ssl.endpoint.identification.algorithm 
                                        ssl.engine.factory.class              
                                        ssl.key.password                      
                                        ssl.keymanager.algorithm              
                                        ssl.keystore.certificate.chain        
                                        ssl.keystore.key                      
                                        ssl.keystore.location                 
                                        ssl.keystore.password                 
                                        ssl.keystore.type                     
                                        ssl.protocol                          
                                        ssl.provider                          
                                        ssl.secure.random.implementation      
                                        ssl.trustmanager.algorithm            
                                        ssl.truststore.certificates           
                                        ssl.truststore.location               
                                        ssl.truststore.password               
                                        ssl.truststore.type                   
                                        unclean.leader.election.enable        
                                       For entity-type 'users':               
                                        SCRAM-SHA-256                         
                                        SCRAM-SHA-512                         
                                        consumer_byte_rate                    
                                        controller_mutation_rate              
                                        producer_byte_rate                    
                                        request_percentage                    
                                       For entity-type 'clients':             
                                        consumer_byte_rate                    
                                        controller_mutation_rate              
                                        producer_byte_rate                    
                                        request_percentage                    
                                       For entity-type 'ips':                 
                                        connection_creation_rate              
                                       Entity types 'users' and 'clients' may 
                                         be specified together to update      
                                         config for clients of a specific     
                                         user.                                
--add-config-file <String>             Path to a properties file with configs 
                                         to add. See add-config for a list of 
                                         valid configurations.                
--all                                  List all configs for the given topic,  
                                         broker, or broker-logger entity      
                                         (includes static configuration when  
                                         the entity type is brokers)          
--alter                                Alter the configuration for the entity.
--bootstrap-server <String: server to  The Kafka server to connect to. This   
  connect to>                            is required for describing and       
                                         altering broker configs.             
--broker <String>                      The broker's ID.                       
--broker-defaults                      The config defaults for all brokers.   
--broker-logger <String>               The broker's ID for its logger config. 
--client <String>                      The client's ID.                       
--client-defaults                      The config defaults for all clients.   
--command-config <String: command      Property file containing configs to be 
  config property file>                  passed to Admin Client. This is used 
                                         only with --bootstrap-server option  
                                         for describing and altering broker   
                                         configs.                             
--delete-config <String>               config keys to remove 'k1,k2'          
--describe                             List configs for the given entity.     
--entity-default                       Default entity name for                
                                         clients/users/brokers/ips (applies   
                                         to corresponding entity type in      
                                         command line)                        
--entity-name <String>                 Name of entity (topic name/client      
                                         id/user principal name/broker id/ip) 
--entity-type <String>                 Type of entity                         
                                         (topics/clients/users/brokers/broker-
                                         loggers/ips)                         
--force                                Suppress console prompts               
--help                                 Print usage information.               
--ip <String>                          The IP address.                        
--ip-defaults                          The config defaults for all IPs.       
--topic <String>                       The topic's name.                      
--user <String>                        The user's principal name.             
--user-defaults                        The config defaults for all users.     
--version                              Display Kafka version.                 
--zk-tls-config-file <String:          Identifies the file where ZooKeeper    
  ZooKeeper TLS configuration>           client TLS connectivity properties   
                                         are defined.  Any properties other   
                                         than zookeeper.clientCnxnSocket,     
                                         zookeeper.ssl.cipher.suites,         
                                         zookeeper.ssl.client.enable,         
                                         zookeeper.ssl.crl.enable, zookeeper. 
                                         ssl.enabled.protocols, zookeeper.ssl.
                                         endpoint.identification.algorithm,   
                                         zookeeper.ssl.keystore.location,     
                                         zookeeper.ssl.keystore.password,     
                                         zookeeper.ssl.keystore.type,         
                                         zookeeper.ssl.ocsp.enable, zookeeper.
                                         ssl.protocol, zookeeper.ssl.         
                                         truststore.location, zookeeper.ssl.  
                                         truststore.password, zookeeper.ssl.  
                                         truststore.type are ignored.         
--zookeeper <String: urls>             DEPRECATED. The connection string for  
                                         the zookeeper connection in the form 
                                         host:port. Multiple URLS can be      
                                         given to allow fail-over. Required   
                                         when configuring SCRAM credentials   
                                         for users or dynamic broker configs  
                                         when the relevant broker(s) are      
                                         down. Not allowed otherwise.

 

Config 확인

kafka-configs --bootstrap-server localhost:9092 --entity-type [brokers/topics] --entity-name [broker id/ topic name] --all --describe

 

Config 설정 (Set)

kafka-configs --bootstrap-server localhost:9092 --entity-type [brokers/topics] --entity-name [broker id/ topic name] --alter --add-config [property name=value]

 

Config 해제 (Unset)

kafka-configs --bootstrap-server localhost:9092 --entity-type [brokers/topics] --entity-name [broker id/ topic name] --alter --delete-config [property name]

 

--all --describe

더보기

주어진 broker, topic의 모든 설정 정보를 출력합니다.

 

 

 

 

 

참고 자료

'Kafka' 카테고리의 다른 글

Producer - 2  (0) 2023.04.09
Partitioner & Partition  (0) 2023.04.08
kafka CLI 사용하기 - kafka-consumer-group.(sh | bat)  (0) 2023.04.08
kafka CLI 사용하기 - kafka-dump-log  (0) 2023.04.04
KafkaProducer  (0) 2023.04.04

댓글