zookeeper部署

Posted 浪子尘晨

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zookeeper部署相关的知识,希望对你有一定的参考价值。

硬件准备

vmware虚拟三台主机node01、node02、node03

zookeeper软件版本

zookeeper-3.4.10,下载地址:zookeeper下载

jdk安装略

zookeeper部署依赖jdk,jdk安装步骤见jdk8安装

单机部署

解压安装

tar -zxvf /opt/software/zookeeper-3.4.10.tar.gz -C /opt/module/zookeeper/standalone/
mkdir /opt/module/zookeeper/standalone/zookeeper-3.4.10/zkdata
cp  /opt/module/zookeeper/standalone/zookeeper-3.4.10/conf/zoo_sample.cfg  /opt/module/zookeeper/standalone/zookeeper-3.4.10/conf/zoo.cfg


修改配置

vim /opt/module/zookeeper/standalone/zookeeper-3.4.10/conf/zoo.cfg
# dataDir=/tmp/zookeeper
dataDir=/opt/module/zookeeper/standalone/zookeeper-3.4.10/zkdata


启动server

/opt/module/zookeeper/standalone/zookeeper-3.4.10/bin/zkServer.sh start
jps

/opt/module/zookeeper/standalone/zookeeper-3.4.10/bin/zkServer.sh status


启动client

/opt/module/zookeeper/standalone/zookeeper-3.4.10/bin/zkCli.sh


关闭client

quit


关闭server

/opt/module/zookeeper/standalone/zookeeper-3.4.10/bin/zkServer.sh stop


分布式部署

cp -r /opt/module/zookeeper/standalone/zookeeper-3.4.10 /opt/module/zookeeper/replicated/

scp -r /opt/module/zookeeper/standalone/zookeeper-3.4.10 root@node02:/opt/module/zookeeper/replicated/
scp -r /opt/module/zookeeper/standalone/zookeeper-3.4.10 root@node03:/opt/module/zookeeper/replicated/
vim /opt/module/zookeeper/replicated/zookeeper-3.4.10/zkdata/myid
1
2
3


修改配置文件

vim /opt/module/zookeeper/replicated/zookeeper-3.4.10/conf/zoo.cfg
# dataDir=/opt/module/zookeeper/standalone/zookeeper-3.4.10/zkdata
dataDir=/opt/module/zookeeper/replicated/zookeeper-3.4.10/zkdata

server.1=node01:2888:3888
server.2=node02:2888:3888
server.3=node03:2888:3888


同步到其他主机

# rsync -avzP --update /opt/module/zookeeper/replicated/zookeeper-3.4.10/ root@node02:/opt/module/zookeeper/replicated/
# rsync -avunzP /opt/module/zookeeper/replicated/zookeeper-3.4.10/ root@node03:/opt/module/zookeeper/replicated/


启动server

/opt/module/zookeeper/replicated/zookeeper-3.4.10/bin/zkServer.sh start
/opt/module/zookeeper/replicated/zookeeper-3.4.10/bin/zkServer.sh start
/opt/module/zookeeper/replicated/zookeeper-3.4.10/bin/zkServer.sh start


关闭server
 

/opt/module/zookeeper/replicated/zookeeper-3.4.10/bin/zkServer.sh stop
/opt/module/zookeeper/replicated/zookeeper-3.4.10/bin/zkServer.sh stop
/opt/module/zookeeper/replicated/zookeeper-3.4.10/bin/zkServer.sh stop

以上是关于zookeeper部署的主要内容,如果未能解决你的问题,请参考以下文章

zookeeper概述和部署

zookeeper高可用集群部署

Zookeeper安装部署

zookeeper集群+kafka集群 部署

ZooKeeper 集群部署

zookeeper群集部署及概述