JobPlus知识库 IT 大数据 文章
Kafka集群的搭建

下载

https://www.apache.org/dyn/closer.cgi?path=/kafka/0.11.0.2/kafka_2.11-0.11.0.2.tgz 
解压缩

tar -xzf kafka_2.11-1.1.0.tgz

 cd kafka_2.11-1.1.0


启动zookeeper

在本地2181端口启动ZK。

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


启动kafka

复制kafka的配置文件,两个配置文件的端口号应该不同

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

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

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


config/server-1.properties:

    broker.id=1

    listeners=PLAINTEXT://:9093

    log.dir=/tmp/kafka-logs-1

config/server-2.properties:

    broker.id=2

    listeners=PLAINTEXT://:9094

    log.dir=/tmp/kafka-logs-2


创建topic(使用命令行)

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

//查看已经创建的topic

bin/kafka-topics.sh --list --zookeeper localhost:2181

//查看topic的具体信息

bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic


生产消息(使用命令行)

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


消费消息(使用命令行)

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic my-replicated-topic


部署kafka监控

这里使用kafkamanager,这个使用play框架 
下载地址 
https://github.com/yahoo/kafka-manager/releases

首先,在用户目录的./sbt下建立如下repositories文件

[repositories]

 local

 aliyun: http://maven.aliyun.com/nexus/content/groups/public

 typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly


解压缩并进入上述文件夹

./sbt clean dist


生产消息(使用Storm)

消费消息(使用Storm)

检查storm监控


如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

¥ 打赏支持
11人赞 举报
分享到
用户评价(0)

暂无评价,你也可以发布评价哦:)

扫码APP

扫描使用APP

扫码使用

扫描使用小程序