一 :安装 
1.获取zookeeper镜像

docker pull zookeeper
 
 
  • 1
  • 1

2.写配置文件zoo.cfg

tickTime=2000
dataDir=/opt/zookeeper/data
clientPort=2181
initLimit=5
syncLimit=2
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

3.启动容器

docker run --name zookeeper --net host -v /showcase/zookeeper/zoo.cfg:/opt/zookeeper/conf/zoo.cfg --restart=always -d zookeeper:latest

 
 
  • 1
  • 2
  • 1
  • 2

二 :集群搭建 
1.写配置文件zoo.cfg

#nod1
tickTime=2000
dataDir=/opt/zookeeper/data
clientPort=2181
initLimit=5
syncLimit=2
server.1=*.*.*.*:2888:3888
server.2=*.*.*.*:2888:3888
server.3=*.*.*.*:2888:3888
myid=1

#nod2
tickTime=2000
dataDir=/opt/zookeeper/data
clientPort=2181
initLimit=5
syncLimit=2
server.1=*.*.*.*:2888:3888
server.2=*.*.*.*:2888:3888
server.3=*.*.*.*:2888:3888
myid=2

#nod3
tickTime=2000
dataDir=/opt/zookeeper/data
clientPort=2181
initLimit=5
syncLimit=2
server.1=*.*.*.*:2888:3888
server.2=*.*.*.*:2888:3888
server.3=*.*.*.*:2888:3888
myid=3
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32

2.分别启动容器

docker run --name zookeeper --net host -v /showcase/zookeeper/zoo.cfg:/opt/zookeeper/conf/zoo.cfg --restart=always -d zookeeper:latest
docker run --name zookeeper --net host -v /showcase/zookeeper/zoo.cfg:/opt/zookeeper/conf/zoo.cfg --restart=always -d zookeeper:latest
docker run --name zookeeper --net host -v /showcase/zookeeper/zoo.cfg:/opt/zookeeper/conf/zoo.cfg --restart=always -d zookeeper:latest
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