Zookeeper集群部署

各zookeeper集群配置java环境#

https://archive.apache.org/dist/zookeeper/ #官网下载地址
服务器环境:Ubuntu18.04
Zk-node1:10.0.1.101
Zk-node2:10.0.1.102
Zk-node3:10.0.1.103

  • zk节点1部署过程
    apt install openjdk-8-jdk
    java -version #验证jdk版本
cat install_zookeeper.sh
#!/bin/bash
#date 2021-1-25
install_zookeeper(){
   tar xvf zookeeper-3.4.13.tar.gz -C /usr/local/src
   cd /usr/local/src
   ln -sv /usr/local/src/zookeeper-3.4.13/ /usr/local/zookeeper
   cd /usr/local/zookeeper/conf
   cp zoo_sample.cfg zoo.cfg
   cd /usr/local/zookeeper/ && mkdir data
   echo "1" > /usr/local/zookeeper/data/myid
}
install_zookeeper
grep '^[^#]'  /usr/local/zookeeper/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/data
clientPort=2181
maxClientCnxns=128
autopurge.snapRetainCount=3
autopurge.purgeInterval=1
server.1=10.0.1.101:2888:3888
server.2=10.0.1.102:2888:3888
server.3=10.0.1.103:2888:3888

scp zoo.cfg 10.0.1.102:/usr/local/zookeeper/conf  #将配置文件分发到其他服务器
scp zoo.cfg 10.0.1.103:/usr/local/zookeeper/conf
  • zk节点2部署过程
    apt install openjdk-8-jdk
    java -version
cat install_zookeeper.sh
#!/bin/bash
#date 2021-1-25

install_zookeeper(){
   tar xvf zookeeper-3.4.13.tar.gz -C /usr/local/src
   cd /usr/local/src
   ln -sv /usr/local/src/zookeeper-3.4.13/ /usr/local/zookeeper
   cd /usr/local/zookeeper/conf
   cp zoo_sample.cfg zoo.cfg
   cd /usr/local/zookeeper/ && mkdir data
   echo "2" > /usr/local/zookeeper/data/myid
}
install_zookeeper
grep '^[^#]'  /usr/local/zookeeper/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/data
clientPort=2181
maxClientCnxns=4096
autopurge.snapRetainCount=128
autopurge.purgeInterval=1
server.1=10.0.1.101:2888:3888
server.2=10.0.1.102:2888:3888
server.3=10.0.1.103:2888:3888
  • zk节点3部署过程
apt install openjdk-8-jdk
java -version

 cat install_zookeeper.sh 
#!/bin/bash
#date 2021-1-25

install_zookeeper(){
   tar xvf zookeeper-3.4.13.tar.gz -C /usr/local/src
   cd /usr/local/src
   ln -sv /usr/local/src/zookeeper-3.4.13/ /usr/local/zookeeper
   cd /usr/local/zookeeper/conf
   cp zoo_sample.cfg zoo.cfg
   cd /usr/local/zookeeper/ && mkdir data
   echo "3" > /usr/local/zookeeper/data/myid
}
install_zookeeper 

grep '^[^#]'  /usr/local/zookeeper/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/data
clientPort=2181
maxClientCnxns=4096
autopurge.snapRetainCount=128
autopurge.purgeInterval=1
server.1=10.0.1.101:2888:3888
server.2=10.0.1.102:2888:3888
server.3=10.0.1.103:2888:3888
  • 各节点启动zookeeper
    /usr/local/zookeeper/bin/zkServer.sh start

/usr/local/zookeeper/bin/zkServer.sh status #验证集群节点状态


posted @ 2021-01-25 20:44  無心的Man  阅读(92)  评论(0编辑  收藏  举报