kafka集群配置案例

前置条件


1、需要修改hosts文件添加主机名和ip的对应关系
2、需要安装jdk1.8版本支持
3、需要修改server.properties 修改host.name=主机IP


然后启动服务
bin/kafka-server-start.sh config/server.properties &


创建topic


bin/kafka-topics.sh --create --topic topic_1 --partitions 1 --replication-factor 3  \--zookeeper 192.168.35.201:2181
bin/kafka-topics.sh --create --topic topic_2 --partitions 1 --replication-factor 3  \--zookeeper 192.168.35.201:2181
bin/kafka-topics.sh --create --topic topic_3 --partitions 1 --replication-factor 3  \--zookeeper 192.168.35.201:2181


查看tipic
bin/kafka-topics.sh --list --zookeeper 192.168.35.201:2181


查看topic属性
bin/kafka-topics.sh --describe --zookeeper 192.168.35.201:2181 




测试发送消息
bin/kafka-console-producer.sh --topic topic_1 --broker-list 192.168.35.205:9092,192.168.35.206:9093,192.168.35.204:9094


输入字符串


测试接收消息
bin/kafka-console-consumer.sh --topic topic_1 --zookeeper 192.168.35.201:2181 --from-beginning


接收到字符串




======================================================================================
配置文件
broker.id=1
listeners=PLAINTEXT://:9093
port=9093
host.name=192.168.35.203
num.network.threads=4
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/tmp/kafka-logs1
num.partitions=5
num.recovery.threads.per.data.dir=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
log.cleaner.enable=false
zookeeper.connect=192.168.35.201:2181,192.168.35.202:2181,192.168.35.203:2181
zookeeper.connection.timeout.ms=6000
queued.max.requests =500
log.cleanup.policy = delete


---------------------------------------------


broker.id=2
listeners=PLAINTEXT://:9094
port=9094
host.name=192.168.35.204
num.network.threads=4
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/tmp/kafka-logs2
num.partitions=5
num.recovery.threads.per.data.dir=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
log.cleaner.enable=false
zookeeper.connect=192.168.35.201:2181,192.168.35.202:2181,192.168.35.203:2181
zookeeper.connection.timeout.ms=6000
queued.max.requests =500
log.cleanup.policy = delete
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值