kafka_2.11-0.8.2.1单机版安装

1、下载kafka安装包
wget http://mirrors.cnnic.cn/apache/kafka/0.8.2.1/kafka_2.11-0.8.2.1.tgz

2、复制到安装目录
cp kafka_2.11-0.8.2.1.tgz /usr/local/

3、解压
cd /usr/local/
tar -zxvf kafka_2.11-0.8.2.1.tgz

4、修改配置
cd kafka_2.11-0.8.2.1
cd config
vi server.properties

进行host配置,如需被其它主机调用可配置IP
host.name=localhost

6、启动
#启动zookeeper
/usr/local/kafka_2.11-0.8.2.1/bin/zookeeper-server-start.sh /usr/local/kafka_2.11-0.8.2.1/config/zookeeper.properties > /var/tmp/zk-server-start.log &

#启动kafka
/usr/local/kafka_2.11-0.8.2.1/bin/kafka-server-start.sh /usr/local/kafka_2.11-0.8.2.1/config/server.properties > /var/tmp/kafka-server-start.log &


7、测试
#producer
/usr/local/kafka_2.11-0.8.2.1/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test

#consumer
/usr/local/kafka_2.11-0.8.2.1/bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning

在 producer 输入: message
在 consumer 显示: message
表示已安装启动成功

#创建topic test2
/usr/local/kafka_2.11-0.8.2.1/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test2

#列出当前的所有topic
/usr/local/kafka_2.11-0.8.2.1/bin/kafka-topics.sh --list --zookeeper localhost:2181

 

posted @ 2015-09-16 00:29  沐风山  阅读(1120)  评论(0编辑  收藏  举报