1、初始化环境搭建
安装jdk,安装zookeeper并保证zk服务正常启动
2、下载安装包并且上传解压
通过以下地址进行下载安装包
hadoop01执行以下命令,下载并解压
cd /export/softwares
wget http://archive.apache.org/dist/kafka/1.0.0/kafka_2.11-1.0.0.tgz
tar –zxvf kafka_2.11-1.0.0.tgz -C /export/servers/
3、hadoop01服务器修改kafka配置文件
hadoop01执行以下命令进入到kafka的配置文件目录,修改配置文件
hadoop01执行以下命令创建数据文件存放目录
mkdir -p /export/servers/kafka_2.11-1.0.0/logs
cd /export/servers/kafka_2.11-1.0.0/config
vim server.properties
broker.id=0
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=/export/servers/kafka_2.11-1.0.0/logs
num.partitions=2
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
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=hadoop01:2181,hadoop02:2181,hadoop03:2181
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0
delete.topic.enable=true
host.name=hadoop01
4、安装包分发到其他服务器上面去
hadoop01执行以下命令,将node01服务器的kafka安装包发送到hadoop02和hadoop03服务器上面去
cd /export/servers/
scp -r kafka_2.11-1.0.0/ hadoop02:$PWD
scp -r kafka_2.11-1.0.0/ hadoop03:$PWD
5、hadoop02与hadoop03服务器修改配置文件
hadoop02与hadoop03服务器修改kafka配置文件
hadoop02使用以下命令修改kafka配置文件
cd /export/servers/kafka_2.11-1.0.0/config
vim server.properties
broker.id=1
host.name=hadoop02
hadoop03使用以下命令修改kafka配置文件
cd /export/servers/kafka_2.11-1.0.0/config
vim server.properties
broker.id=2
host.name=hadoop03
6、kafka集群启动与停止
注意事项:在kafka启动前,一定要让zookeeper启动起来。
三台机子都要启动
cd /export/servers/kafka_2.11-1.0.0
nohup bin/kafka-server-start.sh config/server.properties 2>&1 &
停止服务
cd /export/servers/kafka_2.11-1.0.0
bin/kafka-server-stop.sh