본문 바로가기
DevOps/Apache Kafka

kafka config 옵션 정리

by SeleniumBindingProtein 2023. 1. 8.
728x90
반응형

Kafka Config(server.properties)

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# see kafka.server.KafkaConfig for additional details and defaults

############################# Server Basics #############################

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0 
# 같은 카프카 클러스터에서 현재 브로커를 식별하기 위한 숫자이다. 

############################# Socket Server Settings #############################

# The address the socket server listens on. It will get the value returned from 
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://localhost:9092 
# 카프카 브로커가 내부적으로 바인딩하는 주소이다.
# 브로커가 서버 소켓을 만드는데 사용하며, 리스너간 동일한 포트를 사용할 수 없다.

# Hostname and port the broker will advertise to producers and consumers. If not set, 
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
advertised.listeners=PLAINTEXT://your.host.name:9092 
# 카프카 프로듀서, 컴슈머에게 노출할 주소이다. 설정하지 않을 경우, 디폴트로 listeners 설정이 적용된다.
# 클라이언트가 브로커에 연결하는데 사용한다. 

# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
# 보안 프로토콜 맵은 [이름]:[프로토콜] 형식으로 해당 프로토콜을 어떤 이름으로 부를 것인가를 매핑한다.
# 보안 프로토콜 이름당 하나의 advertised 지정 가능하다. 

# The number of threads that the server uses for receiving requests from the network and sending responses to the network
num.network.threads=3
# 서버에서 네트워크로부터 요청을 받고, 네트워크로 응답을 전송할 때 사용할 쓰레드 수이다.
# 네트워크 요청을 처리하는 쓰레드의 개수이다.
# 기본값은 3이다.

# The number of threads that the server uses for processing requests, which may include disk I/O
num.io.threads=8
# IO가 생길때마다 spawn 되는 쓰레드 수로, 로그를 저장하는데 사용되는 디스크 수와 동일하게 지정하는 것을 권장한다. 
# 기본값은 8이다.

# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes=102400
# 소켓 커넥션에 사용될 SO_SNDBUF 버퍼 크기이며, 기본값은 102400이다.
# 소켓을 생성하면, 소켓에는 send buffer와 recieve buffer가 각각 할당 되는데, send buffer에 대한 설정이다.

# The receive buffer (SO_RCVBUF) used by the socket server
socket.receive.buffer.bytes=102400
# 소켓 커넥션에 사용될 SO_RCVBUFF 버퍼 크기이며, 기본값은 102400이다.

# The maximum size of a request that the socket server will accept (protection against OOM)
socket.request.max.bytes=104857600
# 서버가 받을 수 있는 최대 요청 개수를 말한다.
# 서버 메모리가 고갈되는 걸 방지한다.
# 자바 힙크기보다 작게 설정해야 하며, 기본값은 104857600이다.

############################# Log Basics #############################

# A comma separated list of directories under which to store log files
log.dirs=/tmp/kafka-logs
# 로그가 저장되는 디렉토리이다.

# The default number of log partitions per topic. More partitions allow greater
# parallelism for consumption, but this will also result in more files across
# the brokers.
num.partitions=1
# 토픽당 로그 파티션의 기본 개수이며, 파티션 크기를 명시적으로 지정하지 않아도 된다.

# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1
# 기동 시 로그 복구와 셧다운 시 플러쉬에 사용할 데이터 디렉토리 당 쓰레드의 개수이다.
# 장애에 빠르게 대응하고자 한다면, 높은 값을 설정해야 한다.

############################# Internal Topic Settings  #############################
# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.
offsets.topic.replication.factor=3
# 오프셋 커밋 토픽에 복제 인수를 지정한다.
# 지정값 보다 더 높으면, 그 시점에 토픽을 생성하고 지정값 보다 낮은면 생성된 복제 수가 브로커 수와 같게 된다.
# 기본값은 3이다. 

transaction.state.log.replication.factor=3
# 트랜잭션 토픽의 replication factor를 지정한다.
# 클러스터 크기가 이 값보다 작으면 internal topic 생성에 실패한다.
# 카프카 트랜잭션은 프로듀서와 컨슈머단에서 옵션을 설정해야 한다. 
# __transaction_state : 이 토픽은 프로듀서가 보내는 데이터의 트랜잭션을 기록하는데 사용되며,
# 기록된 데이터는 트랜잭션이 활성화된 컨슈머가 데이터를 가져가는데 사용한다. 

transaction.state.log.min.isr=1
# 트랜잭션 토픽에 대한 min.insync.replicas 설정을 재정의한다. 

############################# Log Flush Policy #############################

# Messages are immediately written to the filesystem but by default we only fsync() to sync
# the OS cache lazily. The following configurations control the flush of data to disk.
# There are a few important trade-offs here:
#    1. Durability: Unflushed data may be lost if you are not using replication.
#    2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
#    3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks.
# The settings below allow one to configure the flush policy to flush data after a period of time or
# every N messages (or both). This can be done globally and overridden on a per-topic basis.

