配置
kafka 修改默认配置
zookeeper 配置
- config/server.properties
修改其中的 zookeeper 地址
############################# Zookeeper #############################
# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=192.168.57.132:2181
log 配置
- config/server.properties
修改其中的kafka的数据文件地址
############################# Log Basics #############################
# A comma seperated list of directories under which to store log files
log.dirs=/opt/software/kafka/
zookeeper 配置修改
- 将/conf 这个路径下的 zoo_sample.cfg 修改为 zoo.cfg
修改日志文件地址
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir= /opt/software/zookeeper
启动
启动 zookeeper
[root@localhost zookeeper-3.4.11]# bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/software/zookeeper-3.4.11/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost zookeeper-3.4.11]# jps
28673 QuorumPeerMain
28805 Jps
启动 kafka
[root@localhost kafka_2.11-1.0.0]# bin/kafka-server-start.sh -daemon config/server.properties
[root@localhost kafka_2.11-1.0.0]# jps
28673 QuorumPeerMain
38874 Jps
38748 Kafka
查看 topic
[root@localhost kafka_2.11-1.0.0]# bin/kafka-topics.sh --zookeeper 192.168.57.132:2181 --list
创建 topic
[root@localhost kafka_2.11-1.0.0]# bin/kafka-topics.sh --zookeeper 192.168.57.132:2181 --create --replication-factor 1 --partitions 1 --topic first
Created topic "first".
[root@localhost kafka_2.11-1.0.0]#
测试
启动测试命令 生产消息
[root@localhost software]# cd kafka_2.11-1.0.0/
[root@localhost kafka_2.11-1.0.0]# bin/kafka-console-producer.sh --broker-list 192.168.57.132:9092 --topic first
>hello
>test
>cuiyt
>
启动测试命令 消费消息
[root@localhost kafka_2.11-1.0.0]# bin/kafka-console-consumer.sh --bootstrap-server 192.168.57.132:9092 --topic first
test
cuiyt