kafka安装

 kafka分布式消息发布订阅系统

① 易于扩展;

② 发布/订阅高吞吐量;

③ 可持久化;

1. 下载kafka

wget http://apache.fayea.com/kafka/0.8.2.0/kafka_2.10-0.8.2.0.tgz

2. 安装

tar zxvf kafka_2.10-0.8.2.0.tgz

3. 修改zookeeper配置:

 
/Users/hyy044101331/java_tools/kafka_2.10-0.8.2.0/config
vi server.properties
zookeeper.connect=localhost:2181
zookeeper.connection.timeout.ms=6000

4. 启动zoookeeper

cd /Users/hyy044101331/java_tools
sh zk-jiqun-start.sh

5. 启动kafka

cd /Users/hyy044101331/java_tools/kafka_2.10-0.8.2.0/bin
sh kafka-server-start.sh ../config/server.properties

6. 创建topic

mengka-2:kafka_2.10-0.8.2.0 hyy044101331$ pwd
/Users/hyy044101331/java_tools/kafka_2.10-0.8.2.0

mengka-2:kafka_2.10-0.8.2.0 hyy044101331$ sh create_topic.sh mengka
Created topic "mengka".
1 #!/bin/bash
  2
  3 ###
  4 #  create a topic
  5 ###
  6
  7 sh /Users/hyy044101331/java_tools/kafka_2.10-0.8.2.0/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --    topic $1

7. 查看topic列表

sh /Users/hyy044101331/java_tools/kafka_2.10-0.8.2.0/bin/kafka-topics.sh --list --zookeeper localhost:2181
mengka

8. 查看topic的详细信息

kafka-topics.sh --describe --zookeeper localhost:2181 --topic mengka

mengka-2:bin hyy044101331$ sh /Users/hyy044101331/java_tools/kafka_2.10-0.8.2.0/bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic mengka
Topic:mengka PartitionCount:1 ReplicationFactor:1 Configs:
Topic: mengka Partition: 0 Leader: 0 Replicas: 0 Isr: 0

9. 停止kafka

ps -ef|grep server.properties

kill -9 9697

相关推荐