部署kafka集群

tar zxvf zookeeper-3.4.6.tar

ln -s /apps/svr/zookeeper-3.4.6 zookeeper

cd zookeeper

vi conf/zoo_sample.cfg

tickTime=2000

initLimit=10

syncLimit=5

dataDir=/apps/svr/zookeeper/data

clientPort=2181
server.1=10.0.20.120:2887:3887
server.2=10.0.20.121:2888:3888
server.3=10.0.20.122:2889:3889

mkdir data

mv conf/zoo_sample.cfg conf/zoo.cfg

/bin/zkServer.sh start

mkdir -p /apps/logs/kafka/msgdata

http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/0.11.0.0/kafka_2.12-0.11.0.0.tgz

tar xvf kafka_2.12-0.11.0.0.tgz

vi server.properties
# 10.0.20.120
broker.id=0
listeners=PLAINTEXT://10.0.20.120:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/apps/logs/kafka/msgdata
num.partitions=1
num.recovery.threads.per.data.dir=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=10.0.20.120:2181,10.0.20.121:2181,10.0.20.122:2181
zookeeper.connection.timeout.ms=6000

#10.0.20.121
broker.id=2
listeners=PLAINTEXT://10.0.20.121:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/apps/logs/kafka/msgdata
num.partitions=1
num.recovery.threads.per.data.dir=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=10.0.20.120:2181,10.0.20.121:2181,10.0.20.122:2181
zookeeper.connection.timeout.ms=6000

#10.0.20.122
broker.id=3
listeners=PLAINTEXT://10.0.20.122:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/apps/logs/kafka/msgdata
num.partitions=1
num.recovery.threads.per.data.dir=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=10.0.20.120:2181,10.0.20.121:2181,10.0.20.122:2181
zookeeper.connection.timeout.ms=6000
./bin/kafka-server-start.sh -daemon config/server.properties
./bin/kafka-topics.sh --create --zookeeper 10.0.20.120:2181 --replication-factor 2 --partitions 1 --topic shuaige
./bin/kafka-console-producer.sh --broker-list 10.0.20.120:9092 --topic shuaige
./bin/kafka-console-consumer.sh --zookeeper 10.0.20.120:2181 --topic shuaige --from-beginning
./bin/kafka-topics.sh --list --zookeeper 10.0.20.120:2181
./bin/kafka-topics.sh --describe --zookeeper 10.0.20.120:2181 --topic shuaige

#正式服
tar zxvf zookeeper-3.4.6.tar
ln -s /apps/svr/zookeeper-3.4.6 zookeeper
cd zookeeper

vi conf/zoo_sample.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/apps/svr/zookeeper/data
clientPort=2181
server.1=10.0.5.210:2887:3887
server.2=10.0.5.211:2888:3888
server.3=10.0.5.212:2889:3889
mkdir data
mv conf/zoo_sample.cfg conf/zoo.cfg
/bin/zkServer.sh start
mkdir -p /apps/logs/kafka/msgdata
http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/0.11.0.0/kafka_2.12-0.11.0.0.tgz
tar xvf kafka_2.12-0.11.0.0.tgz

vi server.properties
# 10.0.5.210
broker.id=0
listeners=PLAINTEXT://10.0.5.210:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/apps/logs/kafka/msgdata
num.partitions=1
num.recovery.threads.per.data.dir=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=10.0.5.210:2181,10.0.5.211:2181,10.0.5.212:2181
zookeeper.connection.timeout.ms=6000

#10.0.5.211
broker.id=2
listeners=PLAINTEXT://10.0.5.211:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/apps/logs/kafka/msgdata
num.partitions=1
num.recovery.threads.per.data.dir=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=10.0.5.210:2181,10.0.5.211:2181,10.0.5.212:2181
zookeeper.connection.timeout.ms=6000

#10.0.5.212
broker.id=3
listeners=PLAINTEXT://10.0.5.212:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/apps/logs/kafka/msgdata
num.partitions=1
num.recovery.threads.per.data.dir=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=10.0.5.210:2181,10.0.5.211:2181,10.0.5.212:2181
zookeeper.connection.timeout.ms=6000
./bin/kafka-server-start.sh -daemon config/server.properties ;tail -f logs/kafkaServer.out
./bin/kafka-topics.sh --create --zookeeper 10.0.5.210:2181 --replication-factor 2 --partitions 1 --topic shuaige
./bin/kafka-console-producer.sh --broker-list 10.0.5.210:9092 --topic shuaige
./bin/kafka-console-consumer.sh --zookeeper 10.0.5.210:2181 --topic shuaige --from-beginning
./bin/kafka-topics.sh --list --zookeeper 10.0.5.210:2181
./bin/kafka-topics.sh --describe --zookeeper 10.0.5.210:2181 --topic shuaige