您的位置:首页 > 运维架构 > Apache

Apache kafka之旅——linux 安装配置

2015-11-10 14:03 399 查看
kafka  安装的安装比较简单,直接下载解压缩,修改一下配置文件然后启动服务就能使用了

kafka 官方下载地址http://kafka.apache.org/downloads.html

一、下载

wget http://mirror.bit.edu.cn/apache/kafka/0.8.2.2/kafka_2.9.2-0.8.2.2.tgz

二、解压缩

tar -xzvf

kafka_2.9.2-0.8.2.2.tgz

三 、修改配置文件

进入到配置文件目录

cd kafka_2.9.2-0.8.2.2/config

vi server.properties

把host.name 的注释打开并把host.name=localhost 修改为host.name=ip

如host.name=192.168.30.229

四、启动服务

(1)先启动zookeeper

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

(2)启动kafka

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

五、创建topic

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

六、发送消息

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test

kafka常用命令

查看topic列表:bin/kafka-topics.sh --list --zookeeper localhost:2181

查看topic :bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning

删除topic:bin/kafka-run-class.sh kafka.admin.DeleteTopicCommand --zookeeper localhost:2181 --topic test

ps:上面的host.name=ip记得一定要修改,不然在后面的java程序调用的时候会不识别,有异常

关于kafka详细的介绍

推荐一篇文章http://www.mincoder.com/article/3942.shtml
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: