我一直試圖在Kafka集羣上運行我的生產者和消費者api,但它不工作。Apache Kafka:生產者-Consume API沒有在GCP上運行
1)動物園管理員是在一個GCP VM實例運行
2)卡夫卡正在另一個GCP VM實例運行
步驟如下:
步驟1)使用運行動物園管理員以下命令:
bin/zookeeper-server-start.sh config/zookeeper.properties
個Zookeeper.properties:
#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
# In milliseconds
tickTime=2000
# In ticks
initLimit=10
syncLimit=5
maxClientCnxns=30
# All Zookeeper servers need to be aware of other Zookeepers part of the cluster
server.1=zook-1:2888:3888
注:祖克-1是動物園管理員實例
步驟2)
在另一個GCP VM實例運行卡夫卡作爲的名稱:
bin/kafka-console-producer.sh --broker-li de-kafka-1:9092 --topic test
server.properties:
############################# Server Basics ############################# # The id of the broker. This must be set to a unique integer for each broker.
broker.id=0
############################ Zookeeper ############################# #
# root directory for all kafka znodes.
zookeeper.connect=zook-1:2181
# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000
host.name=de-kafka-1
步驟3)從步驟2(使用另一SSH隧道卡夫卡實例
運行生產API)如下:
bin/kafka-console-producer.sh --broker-list de-kafka-1:9 092 --topic test
注意:這裏脫卡夫卡-1是我嘗試過的並且用de-Kafka-1實例的外部IP,localhost,zook-1(Zookeeper VM實例的名稱),zook-1的外部IP替換de-kafka-1的名稱實例
Error: OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N Sending msg1 sending msg2
Error: error when sending message to topic test single node with key: null, value: 5 bytes with error (org.apache.kafka.clients.producer.internals.errorloggingcallback)org.apache.kafka.common.errors.timeoutexception: failed to update metadata after 60000 ms.
第4步:
運行消費者API卡夫卡實例(使用SSH第三隧道):
bin/kafka-console-consumer.sh --bootstrap-server de-kafka-1:2181 --topic test --from-beginning
希望如果有人可以幫助這一點。謝謝
嘗試從kafka虛擬機運行'telnet zook-1 2181',如果成功則輸入'stats'並按回車。這將檢查你的kafka-zookepper連通性和動物園管理員的狀態。 –
@Gal感謝您的回覆,以下是我所得到的:------------------------'Zookeeper版本:3.4.9-1757313,內置在08/23/2016 06:50 GMT 客戶:/xx.xxx.x.xx:45284[1](queue=0,recved=275,sent=277) /xx.xxx.x.xx:45384 [0](排隊= 0,recved = 1,發送= 0) 延遲最小/平均/最大:0/0/6 收稿:276 發送:277個 連接:2 優秀:0 Zxid:0x113 模式:獨立 節點數:36 由外部主機關閉的連接。' –
@Gal任何線索代表 –