在Ubuntu12.04 server上安装单结点kafka,我的机器上之前已经安装过zookeeper-3.4.5
根据官网的说明:http://kafka.apache.org/07/quickstart.html
下载一个kafka-0.7.2.tar.gz,解压安装
> tar xzf kafka-<VERSION>.tgz > cd kafka-<VERSION> > ./sbt update > ./sbt package
这个过程中会自动安装Scala,需要花费点时间。
修改/config/server.properties文件,将里面的hostname修改为你主机的IP,还需要修改zk.connect为ZooKeeper的IP:2181。
然后重启kafka-server-start.sh
bin/kafka-server-start.sh config/server.properties
producer发送消息
bin/kafka-console-producer.sh --zookeeper localhost:2181 --topic test
This is a test.
consumer获得消息
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
This is a test.