Kafka版本: kafka_2.11-0.11.0.1
当我尝试在多节点Kafka生态系统中从生产者向消费者发送消息时,消息将被发送,并从Kafka服务器广播!这些消息可以通过Zookeeper使用Kafka Consumer来读取[将在以下版本中弃用!],也可以通过kafka-simple-consumer-shell.sh
./bin/kafka-simple-consumer-shell.sh --broker-list <broker-ip>:9092 --topic myTopic
但无法通过consumer-bootstrap-server从Consumer中读取!
通过Zookeeper-server呼叫消费者:
./bin/kafka-console-consumer.sh --topic myTopic --zookeeper <broker-ip>:2181 --from-beginning
通过Bootstrap-server呼叫消费者:
./kafka-console-consumer.sh --topic myTopic --bootstrap-server <broker-ip>:9092 --consumer.config ../config/consumer.properties
我的config/producer.properties
包含:
bootstrap.servers = {broker-ip}:9092
compression.type =无
我的config/consumer.properties
包含(无):
#zookeeper.connect = {private-ip-1}:2181,{private-ip-2}:2181
连接到zookeeper的超时时间(以毫秒为单位)
#zookeeper.connection.timeout.ms = 6000
#consumer group id
group.id =测试消费者组
#consumer timeout
#consumer.timeout.ms = 7000
#consumer.timeout.ms = -1
我的config/server.properties
包含:
听众= PLAINTEXT:// {私人-IP-1}:9092
advertised.host.name = {私有IP-1}
advertised.listeners = PLAINTEXT:// {私人-IP-1}:9092
advertised.port = 9092
host.name = {私有IP-1}
zookeeper.connect = {私有IP-1}:2181