Linux docker環境kafkaクラスタ構築

13272 ワード

環境:


ホストip:192.168.5.0.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