赞
踩
- 1.首先搭建zookeeper
- 1.创建zookeeper
- cd zookeeper
- mkdir server1
- mkdir server2
- mkdir server3
- tar -zxvf zookeeper.tar.gz
- cp -r zookeeper server1
- cp -r zookeeper server2
- cp -r zookeeper server3
-
- server1配置
- tickTime=2000
- initLimit=10
- syncLimit=5
- dataDir=/home/ixj/zookeeper/server1/data
- dataLogDir=/home/ixj/zookeeper/server1/datalog
- clientPort=2181
- server.1=127.0.0.1:2888:3888
- server.2=127.0.0.1:2889:3889
- server.3=127.0.0.1:2890:3890
-
- server2配置
- tickTime=2000
- initLimit=10
- syncLimit=5
- dataDir=/home/ixj/zookeeper/server2/data
- dataLogDir=/home/ixj/zookeeper/server2/datalog
- clientPort=2182
- server.1=127.0.0.1:2888:3888
- server.2=127.0.0.1:2889:3889
- server.3=127.0.0.1:2890:3890
-
- server3配置
- tickTime=2000
- initLimit=10
- syncLimit=5
- dataDir=/home/ixj/zookeeper/server3/data
- dataLogDir=/home/ixj/zookeeper/server3/datalog
- clientPort=2183
- server.1=127.0.0.1:2888:3888
- server.2=127.0.0.1:2889:3889
- server.3=127.0.0.1:2890:3890
- 2.搭建kafka
-
- 下载解压,复制三份,分别更改config/server.properties
-
-
-
- kafka1配置
- broker.id=0
- num.network.threads=3
- num.io.threads=8
- socket.send.buffer.bytes=102400
- socket.receive.buffer.bytes=102400
- socket.request.max.bytes=104857600
- log.dirs=/home/ixj/kafka/kafkalogs1
- num.partitions=1
- num.recovery.threads.per.data.dir=1
- offsets.topic.replication.factor=1
- listeners=PLAINTEXT://127.0.0.1:9092
- port=9092
- host.name=127.0.0.1
-
- transaction.state.log.replication.factor=1
- transaction.state.log.min.isr=1
- #log.flush.interval.ms=1000
- log.retention.hours=168
- log.segment.bytes=1073741824
- log.retention.check.interval.ms=300000
- zookeeper.connect=127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183
- zookeeper.connection.timeout.ms=6000
- group.initial.rebalance.delay.ms=0
-
-
- kafka2配置
- broker.id=0
- num.network.threads=3
- num.io.threads=8
- socket.send.buffer.bytes=102400
- socket.receive.buffer.bytes=102400
- socket.request.max.bytes=104857600
- log.dirs=/home/ixj/kafka/kafkalogs2
- num.partitions=1
- num.recovery.threads.per.data.dir=1
- offsets.topic.replication.factor=1
- listeners=PLAINTEXT://127.0.0.1:9093
- port=9093
- host.name=127.0.0.1
-
- transaction.state.log.replication.factor=1
- transaction.state.log.min.isr=1
- #log.flush.interval.ms=1000
- log.retention.hours=168
- log.segment.bytes=1073741824
- log.retention.check.interval.ms=300000
- zookeeper.connect=127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183
- zookeeper.connection.timeout.ms=6000
- group.initial.rebalance.delay.ms=0
-
-
-
-
- kafka3配置
- broker.id=0
- num.network.threads=3
- num.io.threads=8
- socket.send.buffer.bytes=102400
- socket.receive.buffer.bytes=102400
- socket.request.max.bytes=104857600
- log.dirs=/home/ixj/kafka/kafkalogs3
- num.partitions=1
- num.recovery.threads.per.data.dir=1
- offsets.topic.replication.factor=1
- listeners=PLAINTEXT://127.0.0.1:9094
- port=9094
- host.name=127.0.0.1
-
- transaction.state.log.replication.factor=1
- transaction.state.log.min.isr=1
- #log.flush.interval.ms=1000
- log.retention.hours=168
- log.segment.bytes=1073741824
- log.retention.check.interval.ms=300000
- zookeeper.connect=127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183
- zookeeper.connection.timeout.ms=6000
- group.initial.rebalance.delay.ms=0
- 启动
- 1. ./bin/kafka-server-start.sh config/server.properties
-
- 创建:bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 3 --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
-
-
-
-
-
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。