Apache Kafka:生产者-Consume API没有在GCP上运行

我一直试图在Kafka集群上运行我的生产者和消费者api,但它不工作。Apache Kafka" title="Apache Kafka">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 

希望如果有人可以帮助这一点。谢谢

回答:

尝试创建主题之前生产bin/kafka-topics.sh --create --zookeeper zook-1:2181 --replication-factor 1 --partitions 1 --topic test

如果不工作,请阅读zkCli.sh脚本here - 通过此脚本,您可以检查代理是否在动物园管理员中注册。

如果您仍有问题,并且您尝试从kafka群集外部生成,请尝试阅读advertised.listeners属性here。

以上是 Apache Kafka:生产者-Consume API没有在GCP上运行 的全部内容, 来源链接: utcz.com/qa/259091.html

回到顶部