概述
集群安装或者单机安装都可以,这里介绍集群安装。Kafka本身安装包也自带了zookeeper,也可以使用其自带的zookeeper。建议试用自己安装的zookeeper,本教程试用单独安装的zookeeper。
安装环境
3台centos7虚拟机:10.15.21.62 10.10.182.168 10.10.182.169
kafka_2.10-0.10.2.0
zookeeper-3.4.9
jdk-1.8.0(安装不做赘述)
环境初始化
定义目录结构。
mkdir /opt/zookeeper
mkdir /opt/zkdata
mkdir /opt/zkdatalog
mkdir /opt/kafka
下载软件
cd /opt/zookeeper
wget https://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
cd /opt/kafka/
wget http://mirror.bit.edu.cn/apache/kafka/0.10.2.0/kafka_2.10-0.10.2.0.tgz
Zookeeper集群搭建
- 修改配置文件
cd /opt/zookeeper/
tar –xvf zookeeper-3.4.9.tar.gz
cd zookeeper-3.4.9/conf
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/opt/zookeeper/zkdata
dataLogDir=/opt/zookeeper/zkdatalog
# the port at which the clients will connect
clientPort=2181
server.1=zk1:2888:3888
server.2=zk2:2888:3888
server.3=zk3:2888:3888
# the maximum number of client connections.
# increase this if you need to handle more clients
server.1 这个1是服务器的标识也可以是其他的数字, 表示这个是第几号服务器,用来标识服务器,这个标识后