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

你可能感兴趣的:(J2EE学习,java-zookeeper,zookeeper,分布式)