kafka的配置和操作

kafka复习:
1.入门–
1.1简介
三大功能:发布和订阅消息订阅系统、容错方式存储、处理记录发生的

kafka概念:
Kafka作为一个或多个服务器上的集群运行。 高吞吐
Kafka集群以称为主题的类别存储记录流。
每个记录由一个键,一个值和一个时间戳组成。

一个主题可以有多个订阅写入消费者中的。

写一个测试用例:
1.开启zookeeper服务
bin/zookeeper-server-start.sh config/zookeeper.properties
2.开启kafka服务:
bin/kafka-server-start.sh config/server.properties
3.创建一个主题–test
bin/kafka-topics.sh –create –zookeeper localhost:2181 –replication-factor 1 –partitions 1 –topic test
4.运行这个主题
bin/kafka-topics.sh –list –zookeeper localhost:2181 test
5.运行一个生产者,并向让这个生产者产生一些数据(可以来自客服端的监控)
bin/kafka-console-producer.sh –broker-list localhost:9092 –topic test
6.启动一个用户,用来消费生产者的数据
bin/kafka-console-consumer.sh –bootstrap-server localhost:9092 –topic test –from-beginning


zookeeper的三个配置

the directory where the snapshot is stored.路径

dataDir=/tmp/zookeeper

the port at which the clients will connect 监听端口号

clientPort=2181

disable the per-ip limit on the number of connections since this is a non-production config

maxClientCnxns=0

server.properties配置项

broker.id=0
num.network.threads=2
num.io.threads=8
socket.send.buffer.bytes=1048576
socket.receive.buffer.bytes=1048576
socket.request.max.bytes=104857600
log.dirs=/tmp/kafka-logs
num.partitions=2
log.retention.hours=168

log.segment.bytes=536870912
log.retention.check.interval.ms=60000
log.cleaner.enable=false

zookeeper.connect=master:2181
zookeeper.connection.timeout.ms=1000000

猜你喜欢

转载自blog.csdn.net/qq_33202508/article/details/79132144