kafka安装

一、kafka安装(集群模式)

1、安装前准备

机器:10.199.240.232,10.199.206.20

kafka版本:2.12-0.10.1.1

下载地址; https://mirrors.tuna.tsinghua.edu.cn/apache/

相关目录:

/apps/svr/kafka_2.12-0.10.1.1  kafka根目录

/apps/logs/kafka                       kafka日志目录

/apps/sh                                       kafka启动脚本

注意:笔者 zk 已经提前部署好;本文没有对zk的集群安装简述

2、安装步骤

(1)kafka booker1

cd /apps/svr/kafka_2.12-0.10.1.1/config

mv server.properties server.properties.bak

touch server.properties

vim server.properties

broker.id=1

listeners=PLAINTEXT://10.199.206.20:9092

advertised.listeners=PLAINTEXT://10.199.206.20:9092

host.name=10.199.206.20

num.network.threads=3

num.io.threads=8

socket.send.buffer.bytes=102400

socket.receive.buffer.bytes=102400

socket.request.max.bytes=104857600

num.partitions=3

num.recovery.threads.per.data.dir=1

log.dirs=/apps/logs/kafka

log.flush.interval.messages=10000

log.flush.interval.ms=1000

log.retention.hours=168

log.segment.bytes=1073741824

log.retention.check.interval.ms=300000

zookeeper.connect=zk1:2181

zookeeper.connection.timeout.ms=6000

vim producer.properties

bootstrap.servers=10.199.240.232:9092,10.199.206.20:9092

compression.type=none

vim /etc/hosts

10.199.240.232 kafka2  zk2  db-t7pfx.vclound.com

10.199.206.20  kafka1  zk1  xupengzhang-gz5rn.vclound.com

 

(2)kafka broker2

cd /apps/svr/kafka_2.12-0.10.1.1/config

mv server.properties server.properties.bak

touch server.properties

vim server.properties

broker.id=2

listeners=PLAINTEXT://10.199.240.232:9092

advertised.listeners=PLAINTEXT://10.199.240.232:9092

host.name=10.199.240.232

num.network.threads=3

num.io.threads=8

socket.send.buffer.bytes=102400

socket.receive.buffer.bytes=102400

socket.request.max.bytes=104857600

num.partitions=3

num.recovery.threads.per.data.dir=1

log.dirs=/apps/logs/kafka

log.flush.interval.messages=10000

log.flush.interval.ms=1000

log.retention.hours=168

log.segment.bytes=1073741824

log.retention.check.interval.ms=300000

zookeeper.connect=zk1:2181

zookeeper.connection.timeout.ms=6000

vim producer.properties

bootstrap.servers=10.199.240.232:9092,10.199.206.20:9092

compression.type=none

vim /etc/hosts

10.199.240.232 kafka2  zk2  db-t7pfx.vclound.com

10.199.206.20  kafka1  zk1  xupengzhang-gz5rn.vclound.com

(3)启动脚本

 1 source /etc/profile
 2 kafkaHome="/apps/svr/kafka_2.12-0.10.1.1"
 3 kafkaBin="$kafkaHome/bin"
 4 kafkaConf="$kafkaHome/config"
 5 zkHome="/apps/svr/zookeeper-3.4.11"
 6 zkBin="$zkHome/bin"
 7 
 8 function start() {
 9         echo "Starting bundle zookeeper..."
10         $zkHome/bin/zkServer.sh start &
11         sleep 3
12         echo "Starting kafka server..."
13         $kafkaHome/bin/kafka-server-start.sh -daemon $kafkaHome/config/server.properties &
14         return $?
15 }
16 
17 function stop() {
18         echo "Stoping kafka server..."
19         $kafkaHome/bin/kafka-server-stop.sh -daemon $kafkaHome/config/server.properties &
20         sleep 3
21         echo "Stoping bundle zookeeper..."
22         $zkHome/bin/zkServer.sh stop &
23         return $?
24 }
25 case "$1" in
26     start)
27         start
28     ;;
29     stop)
30         stop
31     ;;
32     restart)
33         stop
34         sleep 1
35         start
36     ;;

 

posted @ 2017-11-30 20:47  xupeng.zhang  阅读(283)  评论(0编辑  收藏  举报