Linux docker环境kafka集群搭建

环境:

宿主机ip: 192.168.50.113

borker集群配置:

broker1: 192.168.50.113:9091
broker2: 192.168.50.113:9092
broker3: 192.168.50.113:9093

安装zookeeper

http://blog.csdn.net/lylclz/article/details/78633074

创建目录(宿主机)

mkdir -p /data1/kafka/9091/logs;
mkdir -p /data1/kafka/9092/logs;
mkdir -p /data1/kafka/9093/logs;

创建kafka容器

docker run -it --name=kafka_container  --net=host -v /data1:/data1  centos /bin/bash

下载kafka安装包

yum -y install java;
yum -y install wget;
 wget https://archive.apache.org/dist/kafka/0.9.0.0/kafka_2.10-0.9.0.0.tgz;
tar -zxvf kafka_2.10-0.9.0.0.tgz;
mv kafka_2.10-0.9.0.0 /usr/local/kafka;

配置文件

vi /data1/kafka/9091/server.properties

broker.id=1
port=9091
host.name=192.168.50.113
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=/data1/kafka/9091/logs
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.50.113:2181,192.168.50.113:2182,192.168.50.113:2183
zookeeper.connection.timeout.ms=6000
queued.max.requests =500
log.cleanup.policy = delete

vi /data1/kafka/9092/server.properties

broker.id=2
port=9092
host.name=192.168.50.113
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=/data1/kafka/9092/logs
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.50.113:2181,192.168.50.113:2182,192.168.50.113:2183
zookeeper.connection.timeout.ms=6000
queued.max.requests =500
log.cleanup.policy = delete

vi /data1/kafka/9093/server.properties

broker.id=3
port=9093
host.name=192.168.50.113
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=/data1/kafka/9093/logs
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.50.113:2181,192.168.50.113:2182,192.168.50.113:2183
zookeeper.connection.timeout.ms=6000
queued.max.requests =500
log.cleanup.policy = delete

启动

borker1:

/usr/local/kafka/bin/kafka-server-start.sh /data1/kafka/9091/server.properties > /dev/null 2>/dev/null &

borker2

/usr/local/kafka/bin/kafka-server-start.sh /data1/kafka/9092/server.properties > /dev/null 2>/dev/null &

borker3

/usr/local/kafka/bin/kafka-server-start.sh /data1/kafka/9093/server.properties > /dev/null 2>/dev/null &

:

正常

[root@192 9091]# netstat -apn | egrep "(9091|9092|9093)" | grep LISTEN
tcp6       0      0 192.168.50.113:9091     :::*                    LISTEN      1976/java
tcp6       0      0 192.168.50.113:9092     :::*                    LISTEN      2037/java
tcp6       0      0 192.168.50.113:9093     :::*                    LISTEN      2092/java 

你可能感兴趣的:(Linux docker环境kafka集群搭建)