赞
踩
- ApacheKafka®是一个分布式流媒体平台。这到底是什么意思呢?
我们认为流媒体平台具有三个关键功能:
1. 它可以让你发布和订阅记录流。在这方面,它类似于消息队列或企业消息传递系统。
2. 它允许您以容错方式存储记录流。
3. 它可以让您在发生记录时处理记录流。
tar zxf kafka_2.11-1.0.0
./bin/zookeeper-server-start.sh config/zookeeper.properties
./bin/kafka-server-start.sh config/server.properties
在默认的 kafka_2.11-1.0.0/config 目录下的server.properties文件中
默认端口为9092
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
cp config/server.properties config/server2.properties
cp config/server.properties config/server3.properties
config/server2.properties:
broker.id=1
listeners=PLAINTEXT://:9093
log.dir=/tmp/kafka-logs-1
config/server3.properties:
broker.id=2
listeners=PLAINTEXT://:9094
log.dir=/tmp/kafka-logs-2
./bin/kafka-server-start.sh config/server2.properties &
.....
./bin/kafka-server-start.sh config/server3.properties &
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic test2
./bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test2
Topic:test2 PartitionCount:1 ReplicationFactor:3 Configs:
Topic: zhh-replicated-topic Partition: 0 Leader: 2 Replicas: 2,0,1 Isr: 2,0,1
第一行表示汇总信息. 有1个分区, 3份备份 第二行表示每个分区的信息,对分区0,领导节点id是2, 备份到2,0,1.
leader 表示负责某分区全部读写的节点. 每个分区都会有随机选择的leader.
Replicas 表示需要复制到的节点, 不管是否活着.
Isr 表示(“in-sync” replicas), 正在同步的备份, 表示可用的活着的节点
./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test2
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test2 --from-beginning
ps aux | grep server.properties #查看节点(73370)是否已启用
kill -9 73370 #杀死此节点
更多文章:点击这里
扫码关注公众号《后端开发ipoo》。一起交流分享,欢迎投稿。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。