Java测试远程连接Kafka,实现生产者和消费者,发现两者数据不通?
Posted Mr.zhou_Zxy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java测试远程连接Kafka,实现生产者和消费者,发现两者数据不通?相关的知识,希望对你有一定的参考价值。
Java测试远程连接Kafka,实现生产者和消费者,发现两者数据不通?
错误显示
错误排除
- 1.在网上看到有这种方法,修改Kafka下的conf下的server.properties文件
cd /opt/apps/kafka/conf/server.properties
vim server.properties把这两行释放出来:
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://192.168.130.110:9092
# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
# FORMAT:
# listeners = listener_name://host_name:port
# EXAMPLE:
# listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://:9092
# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured. Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
advertised.listeners=PLAINTEXT://192.168.130.110:9092
# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
# The number of threads that the server uses for receiving requests from the network and sending responses to the network
num.network.threads=3
# The number of threads that the server uses for processing requests, which may include disk I/O
num.io.threads=8
- 2.在完成上面的操作后,发现还是不能连接,然后就尝试从主机ping虚拟机
这也是后话了(然后发现并没有什么用,无论虚拟机的防火墙开不开这都可以ping通)
>随后在虚拟机输入了关闭防火墙命令,然后IDEA成功的实现了生产者和消费者
systemctl stop firewalld
以上是关于Java测试远程连接Kafka,实现生产者和消费者,发现两者数据不通?的主要内容,如果未能解决你的问题,请参考以下文章