kafka单节点部署
下载kafka安装包:http://archive.apache.org/dist/kafka/
解压文件,修改kafka的config/server.properties里面的配置
server.properties配置中需要关注以下几个参数:
# The id of the broker. This must be set to a unique integer for each broker. # 表示broker的编号,如果集群中有多个broker,则每个broker的编号需要设置的不同 broker.id=0 # listeners=PLAINTEXT://0.0.0.0:9092 # broker对外提供的服务入口地址 listeners=PLAINTEXT://192.168.110.142:9092 # 设置存放消息日志的地址 # A comma separated list of directories under which to store log files log.dirs=/tmp/kafka-logs # zookeeper.connect=localhost:2181 # kafka所需的zookeeper的集群地址 zookeeper.connect=192.168.110.142:2181
如需要集群环境内外网区分,需关注 kafka的 listeners 和advertised.listeners 详细配置
修改完毕后,启动kafka ./bin/kafka-server-start.sh -daemon ./config/server.properties
命令:
创建topic
./kafka-topics.sh -zookeeper 192.168.0.20:218 -topic test -replication-factor 2 -partitions 5 --create
查看当前topic
./kafka-topics.sh -zookeeper 192.168.0.20:2181 -list
创建生产者生产数据
./kafka-console-producer.sh --broker-list 192.168.0.20:9092 --topic test
创建消费者消费数据
kafka-console-consumer.sh --bootstrap-server 192.168.0.20:9092 --topic canal_topic --from-beginning
删除topic
kafka-topics.sh --zookeeper 192.168.0.20:2181 --delete --topic test_epidemic_report
author@nohert