본문 바로가기


카테고리 없음

#1 Window에서 Spring Boot랑 Kafka 연동해보기(Kafka 설치)

by worldforest 2023. 1. 13.

Kafka 다운받기

 

Apache Downloads

We suggest the following site for your download: https://dlcdn.apache.org/ Alternate download locations are suggested below. It is essential that you verify the integrity of the downloaded file using the PGP signature (.asc file) or a hash (.md5 or .sha* f

www.apache.org

아래 페이지에서 바로 다운 받을 수 있다.

 

Index of /

 

dlcdn.apache.org

Kafka를 찾아 적당한 버전을 다운받았다.

 

Kafka_[버전].tgz 파일을 다운받고 tar zxvf 파일명으로 압축을 해제한다. 

tar zxvf kafka_2.12-3.2.3.tgz

Kafka 실행하기

kafka-run-class.sh

모든 명령은 kafka root 디렉터리(kafka_2.12-3.2.1 = 다운받은 kafka 파일의 버전) 기준으로 실행했다.

 

먼저 zookeeper 실행(windowd에서 실행하기 때문에 /window 폴더안에서 .bat파일을 실행해준다)

 


zookeeper-server-start.bat 실행 시 "명령 구문이 올바르지 않습니다." 이와 같은 오류가 발생한다면

 

kafka 실행시 명령 줄이 너무 깁니다

rem Classpath addition for release for %%i in ("%BASE_DIR%\libs\*") do ( call :concat "%%i" ) 윈도우 환경에 kafka를 설치해서 실행시킬 일이 있었다 cmd창에서 kafka-server-start.bat ../../config/server.properties 명령어로 실행시

kimdeveloper.tistory.com

다음과 같이 /bin/windows/kafka-run-class.bat에서 아래 반복문을 수정(없애기)해준다.


zookeeper를 실행

.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties

// 백그라운드로 실행
.\bin\windows\zookeeper-server-start.bat .-daemon \config\zookeeper.properties

kafka 실행

.\bin\windows\kafka-server-start.bat .\config\server.properties

실행확인

jps로 확인했을 때 QuorumPeerMain이 떠있으면 zookeeper가 실행중인 것으로 간주하면 될 것 같다.

 


3개의 브로커(카프카 설치 서버) 구성하기(ing)

config/server.properties 3개 복사후 수정하기

############################# 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. If not configured, the host name will be equal to the value of
# java.net.InetAddress.getCanonicalHostName(), with PLAINTEXT listener name, and port 9092.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://:9092

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

# A comma separated list of directories under which to store log files
log.dirs=/tmp/kafka-logs

############################# 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

각 서버 설정값으로 설정 후 log 디렉터리 생성

  broker.id= listeners=PLAINTEXT://: log.dirs=
server.1.properties 1 9093 /tmp/kafka-logs1
server.1.properties 2 9094 /tmp/kafka-logs2
server.3.properties 3 9095 /tmp/kafka-logs3

 


Kafka bin 폴더에 있는 파일 목록

connect-distributed.bat
connect-standalone.bat
kafka-acls.bat
kafka-broker-api-versions.bat
kafka-configs.bat
kafka-console-consumer.bat
kafka-console-producer.bat
kafka-consumer-groups.bat
kafka-consumer-perf-test.bat
kafka-delegation-tokens.bat
kafka-delete-records.bat
kafka-dump-log.bat
kafka-get-offsets.bat
kafka-leader-election.bat
kafka-log-dirs.bat
kafka-metatada-quorum.bat
kafka-mirror-maker.bat
kafka-producer-perf-test.bat
kafka-reassign-partitions.bat
kafka-replica-verification.bat
kafka-run-class.bat
kafka-server-start.bat
kafka-server-stop.bat
kafka-storage.bat
kafka-streams-application-reset.bat
kafka-topics.bat
kafka-transactions.bat
zookeeper-server-start.bat
zookeeper-server-stop.bat
zookeeper-shell.bat

 

 


참고사이트

반응형

댓글