Zookeeper集群搭建

三台虚拟机安装好Linux操作系统cenots, jdk , 配置好ip

192.168.180.10

192.168.180.11

192.168.180.12

下载好zookeeper安装包,解压

配置zk环境变量vim /etc/profile

# zookeeper add by gxf
export ZOOKEEPER_HOME=/opt/software/zookeeper/apache-zookeeper-3.7.0-bin
export PATH=$ZOOKEEPER_HOME/bin:$PATH
source /etc/profile

环境变量生效

zk解压目录创建data和logs目录

mkdir data logs

/opt/software/zookeeper/apache-zookeeper-3.7.0-bin/conf目录编辑zoo.cfg

tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/software/zookeeper/data
dataLogDir=/opt/software/zookeeper/logs
clientPort=2181
server.1=192.168.180.10:2888:3888
server.2=192.168.180.11:2888:3888
server.3=192.168.180.12:2888:3888

 

/opt/software/zookeeper/data创建myid文件,编辑内容,各个节点设置对应serverid。节点和id对应关系不能错,不然启动不了

192.168.180.10节点myid内容增加1

192.168.180.11节点myid内容增加2

192.168.180.12节点myid内容增加3

启动zk

sh zkServer.sh start

输出内容,启动成功

ZooKeeper JMX enabled by default
Using config: /opt/software/zookeeper/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

查看zk节点状态

sh zkServer.sh status

输出

ZooKeeper JMX enabled by default
Using config: /opt/software/zookeeper/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: leader

客户端连接

sh zkCli.sh -server 192.168.180.10:2181

 

posted on 2021-08-08 15:40  luckygxf  阅读(137)  评论(0编辑  收藏  举报

导航