Apache kafka之旅——linux 安装配置

来源:互联网 发布:广州淘宝美工培训学校 编辑:程序博客网 时间:2024/06/07 06:55

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 -xzvfkafka_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



0 0
原创粉丝点击