-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df4a2ed
commit d2024a6
Showing
4 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
_posts/development/kafka/2024-12-18-kafka-connector-distributed-mode.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
--- | ||
title: "Kafka Connector on k8s - Distributed Mode" | ||
toc: true | ||
toc_sticky: true | ||
categories: ["Kafka"] | ||
excerpt: "" | ||
--- | ||
|
||
μ΄λ² ν¬μ€νΈλ [Kafka Connector on k8s - Standalone Mode](/2024/12/17/kafka-connector-standalone-mode/)μμ λ΄μ©μ΄ μ΄μ΄μ§λλ€. π | ||
|
||
|
||
# μ Distributed Modeμ κ΄μ¬μ κ°κ² λμλμ? | ||
|
||
νμ¬μμ Confluentλ₯Ό ν΅ν΄ Kafka ν΄λ¬μ€ν°λ₯Ό μ¬μ©νκ³ μμ΅λλ€. λλΆλΆμ κ²½μ° Confluent-managed Connectorλ₯Ό μ¬μ© νμμΌλ, μ΅κ·Ό Confluentμμ μ§μνμ§ μλ λ°μ΄ν°λ² μ΄μ€λ‘ Topicμ λ°μ΄ν°λ₯Ό μ μ¬ν΄μΌ ν μΌμ΄ μκ²Όκ³ , μ΄λ₯Ό K8sμ Standalone modeλ‘ λμ μ΅λλ€. | ||
|
||
κ·Έλ κ² ν λ¬ μ λ μ μ΄μνκ³ μλ€κ° Confluent μ κΈ° λ―Έν μμ Connectorλ₯Ό Standalone λͺ¨λλ‘ μ°κ³ μλ€κ³ λ§μ λ리λ, Standalone λͺ¨λλ λ¬Έμ μ΄λλ₯Ό λ΄λ "*κ°λ°, ν μ€νΈ λͺ©μ μΌλ‘ μ°μμ€*"λΌκ³ λμμμ§ Prod νκ²½μμλ "Distributed" λͺ¨λλ‘ λ리λ κ²μ΄ κΆμ₯ μ¬νμ΄λΌλ νΌλλ°±μ λ€μμ΅λλ€! μνΌ μ¬κΈ°κΉμ§κ° λ°°κ²½μ΄μꡬμ! μ΄λ»κ² ꡬννλμ§ μ΄ν΄λ³΄κ² μ΅λλ€. | ||
|
||
# Standalone vs. Distributed: Scalability | ||
|
||
![](/images/development/kafka/kafka-connect-standalone-vs-distributed.png){: style="width: 100%" } | ||
{: .small .gray .text-center } | ||
|
||
Kafka Connectλ₯Ό Standalone λͺ¨λλ‘ λνλ‘μ΄ ν μνμμ Pod Replicaλ₯Ό 1μμ 2λ‘ λλ¦¬κ² λλ€λ©΄, κ° Podμ΄ λμΌ λ°μ΄ν°λ₯Ό μ²λ¦¬νκ² λ©λλ€. μ¦, Throughputμ΄ 2λ°°κ° λλ κ²μ λ§μ§λ§ λ°μ΄ν°λ 2λ°°μ© μ€λ³΅ν΄μ λ€μ΄μ€κ² λ©λλ€!! | ||
|
||
λ°λ©΄μ Distributed λͺ¨λλ‘ λνλ‘μ΄ ν μνμμ Pod Replicaλ₯Ό 2λ‘ λλ¦¬κ² λλ©΄, κ° Podμ΄ λ°μ΄ν°λ₯Ό "μ λ°μ© λλμ΄" μ²λ¦¬νκ² λ©λλ€. μ¦, Throughputμ 2λ°°λ‘ λ리면μ λ°μ΄ν°λ μ€λ³΅λμ§ μμ΅λλ€! | ||
|
||
|
||
# Standalone vs. Distributed: Config Topics | ||
|
||
Standalone λͺ¨λμμλ Connectorλ₯Ό μ€νν λ, μλμ κ°μ΄ μ€νν©λλ€. | ||
|
||
```bash | ||
$ connect-standalone standalone.properties local-file-sink.properties | ||
``` | ||
|
||
`standalone.properties`μλ Kafka Serverμ μ μνκΈ° μν μ λ³΄κ° λ΄κ²¨μμκ³ , `local-file-sink.properties`μλ File Sink Connectorλ₯Ό λμνκΈ° μν μ λ³΄κ° λ΄κ²¨ μμμ΅λλ€. | ||
|
||
Distributed λͺ¨λμμλ λ€μ Connector Plugin ꡬμ±μ΄ νμΌμ΄ μλλΌ Kafka Configuration Topicμ κΈ°λ‘λ©λλ€. | ||
|
||
![](https://images.ctfassets.net/gt6dp23g0g38/6SpP65mFNZLSdngL4Gf4XD/9df532fc6b1b3d2c9385d443c17770e1/kafka-connect-distributed-mode.jpg) | ||
{: .align-center style="width: 100%" } | ||
developer.confluent.io | ||
{: .small .gray .text-center } | ||
|
||
Distributed λͺ¨λλ Standaloneκ³Ό λ¬λ¦¬ 3κ°μ§ ν ν½μ νμλ‘ ν©λλ€. | ||
|
||
- `config.storage.topic` | ||
- Kafka Connectorμμ μ€ννλ μμ (task)μ λν κ΅¬μ± μ 보 | ||
- `local-file-sink.properties` νμΌμ μλ μ λ³΄κ° μ ν ν½μ λ΄κΈ΄λ€. | ||
- `offset.storage.topic` | ||
- Kafka Connectorμ μμ μ΄ μ΄λκΉμ§ μ²λ¦¬ νλμ§ κΈ°λ‘ν μ 보 | ||
- Standaloneμμλ `offset.storage.file.filename`μ λͺ μν νμΌμ ν΄λΉ μ λ³΄κ° λ΄κ²Όλ€. | ||
- `status.storage.topic` | ||
- Kafka Connector μμμ λμνλ κ°λ³ μμ (task)μ μνλ₯Ό μ μ₯νλ μ 보 | ||
- Distributed λͺ¨λμμλ Fault Toleranceλ₯Ό μν΄ κ° Taskκ° μλ‘ μνλ₯Ό 체ν¬νλ€. | ||
|
||
μ΄λ κ² κ΅¬μ± μ λ³΄κ° Kafka Connect λ΄λΆκ° μλλΌ, μΈλΆ(remote)μΈ Topicμ κΈ°λ‘λκΈ° λλ¬Έμ λͺ¨λ Podμ΄ μ€λ¨λκ±°λ μ μ€ λλλΌλ, Topicμ κΈ°λ‘ν΄λμλ μ 보λ₯Ό λ°νμΌλ‘ Kafka Connectλ₯Ό μμ νκ² λ€μ μ€νν μ μμ΅λλ€ π | ||
|
||
|
||
# Standalone β Distributed | ||
|
||
μ κ²½μ°λ Standalone λͺ¨λλ‘ λνλ‘μ΄ ν Kafka Connectλ₯Ό Distributed λͺ¨λλ‘ μ ννλ κ²½μ° μμ΅λλ€. μ΄λ€ propertiesλ₯Ό λ³κ²½ νλμ§ μμ£Όλ‘ μ΄ν΄λ³΄λ©΄ | ||
|
||
```diff | ||
- offset.storage.file.filename=/tmp/connect.offsets | ||
+ group.id=local-file-sink | ||
+ config.storage.topic=_local_file_sink.config | ||
+ offset.storage.topic=_local_file_sink.offset | ||
+ status.storage.topic=_local_file_sink.status | ||
``` | ||
|
||
μ°μ λμ΄μ offset μ 보λ₯Ό Kafka Connectμ λ‘컬μ μ μ₯νμ§ μκΈ° λλ¬Έμ `offset.storage.file.filename` κ°μ΄ νμ μμ΅λλ€. | ||
|
||
κ·Έλ¦¬κ³ Distributed λͺ¨λλ‘ λμνκΈ° μν΄ κ° νμ€ν¬μ μ 보λ₯Ό μ μ₯ν Topic 3κ°μ§λ₯Ό μ§μ ν©λλ€. | ||
|
||
- `config.storage.topic` | ||
- `offset.storage.topic` | ||
- `status.storage.topic` | ||
|
||
Distributed λͺ¨λλ‘ Kafka Connectλ₯Ό λνλ‘μ΄ νκ² λλ©΄, Kafka Connectλ₯Ό ν΄λ¬μ€ν°(cluster) νμμΌλ‘ μ΄μνκ² λ©λλ€. κ·Έλμ μ΄ ν΄λ¬μ€ν° μ΄λ¦μ `group.id`λ‘ μ§μ ν΄μ€λλ€. | ||
|
||
## Update Pod Yaml | ||
|
||
Pod Yamlλ μλμ κ°μ΄ λ³κ²½ν©λλ€. | ||
|
||
```diff | ||
- command: | ||
- - "connect-standalone" | ||
- - "/etc/kafka-connect-properties/standalone/standalone.properties" | ||
- - "/etc/kafka-connect-properties/file-sink-connector/local-file-sink.properties" | ||
+ command: | ||
+ - "connect-distributed" | ||
+ - "/etc/kafka-connect-properties/distributed/distributed.properties" | ||
``` | ||
|
||
ν¬κ² λ³κ²½λλ μ μ μκ³ , containerλ₯Ό λ릴 λ, `connect-distributed`μ μμ μꡬμ¬νμ λ°μν `distributed.properties`λ‘ μ€ννλλ‘ λ³κ²½ν©λλ€. | ||
|
||
## Registry Task using REST API | ||
|
||
Standalone λͺ¨λμμλ μ΄λ€ μμ (task)λ₯Ό λλ¦΄μ§ `.properties` νμΌμ μμ±νκ³ μ΄λ₯Ό `connect-standalone`μ λ겨주μμ΅λλ€. | ||
|
||
Distributed λͺ¨λμμλ μμ (task)μ λ±λ‘ν λ Kafka Connectμ REST APIλ₯Ό μ¬μ©ν©λλ€! | ||
|
||
```bash | ||
$ curl -X POST -H "Content-Type: application/json" \ | ||
http://localhost:8083/connectors \ | ||
--data "@/etc/kafka-connect-properties/file-sink-connector/local-file-sink.json" | ||
``` | ||
|
||
μμ `curl` λͺ λ Ήμ΄μμ `local-file-sink.json`μΌλ‘ μ λ¬νλλ°, μ΄λ₯Ό μν΄ `local-file-sink.json`μ μλμ κ°μ΄ μμ±ν ν, Standalone λͺ¨λμμ νλ κ²μ²λΌ K8s SecretμΌλ‘ λ§λ€μ΄ Podμ Volume Mountλ‘ μ£Όμ ν©λλ€. | ||
|
||
```json | ||
// @./local-file-sink.json | ||
{ | ||
"name": "local-file-sink", | ||
"config": | ||
{ | ||
"connector.class": "FileStreamSink", | ||
"tasks.max": "1", | ||
"topics": "szcode2.qa.avro.server", | ||
|
||
"file": "/tmp/test.sink.txt" | ||
} | ||
} | ||
``` | ||
|
||
`curl`μ ν΅ν μμ λ±λ‘μ Kafka Connector Podμ΄ λνλ‘μ΄ λκ³ , λͺμ΄κ°μ λλ© ν λ±λ‘μ΄ κ°λ₯ν©λλ€. | ||
|
||
κ·Έλ¦¬κ³ , μμ λ±λ‘ νμ λ 1λΆ~3λΆ μ λ κΈ°λ€λ¦¬λ©΄, Confluentμμλ Distributed λͺ¨λμ Connectorκ° λ±λ‘λ κ²μ νμΈν μ μμ΅λλ€ π | ||
|
||
|
||
# λ§Ίμλ§ | ||
|
||
λκ° Kafkaλ₯Ό μ²μ 곡λΆν λ λ΄€λ κΈ°μ΅μ΄ μ΄λ ΄νμ΄ λλ κ² κ°μλ°, μ§μ λμ보λ μ Standalone λͺ¨λμ Distributed λͺ¨λ, λ λ°©μμ΄ μ‘΄μ¬νλμ§ μ μλΏλ κ² κ°μ΅λλ€ γ γ (μμ μ§μ ν΄λ΄μΌ λμ΄) | ||
|
||
Distributed Mode μμ± μ€μ `rest.advertised.host.name` μͺ½μ μμ§ μ λλ‘ λͺ» λ΄€λλ°, λμ€μ μκ°μ΄ λλ©΄ μ’λ μ΄ν΄λ³΄κ³ μ ν©λλ€. (μ λΉν λμ΄μ£Όλ κ²λ νμ γ γ ) | ||
|
||
μ΄λ²μ νμ¬ μ λ¬΄λ‘ Kafka μμ μ κ½€ λ§μ΄ ν΄λ³΄κ² λμ΄μ λ€μ μ격μ¦μΌλ‘ Confluent Certificateλ₯Ό λͺ©νλ‘ μ€μ νμ΅λλ€! μ΄μͺ½ μνκ³μ λν΄μλ λλλ λ§μ΄ μ μ μκ² λκΈΈ γ γ κ·ΈλΌ μμΌλ‘λ μμ’μ£! π |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.