新版kafka内置zookeeper配置单机版

本机安装kafak主机电脑ip地址为:192.168.171.130

其中9092端口,为kafka自身内置端口;

谨记此为新版kafka!!!!!!

下载安装新版kafka~~~安装略过

1、修改config目录下server.properties文件

只修改两处,取消前面注释#,在listeners、advertised.listeners处添加上kafka安装所在主机ip地址

端口不用修改,为本身自带端口;

############################# 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
listeners=PLAINTEXT://192.168.171.130: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.171.130:9092

新版kafka内置zookeeper配置单机版_第1张图片

 2、不用修改config目录下zookeeper.properties文件,保留原有状态;

3、开启kafka自身内置zookeeper

./bin/zookeeper-server-start.sh config/zookeeper.properties

开启成功状态

新版kafka内置zookeeper配置单机版_第2张图片

4、 开启kafka

./bin/kafka-server-start.sh config/server.properties

开启成功状态

新版kafka内置zookeeper配置单机版_第3张图片

 5、创建topic

./bin/kafka-topics.sh --create --bootstrap-server 192.168.171.130:9092 --replication-factor 1 --partitions 1 --topic test

 创建成功状态

6、查看所建topic

./bin/kafka-topics.sh --list --bootstrap-server 192.168.171.130:9092

 查询成功状态

 7、生产者消息

./bin/kafka-console-producer.sh --broker-list 192.168.171.130:9092 --topic test

 开启成功状态

 8、消费者消息

./bin/kafka-console-consumer.sh --bootstrap-server 192.168.171.130:9092 --topic test

 成功状态

 相互消费消息

 9、完毕

你可能感兴趣的:(kafka,java-zookeeper,zookeeper)