# The number of messages to accept before forcing a flush of data to disk
#log.flush.interval.messages=10000
# 디스크에 플러쉬 될 때까지 메모리에 유지될 메시지의 숫자이다. 
# 메시지가 디스크로 플러쉬 되기 전에 로그 파티션에 누적된 메시지 수이다.

# The maximum amount of time a message can sit in a log before we force a flush
#log.flush.interval.ms=1000
# 디스크로 플러쉬 되기 전에 모든 주제의 메시지가 메모리에 보관되는 최대 시간이다.

############################# Log Retention Policy #############################

# The following configurations control the disposal of log segments. The policy can
# be set to delete segments after a period of time, or after a given size has accumulated.
# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
# from the end of the log.

# The minimum age of a log file to be eligible for deletion due to age
log.retention.hours=168
# 로그 파일(메시지)의 수명이며, 기본값은 168(7일)이다.
# 일반적으로 3일 정도로 설정하여 사용한다고 하는데, 일배치로 마이그레이션을 하기 위해 1일 미만으로 설정하기도 한다. 

# A size-based retention policy for logs. Segments are pruned from the log unless the remaining
# segments drop below log.retention.bytes. Functions independently of log.retention.hours.
#log.retention.bytes=1073741824
# 로그 파일(메시지)의 크기이며, 기본 값은 1073741824이다. 

# The maximum size of a log segment file. When this size is reached a new log segment will be created.
log.segment.bytes=1073741824
# 로그 세그먼트 파일의 최대 크기이며, 이 크기에 도달하면 새 로그 세그먼트가 생성된다. 

# The interval at which log segments are checked to see if they can be deleted according
# to the retention policies
log.retention.check.interval.ms=300000
# 로그를 삭제하기 위한 check 주기이다. 

############################# Zookeeper #############################

# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=localhost:2181
# hostname:port 형식으로 주키퍼 커넥션을 지정한다.
# 콤마(,)로 구분하여 여러 주키퍼 노드를 지정할 수 있다. 
# 여러 노드를 지정하는 것은 주키퍼 노드 하나가 다운되어도 카프카 클러스터가 신뢰도와 지속성을 가지게 하기 위함이다.
# 주키퍼는 특정 패스에 카프카 데이터를 만들 수 있게 chroot 패스를 허용한다. 
# chroot는 동일 주키퍼 클러스터가 여러 카프카 클러스터를 지원할 수 있게 한다. 
# 예) host1:port1,host2:port2,host3:port3/chroot/path. 
# 마지막 설정은 모든 클러스터 데이터를 /chroot/path에 넣는다. 
# 이 패스는 반드시 카프카가 시작되기 전에 생성되어야 한다. 
# 컨슈머는 반드시 동일한 문자열(패스)을 사용해야 한다.

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=18000
# 서버로부터 하트비트를 받지 못하면 죽은 것으로 간주한다. 이 값은 반드시 주의깊게 설정되어야 한다.
# 만약 이 하트비트의 주기가 너무 길면 죽은 서버를 감지하지 못하고, 짧으면 살아있는 서버가 죽은 것으로 간주된다.
# 기본값은 6000이다.(6초)

############################# Group Coordinator Settings #############################

# The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance.
# The rebalance will be further delayed by the value of group.initial.rebalance.delay.ms as new members join the group, up to a maximum of max.poll.interval.ms.
# The default value for this is 3 seconds.
# We override this to 0 here as it makes for a better out-of-the-box experience for development and testing.
# However, in production environments the default value of 3 seconds is more suitable as this will help to avoid unnecessary, and potentially expensive, rebalances during application startup.
group.initial.rebalance.delay.ms=3
# 그룹 코디네이터가 새 그룹에서 처음 리밸런스를 수행 하기 전에,더 많은 컨슈머가 그룹에 들어올 수 있도록 기다리는 시간을 말한다. 
# 리밸런스는 리더 역할을 할 클라이언트를 선출하며 파티션을 분배하는 과정이다.
# 더 오래 기다리면 앞으로 리밸런스를 덜 할 순 있지만, 리밸런스를 시작하기까지 시간이 더 오래 걸린다.
# 개발 및 테스트 중에는 테스트 실행 시간을 지연시키지 않기 위해 이걸을 0으로 설정하는 것이 바람직할 수 있다.
# default를 3000ms 만큼 대기하는 것을 추천한다.

 

Zookeper Config(zookeeper.properties)

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
# 
#    http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# the directory where the snapshot is stored.
dataDir=/tmp/zookeeper
# 주키퍼의 상태, 스냅샷, 트랜잭션 로그들을 저장하고 업데이트 하는 디렉토리의 위치이다. 

# the port at which the clients will connect
clientPort=2181
# 클라이언트로부터 요청 받기 위한 포트이다. 

# disable the per-ip limit on the number of connections since this is a non-production config
maxClientCnxns=0
# 클라이언트로부터 동시에 접속할 수 있는 연결 수를 지정한다.
# 연결 수는 클라이언트 IP당 개수이며, 기본값은 10이며, 0은 무제한이다. 

