以下笔记为简略记录,详细实战内容待补充。
分布式消息流管理工具
http://kafka.apache.org/
[zeal@data1 softwares]$ tar -zxf kafka_2.11-0.9.0.0.tgz -C /opt/modules/
kafka配置
server.properties
producer.properties
分发到其他机器
修改其他机器上server.properties文件中的配置broker.id和host.name
启动kafka测试
启动服务
[zeal@data1 kafka_2.11-0.9.0.0]$ bin/kafka-server-start.sh config/server.properties
创建topics
[zeal@data2 kafka_2.11-0.9.0.0]$ bin/kafka-topics.sh --create --zookeeper data1.zeal.name:2181,data2.zeal.name:2181,data3.zeal.name:2181 --replication-factor 1 --partitions 1 --topic test
查询zookeeper
[zeal@data3 zookeeper-3.4.5-cdh5.10.0]$ bin/zkCli.sh
[zk: localhost:2181(CONNECTED) 0] ls /
[hbase, hadoop-ha, zeal, admin, zookeeper, consumers, config, controller, yarn-leader-election, brokers, controller_epoch]
[zk: localhost:2181(CONNECTED) 1] ls /brokers
[topics, ids]
[zk: localhost:2181(CONNECTED) 2] ls /brokers/topics
[test]
[zk: localhost:2181(CONNECTED) 3] quit
运行生产者
[zeal@data2 kafka_2.11-0.9.0.0]$ bin/kafka-console-producer.sh --broker-list data1.zeal.name:9092,data2.zeal.name:9092,data3.zeal.name:9092 --topic test
启动消费者
[zeal@data3 kafka_2.11-0.9.0.0]$ bin/kafka-console-consumer.sh --zookeeper data1.zeal.name:2181,data2.zeal.name:2181,data3.zeal.name:2181 --from-beginning --topic test
生产者生产消息,消费者消费消息测试
Copyright ©2017-2024 uzen.zone
湘ICP备17013178号-3