欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

2.kafka 分布式集群安装

程序员文章站 2024-01-20 09:58:28
Kafka集群安装主节点h201,从节点h202、h2031.安装jdk1.8[hadoop@h201 ~]$ /usr/jdk1.8.0_144/bin/java -version 2.安装zookeeperkafka集群需要 zookeeper支持[hadoop@h201 ~]$ tar -zx ......

kafka集群安装
主节点h201,从节点h202、h203
1.安装jdk1.8
[hadoop@h201 ~]$ /usr/jdk1.8.0_144/bin/java -version

2.安装zookeeper
kafka集群需要 zookeeper支持
[hadoop@h201 ~]$ tar -zxvf zookeeper-3.4.5-cdh5.5.2.tar.gz

[hadoop@h201 zookeeper-3.4.5-cdh5.5.2]$ mkdir data
[hadoop@h201 zookeeper-3.4.5-cdh5.5.2]$ mkdir log

[hadoop@h201 conf]$ vi zoo.cfg
ticktime=2000
#心跳的时间间隔
initlimit=10
#初始化连接时最长能忍受多少个心跳时间间隔数
synclimit=5
#leader 与follower 之间发送消息,请求和应答时间长度

datadir=/home/hadoop/zookeeper-3.4.5-cdh5.5.2/data
datalogdir=/home/hadoop/zookeeper-3.4.5-cdh5.5.2/data
clientport=2181
server.1=192.168.8.201:2888:3888
server.2=192.168.8.202:2888:3888
server.3=192.168.8.203:2888:3888

[hadoop@h201 ~]$ scp -r zookeeper-3.4.5-cdh5.5.2 h202:/home/hadoop/
[hadoop@h201 ~]$ scp -r zookeeper-3.4.5-cdh5.5.2 h203:/home/hadoop/

[hadoop@h201 ~]$ echo "1" > zookeeper-3.4.5-cdh5.5.2/data/myid
[hadoop@h202 ~]$ echo "2" > zookeeper-3.4.5-cdh5.5.2/data/myid
[hadoop@h203 ~]$ echo "3" > zookeeper-3.4.5-cdh5.5.2/data/myid

3.kafka安装 (集群安装模式)
[hadoop@h201 ~]$tar -zxvf kafka_2.12-0.10.2.1.tgz
[hadoop@h201kafka_2.12-0.10.2.1]$ mkdir kafkalogs
[hadoop@h201kafka_2.12-0.10.2.1]$ cd config
[hadoop@h201 config]$ vi server.properties

#broker.id=0
#每台节点唯一
#zookeeper.connect=localhost:2181
#关闭kafka自带的zk
#log.dirs=/tmp/kafka-logs

host.name=h201
#每节点的地址
log.dirs=/home/hadoop/kafka_2.12-0.10.2.1/kafkalogs
message.max.byte=5242880
default.replication.factor=2
replica.fetch.max.bytes=5242880
broker.id=1
port=9092
zookeeper.connect=h201:2181,h202:2181,h203:2181
########禁用原始的broker.id=0#########

[hadoop@h201 ~]$ scp -r kafka_2.12-0.10.2.1 h202:/home/hadoop/
[hadoop@h202 config]$ vi server.properties
修改
host.name=h202
broker.id=2

[hadoop@h201 ~]$ scp -r kafka_2.12-0.10.2.1 h203:/home/hadoop/
[hadoop@h203 config]$ vi server.properties
修改
host.name=h203
broker.id=3

启动服务
[hadoop@h201 zookeeper-3.4.5-cdh5.5.2]$ bin/zkserver.sh start
[hadoop@h202 zookeeper-3.4.5-cdh5.5.2]$ bin/zkserver.sh start
[hadoop@h203 zookeeper-3.4.5-cdh5.5.2]$ bin/zkserver.sh start

[hadoop@h201kafka_2.12-0.10.2.1]$ bin/kafka-server-start.sh config/server.properties &
[hadoop@h202kafka_2.12-0.10.2.1]$ bin/kafka-server-start.sh config/server.properties &
[hadoop@h203kafka_2.12-0.10.2.1]$ bin/kafka-server-start.sh config/server.properties &

[hadoop@h201kafka_2.12-0.10.2.1]$jps