我有一个带有 spring-cloud-starter-bus-kafka 的项目,我在里面设置了 kafka URL,application.yml
如下所示:
spring.kafka.bootstrap-servers=localhost:9092
这可以在本地部署 kafka 和 zookeeper 时找到,但是如果我将 kafka 和 zookeeper 移动到他们自己的服务器上,当 spring-boot 启动时会出现错误:
新配置
spring.kafka.bootstrap-servers=192.168.0.120:9092
错误
{
"@timestamp" : "2018-05-15T14:56:45.628+00:00",
"message" : "Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)",
"logger_name" : "org.apache.zookeeper.ClientCnxn",
"thread_name" : "main-SendThread(localhost:2181)",
"level" : "INFO"
}
{
"@timestamp" : "2018-05-15T14:56:45.629+00:00",
"message" : "Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect",
"logger_name" : "org.apache.zookeeper.ClientCnxn",
"thread_name" : "main-SendThread(localhost:2181)",
"level" : "WARN",
"stack_trace" : "java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)"
}
我应该如何配置 kafka 和 zookeeper 以连接到他们的服务器?