其他分享
首页 > 其他分享> > kafka环境部署(二)

kafka环境部署(二)

作者:互联网

一个机器上部署kafka集群服务
服务器:2*kafka+2*Zookeeper环境搭建

Zookeeper配置
拷贝2份zookeeper.properties文件,重命名为zookeeper1.properties,zookeeper2.properties
修改zookeeper1.properties:

dataDir=/tmp/zookeeper1
dataLogDir=/tmp/log/zookeeper1
clientPort=2181
tickTime=3000
initLimit=10
syncLimit=5
#maxClientCnxns=0
server.0=localhost:2888:3888
server.1=localhost:4888:5888

修改zookeeper2.properties:

dataDir=/tmp/zookeeper2
dataLogDir=/tmp/log/zookeeper2
clientPort=2182
tickTime=3000
initLimit=10
syncLimit=5
server.0=localhost:2888:3888
server.1=localhost:4888:5888

zookeeper的dataDir节点配置的目录下添加myid文件,写入broker.id的值,这里需与zookeeper1.properties的配置相同
在/tmp/zookeeper1下的myid写入0
在这里插入图片描述

在/tmp/zookeeper2下的myid写入1
在这里插入图片描述

Kafka配置
拷贝2份server.properties文件,重命名为server1.properties,server2.properties
修改server1.properties:

broker.id=0
listeners=PLAINTEXT://localhost:9092
log.dir=/tmp/kafka-logs/kafka1
zookeeper.connect=localhost:2181,localhost:2182
num.partitions=2
default.replication.factor=2

修改server2.properties:

#集群id
broker.id=1
#listeners地址
listeners=PLAINTEXT://localhost:9093
#日志路径
log.dir=/tmp/kafka-logs/kafka2
#zookeeper连接地址
zookeeper.connect=localhost:2181,localhost:2182
#新建topic默认分区数
num.partitions=2
#保存消息的副本数
default.replication.factor=2

进入kafka跟目录,启动zookeeper服务

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

配置多个zookeeper服务时,只启动一个zookeeper会报错,待全部启动后错误消失。

启动kafka服务

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

标签:tmp,部署,zookeeper,环境,kafka,zookeeper1,properties,localhost
来源: https://blog.csdn.net/weixin_43510054/article/details/117530946