# Disable the adminserver by default to avoid port conflicts.
# Set the port to something non-conflicting if choosing to enable this
admin.enableServer=false
# 주키퍼는 default로 admin server를 기동하는데, 8080 port를 사용한다.
# 주키퍼 기동 시 port 충돌을 방지하기 위해 false로 사용한다. 

# admin.serverPort=8080

 

Connect (connect-distributed.properties)

##
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##

# This file contains some of the configurations for the Kafka Connect distributed worker. This file is intended
# to be used with the examples, and some settings may differ from those used in a production system, especially
# the `bootstrap.servers` and those specifying replication factors.

# A list of host/port pairs to use for establishing the initial connection to the Kafka cluster.
bootstrap.servers=localhost:9092, localhost:9093, localhost:9093
# 카프카 클러스터에 대한 초기 커넥션을 구축하는데 사용할 호스트/포트 쌍 리스트이다.
# kafka broker 서버 = bootstrap 서버

# unique name for the cluster, used in forming the Connect cluster group. Note that this must not conflict with consumer group IDs
group.id=connect-cluster
# connect를 같은 클러스터로 묶기 위한 그룹을 설정한다. 

# The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will
# need to configure these based on the format they want their data in when loaded from or stored into Kafka
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
# 카프카 커넥터 포맷과 카프카에 기록한 직렬화된 포맷 간을 변환할 때, 사용할 컨버터 클래스이다.
# 카프카에서 쓰거나 읽은 메시지 키 포맷은 이 클래스가 제어하며, 
# 컨버터는 커넥터와는 독립적이기 때문에 사용하는 커넥터와는 무관하게 어떤 직렬화 포맷으로도 작업할 수 있다.

# Converter-specific settings can be passed in by prefixing the Converter's setting with the converter we want to apply
# it to
key.converter.schemas.enable=true
value.converter.schemas.enable=true
# key/value 값이 내부 schema와 data를 모두 포함하는 복합개체로 처리되도록 하는 설정이다. 
# 만약 스키마 형태로 제공하지 않는다면, enable option을 false로 설정한다. 

# Topic to use for storing offsets. This topic should have many partitions and be replicated and compacted.
# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
# the topic before starting Kafka Connect if a specific topic configuration is needed.
# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
offset.storage.topic=connect-offsets
# connect offset을 저장할 kafka topic 명이다.

offset.storage.replication.factor=3
# offset을 저장하는 토픽을 생성할 때, 사용할 replication factor이다. 
# 기본값은 3이다. 

#offset.storage.partitions=25

# Topic to use for storing connector and task configurations; note that this should be a single partition, highly replicated,
# and compacted topic. Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
# the topic before starting Kafka Connect if a specific topic configuration is needed.
# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
config.storage.topic=connect-configs
# connector 설정을 저장할 kafka topic 명이다. 

config.storage.replication.factor=3
# 설정을 저장하는 topic을 생성할 때, 사용할 replication factor이다.
# 기본값은 3이다.

# Topic to use for storing statuses. This topic can have multiple partitions and should be replicated and compacted.
# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
# the topic before starting Kafka Connect if a specific topic configuration is needed.
# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
status.storage.topic=connect-status
# connector와 task 상태를 저장할 topic 명이다. 

status.storage.replication.factor=3
# 상태를 저장하는 topic을 생성할 때, 사용할 replication factor이다.
# 기본값은 3이다. 

#status.storage.partitions=5

# Flush much faster than normal, which is useful for testing/debugging
offset.flush.interval.ms=10000
# task에서 offset 커밋을 시도하는 주기이다. 

# List of comma-separated URIs the REST API will listen on. The supported protocols are HTTP and HTTPS.
# Specify hostname as 0.0.0.0 to bind to all interfaces.
# Leave hostname empty to bind to default interface.
# Examples of legal listener lists: HTTP://myhost:8083,HTTPS://myhost:8084"
#listeners=HTTP://:8083

# The Hostname & Port that will be given out to other workers to connect to i.e. URLs that are routable from other servers.
# If not set, it uses the value for "listeners" if configured.
#rest.advertised.host.name=
#rest.advertised.port=
#rest.advertised.listener=

# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for plugins
# (connectors, converters, transformations). The list should consist of top level directories that include 
# any combination of: 
# a) directories immediately containing jars with plugins and their dependencies
# b) uber-jars with plugins and their dependencies
# c) directories immediately containing the package directory structure of classes of plugins and their dependencies
# Examples: 
# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors,
#plugin.path=
# 추가 플러그인 경로이다.
728x90
반응형

'DevOps > Apache Kafka' 카테고리의 다른 글

kafka UI - CMAK 설치 및 실행  (0) 2023.01.17
Messaging System 개념 정리  (0) 2022.04.05
Apache Kafka 개념 정리  (0) 2022.04.05

댓글