kafka单机多实例部署

目录

一.环境准备

当前环境:centos7.3一台
软件版本:kafka_2.12
部署目录:/usr/local/kafka
启动端口:9092,9093,9094
配置文件:/usr/local/kafka/config/server.properties

yum依赖
yum install java-1.8.0-openjdk

需要部署zookeeper单机多实例

二.安装

1.下载kafka包
wget http://mirror.bit.edu.cn/apache/kafka/0.10.2.1/kafka_2.12-0.10.2.1.tgz

2.解压并移动,然后创建日志目录
tar zxvf kafka_2.12-0.10.2.1.tgz
mv kafka_2.12-0.10.2.1 /usr/local/kafka

mkdir /var/log/kafka/one
mkdir /var/log/kafka/two
mkdir /var/log/kafka/three

3.复制配置文件
cd /usr/local/kafka
cp config/server.properties config/server1.properties
cp config/server.properties config/server2.properties
cp config/server.properties config/server3.properties

修改配置文件,这里只修改第一个,后面几个类似
vim /usr/local/kafka/config/server1.properties

#第一个节点1,第二个节点2
broker.id=1

# Switch to enable topic deletion or not, default value is false
delete.topic.enable=true

#本机开启端口和监听端口
port=9092,第二个是9093
advertised.host.name=192.168.1.189

# The number of threads handling network requests
num.network.threads=3

# The number of threads doing disk I/O
num.io.threads=8

# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes=102400

# The receive buffer (SO_RCVBUF) used by the socket server
socket.receive.buffer.bytes=102400

# The maximum size of a request that the socket server will accept (protection against OOM)
socket.request.max.bytes=104857600

#日志目录,第二个是two
log.dirs=/var/log/kafka/one

#开启10个分区
num.partitions=10

#kafka保存消息的副本数
default.replication.factor=3

# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1

#持久化时间
log.retention.hours=48

# The maximum size of a log segment file. When this size is reached a new log segment will be created.
log.segment.bytes=1073741824

# to the retention policies
log.retention.check.interval.ms=300000

#连接zookeeper集群地址端口
zookeeper.connect=192.168.1.189:2181,192.168.1.190:2181,192.168.1.191:2181

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000

三.使用验证

启动
/usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server1.properties

/usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server2.properties

/usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server3.properties

检查
netstat -unltp | grep 909*

上一篇:不停服务,动态加载properties资源文件


下一篇:事务