Fork me on GitHub

Kafka(一)

1、安装zookeeper集群

2.下载kafka    wget http://mirror.bit.edu.cn/apache/kafka/1.0.0/kafka_2.11-1.0.0.tgz

配置:

broker.id=0 //为依次增长的:0、1、2、3、4,集群中唯一id

log.dirs=/opt/kafka_2.11-0.9.0.1/logs //日志地址

zookeeper.connect=master:2181,slave1:2181,slave2:2181 //zookeeperServers列表,各节点以逗号分开

3.启动

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

创建topic
kafka-topics.sh  --create --zookeeper master:2181,node1:2181,node2:2181 --replication-factor 3  --partitions 3 --topic  topic20180103-1


列出所有topic
kafka-topics.sh --list --zookeeper master:2181,node1:2181,node2:2181

列出topic的详细信息
kafka-topics.sh  --zookeeper master:2181,node1:2181,node2:2181 --topic topic20180103-1 --describe


删除topic
kafka-topics.sh --zookeeper master:2181,node1:2181,node2:2181   --delete --topic "topictest"


kafka-topics.sh --delete --zookeeper HadoopMaster:2181/kafka --topic test

//生产数据
kafka-console-producer.sh --broker-list node1:9092,node2:9092,node3:9092 --topic topic20180103-1

//消费数据
kafka-console-consumer.sh --zookeeper master:2181,node1:2181,node2:2181 --from-beginning --topic topic20180103-1

//新(支持0.9版本+)

./kafka-console-consumer.sh --bootstrap-server node1:9092,node2:9092,node3:9092 --topic topic20180103-1 --from-beginning

 

 

参考:http://blog.csdn.net/lnho2015/article/details/51352966

 

posted @ 2018-01-03 17:35  薄荷加冰2060  阅读(141)  评论(0编辑  收藏  举报