// An highlighted block
需要将kafka下config的server.properties文件中改为zookeeper启动地址
zookeeper.connect=0.0.0.0:2181(指定具体的ip)
整合springboot时遇到连接失败问题
// An highlighted block
需要将kafka下config的server.properties文件中新增host.name
############################# Socket Server Settings #############################
# 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://your.host.name:9092
host.name=127.0.0.1
创建TOPICS 并测试
打开cmd 并进入
cd C:\Users\localadmin\CODE\kafka_2.11-2.0.0\bin\windows
创建一个topic:
kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
打开一个PRODUCER:
cd C:\Users\localadmin\CODE\kafka_2.11-2.0.0\bin\windows
kafka-console-producer.bat --broker-list localhost:9092 --topic test
打开一个CONSUMER:
cd C:\Users\localadmin\CODE\kafka_2.11-2.0.0\bin\windows
kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning