Apache Kafka学习 (二)

  • 时间:
  • 浏览:4

> bin/kafka-server-start.sh config/server-1.properties &

...

> bin/kafka-server-start.sh config/server-2.properties &

...

broker.id=2

listeners=PLAINTEXT://:9094

log.dir=/tmp/kafka-logs-2

4. 新建三个白 有三个白基因重组的主题

> bin/kafka-console-producer.sh --broker-list localhost:9092 --topic my-replicated-topic

config/server-2.properties:

5. 查看主题

7. 测试容错机制

> cp config/server.properties config/server-1.properties

> cp config/server.properties config/server-2.properties

> ps aux | grep server-1.properties

8. 消费主题的消息

> bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic my-replicated-topic

config/server-1.properties:

------------------------------------------------

(We already have Zookeeper and our single node started, so we just need to start the two new nodes)

------------------------------------------------

6. 发布主题的消息

3. 人们 因为因为启动了zookeeper和三个白 9092的单节点,那么假如再启动那三个白 新节点就好了

7564 ttys002 0:15.91 /System/Library/Frameworks/JavaVM.framework/Versions/1.8/Home/bin/java...

> kill -9 7564

> bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic

------------------------------------------------

1. 配置server.properties

------------------------------------------------

2. 编辑server.properties

> bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic my-replicated-topic

broker.id=1

listeners=PLAINTEXT://:9093

log.dir=/tmp/kafka-logs-1