阅读更多
1.下载 kafka_2.10-0.9.0.1.tgz
下载路径:http://kafka.apache.org/downloads.html
2.解包
# tar -zvxf kafka_2.10-0.9.0.1.tgz
3.切换目录
# cd kafka_2.10-0.9.0.1
4.配置
# cd config
# vi server.properties
【server1】
broker.id=1
port=9092
host.name=server1
socket.send.buffer.bytes=1048576
socket.receive.buffer.bytes=1048576
socket.request.max.bytes=104857600
log.dir=./kafka1-logs
num.partitions=10
zookeeper.connect=zk1:2181,zk2:2181,zk3:2181
【server2】
broker.id=2
port=9092
host.name=server2
socket.send.buffer.bytes=1048576
socket.receive.buffer.bytes=1048576
socket.request.max.bytes=104857600
log.dir=./kafka1-logs
num.partitions=10
zookeeper.connect=zk1:2181,zk2:2181,zk3:2181
【server3】
broker.id=3
port=9092
host.name=server3
socket.send.buffer.bytes=1048576
socket.receive.buffer.bytes=1048576
socket.request.max.bytes=104857600
log.dir=./kafka1-logs
num.partitions=10
zookeeper.connect=zk1:2181,zk2:2181,zk3:2181
4)启动kafka服务(在server1,server2,server3上分别运行)
# cd bin
# ./kafka-server-start.sh ../config/server.properties &
5)创建Topic
# ./kafka-topics.sh --create --zookeeper zk1:2181,zk2:2181,zk3:2181 --replication-factor 3 --partitions 1 --topic test
6)查看Topic列表
# ./kafka-topics.sh --list --zookeeper zk1:2181,zk2:2181,zk3:2181
7)查看Topic状态
# ./kafka-topics.sh --describe --zookeeper zk1:2181,zk2:2181,zk3:2181 --topic test
8)producer发送消息
#./kafka-console-producer.sh --broker-list server1:9092,server2:9092,server3:9092 --topic test
9)consumer接收消息
#./kafka-console-consumer.sh --zookeeper zk1:2181,zk2:2181,zk3:2181 --topic test --from-beginning