我是kafka的新手,我只是在Hortonworks Sandbox中尝试一个示例程序。
低于错误。任何帮助,将不胜感激。
from kafka import KafkaProducer
from kafka.errors import KafkaError
producer = KafkaProducer(bootstrap_servers=['sandbox.hortonworks.com:9092'])
topic = "kafkatopic"
producer.send(topic, b'test message')
错误:
Traceback (most recent call last):
File "kaf_prod.py", line 4, in <module>
producer = KafkaProducer(bootstrap_servers=['sandbox.hortonworks.com:9092'])
File "/usr/lib/python2.6/site-packages/kafka/producer/kafka.py", line 334, in __init__
**self.config)
File "/usr/lib/python2.6/site-packages/kafka/client_async.py", line 204, in __init__
self.config['api_version'] = self.check_version(timeout=check_timeout)
File "/usr/lib/python2.6/site-packages/kafka/client_async.py", line 795, in check_version
raise Errors.NoBrokersAvailable()
kafka.errors.NoBrokersAvailable: NoBrokersAvailable
最佳答案
卡夫卡经纪人端口在hortonworks中为6667,而不是9092。尝试更改
生产者=
KafkaProducer(bootstrap_servers = ['sandbox.hortonworks.com:9092'])
至
生产者=
KafkaProducer(bootstrap_servers = ['sandbox.hortonworks.com:6667'])
关于python - Hortonworks中的Apache Kafka错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42730310/