kafka集群搭建

  • zookeeper集群搭建
  • 从官网下载kafka,解压
  • 配置
    • config/server.properties
    host.name=master
    zookeeper.connect=master:2181,slave1:2181,slave2:2181
    
    • config/consumer.properties
    zookeeper.connect=master:2181,slave1:2181,slave2:2181
    
    • config/producer.properties
    metadata.broker.list=master:9092,slave1:9092,slave2:9092
    
  • 启动(3台机器均启动)
./kafka-server-start.sh -daemon ../config/server.properties
  • 创建主题
./kafka-topics.sh --create --zookeeper master:2181 --replication-factor 1 --partitions 1 --topic test111
  • 查看主题
./kafka-topics.sh --list --zookeeper master:2181
  • 创建发布者
./kafka-console-producer.sh --broker-list master:9092 --topic test111
  • 创建订阅者
./kafka-console-consumer.sh --zookeeper master:2181 --topic test111 --from-beginning
04-17 19:45