「Apache Kafka」:修訂間差異

出自Gea-Suan Lin's Wiki
跳至導覽 跳至搜尋
本頁面具有訪問限制。如果您看見此訊息,這代表您沒有訪問本頁面的權限。
無編輯摘要
行 3: 行 3:
== 介紹 ==
== 介紹 ==


Kafka本身不過多處理多節點之間的效能分配問題,而是透 [[ZooKeeper]]處理。可以從「[[#測試]]」的章節看到操作時都是指定ZooKeeper當作API Endpoint。在Production環境上,一般我們會用TCP load balancer放在前面,讓用戶端架構比較簡單(僅需設定單一名稱)。
Kafka本身不過多處理多節點之間的效能分配問題,而是透 過KRaft(以前的版本則是[[ZooKeeper]] 處理。可以從「[[#測試]]」的章節看到操作時都是指定ZooKeeper當作API Endpoint。在Production環境上,一般我們會用TCP load balancer放在前面,讓用戶端架構比較簡單(僅需設定單一名稱)。


== 安裝 ==
== 安裝 ==

於 2023年10月3日 (二) 06:46 的修訂

Apache Kafka是一套基於JavaScala,提供Streaming架構的軟體。

介紹

Kafka本身不過多處理多節點之間的效能分配問題,而是透過KRaft(以前的版本則是ZooKeeper)處理。可以從「#測試」的章節看到操作時都是指定ZooKeeper當作API Endpoint。在Production環境上,一般我們會用TCP load balancer放在前面,讓用戶端架構比較簡單(僅需設定單一名稱)。

安裝

這邊建議直接裝Confluent的版本。

測試

可以這樣測試,可以透過建立一個topic簡單確認cluster是否有運作:

/opt/kafka/bin/kafka-topics.sh --describe --zookeeper test-gslin-zookeeper-xxxxxxxxx.us-east-1.elb.amazonaws.com:2181
/opt/kafka/bin/kafka-topics.sh --create --zookeeper test-gslin-zookeeper-xxxxxxxxx.us-east-1.elb.amazonaws.com:2181 --replication-factor 2 --partitions 1 --topic my-replicated-topic
/opt/kafka/bin/kafka-topics.sh --describe --zookeeper test-gslin-zookeeper-xxxxxxxxx.us-east-1.elb.amazonaws.com:2181

如果ZooKeeper不是使用TCP load balancer時,可以直接指定所有的ZooKeeper主機:

/opt/kafka/bin/kafka-topics.sh --describe --zookeeper 1.2.3.4:2181,5.6.7.8:2181,9.10.11.12:2181
/opt/kafka/bin/kafka-topics.sh --create --zookeeper 1.2.3.4:2181,5.6.7.8:2181,9.10.11.12:2181 --replication-factor 2 --partitions 1 --topic my-replicated-topic
/opt/kafka/bin/kafka-topics.sh --describe --zookeeper 1.2.3.4:2181,5.6.7.8:2181,9.10.11.12:2181

其中所有的:2181都可以簡化省略,因為ZooKeeper的預設Port就是Port 2181:

/opt/kafka/bin/kafka-topics.sh --describe --zookeeper test-gslin-zookeeper-xxxxxxxxx.us-east-1.elb.amazonaws.com
/opt/kafka/bin/kafka-topics.sh --create --zookeeper test-gslin-zookeeper-xxxxxxxxx.us-east-1.elb.amazonaws.com --replication-factor 2 --partitions 1 --topic my-replicated-topic
/opt/kafka/bin/kafka-topics.sh --describe --zookeeper test-gslin-zookeeper-xxxxxxxxx.us-east-1.elb.amazonaws.com
/opt/kafka/bin/kafka-topics.sh --describe --zookeeper 1.2.3.4,5.6.7.8,9.10.11.12
/opt/kafka/bin/kafka-topics.sh --create --zookeeper 1.2.3.4,5.6.7.8,9.10.11.12 --replication-factor 2 --partitions 1 --topic my-replicated-topic
/opt/kafka/bin/kafka-topics.sh --describe --zookeeper 1.2.3.4,5.6.7.8,9.10.11.12

相關連結

外部連結