라벨이 kafka인 게시물 표시

About Kafka Basic

이미지
Topics 데이터베이스에서 테이블과 비슷한 개념으로 특정한 stream of data 으로 구성된다. 원하는 만큼 생성할 수 있고, 이름으로 토픽을 식별한다. 모든 데이터 형식을 지원한다. - json - avro - text - binary 카프카 프로듀서가 데이터를생산하고, 카프카 컨슈머가 데이터 읽는다. Partitions & Offsets 토픽은 여러개의 파티션으로 구성된다. 메세지는 파티션내에서 순서대로 저장된다. 토픽 레벨에서 메세지 순서를 보장하지 않는다. 각각 메세지는 파티션내에서 증분 id 를 가지고 이를 kafka partition offsets 이라 한다. 따라서 offset 은 특정 파티션내에서만 의미를 갖는다. 카프카 토픽은  immutable 이다. 한 번 파티션에 데이터가 쓰여지면 변경이 불가능하다. 데이터는 정해진 시간내에서만 존재한다. 기본값은 1주일이다. 프로듀서에서 데이터에 key 를 지정하지 않으면 랜덤으로 파티션에 할당된다. 파티션 개수는 원하는 만큼 지정할 수 있다. Producer 데이터를 토픽에 쓰는 역할을한다. 프로듀서에서 어느 토픽에 어느 파티션에 데이터를 쓸 지 정할 수 있다. Producer Message Key 프로듀서는 메세지를 key 와 함께 전송할 수 있다. key 가 null 이면 라운드로빈 방식으로 파티션에 데이터가 전송된다. 해싱 전략(murmur2)으로 항상 동일한 파티션으로 할당할 수 있다. - key - binary (can be null) - value - binary (can be null) - compression type (none, gzip, snappy, lz4, zstd) - headers (optional)     - key value - partition + offset - timestamp (system or user set) Kafka Message Serializer 카프카는 프로듀서로부터 그리고 컨슈머로 bytes 만 input 과 ou...

Install and Run Kafka on my M1 Macbook

이미지
 M1 맥북 로컬에 카프카를 설치하는 방법은 두가지가 있다. binary 로 다운받아서 설치하는 방법과 간단한 homebrew 를 통해서 설치하는 방법이 있다. homebrew 로 진행해보자. m1 의 homebrew 통한 설치 경로는 아래와 같다. - 바이나리와 스크립트는 /opt/homebrew/bin - Kafka 설정들은 /opt/homebrew/etc/kafka - Zookeeper 설정은 /opt/homebrew/etc/zookeeper - log.dirs config (the location for Kafka data) 는 /opt/homebrew/var/lib/kafka-logs 1. homebrew 설치 1 /bin/bash -c " $( curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh ) " 2. kafka 설치 brew install kafka 3. zookeeper 실행 zookeeper-server-start /opt/homebrew/etc/zookeeper/zoo.cfg 4. kafka 실행 kafka-server-start /opt/homebrew/etc/kafka/server/properties Zookeeper 없이 실행하기 - Kraft 1. Kafka UUID 생성 kafka-storage random-uuid # 76BLQI7sT_ql1mBfKsOk9Q 2. 포맷팅 kafka-storage format -t <uuid> -c /opt/homebrew/etc/kafka/kraft/server.properties # Formatting /opt/homebrew/var/lib/kraft-combined-logs with metadata.version 3.4-IVO. 3. kafka 실행 kafka-server-start /opt/homebrew/etc/kafka/kraft/server.properties ...