安装zookeeper和kafka
软件及版本
软件 | 版本 |
---|---|
zookeeper | 3.5.7 |
kafka | 2.12-2.2.2 |
jdk | 1.8 |
安装zookeeper
tar xf apache-zookeeper-3.5.7-bin.tar.gz -C /usr/local/
cd /usr/local/
ln -s apache-zookeeper-3.5.7-bin zookeeper
cd zookeeper/conf/
cp zoo_sample.cfg zoo.cfg
修改配置文件
dataDir=/data1/zk/data
dataLogDir=/data1/zk/log
server.1=192.168.68.7:2888:3888
server.2=192.168.69.7:2888:3888
server.3=192.168.70.7:2888:3888
[root@kafka_70 conf]# grep -v '^#' zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
clientPort=2181
dataDir=/data1/zk/data
dataLogDir=/data1/zk/log
server.1=192.168.68.7:2888:3888
server.2=192.168.69.7:2888:3888
server.3=192.168.70.7:2888:3888
创建数据和日志目录
mkdir /data1/zk/data
mkdir /data1/zk/log
创建myid文件, 不同的节点设置不同的数字, 比如测试环境的三节点myid为1, 2, 3
echo 1 > /data1/zk/data/myid
安装kafka
tar xf kafka_2.12-2.2.2.tgz -C /usr/local/
cd /usr/local/
ln -s kafka_2.12-2.2.2 kafka
mkdir -p /data1/kafka/log
修改配置文件
broker.id=0 #不同的节点配置不同的brokerID, 以三节点为例, 分别为0, 1, 2
listeners=PLAINTEXT://kafka1:9092 #修改为主机名, 需要在数据发送端配置好kafka主机名的host解析
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=/data1/kafka/log
num.partitions=1
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.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=192.168.68.7:2181,192.168.69.7:2181,192.168.70.7:2181 #配置zookeeper集群
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0
修改/etc/profile文件, 添加环境变量
export ZK_HOME=/usr/local/zookeeper/
export PATH=$ZK_HOME/bin:$PATH
export KAFKA_HOME=/usr/local/kafka
export PATH=${KAFKA_HOME}/bin:$PATH
启动服务
zkServer.sh start
zkServer.sh status
kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties