`
phipray
  • 浏览: 65767 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Docker zookeeper安装部署

 
阅读更多

一 下载zookeeper包

http://apache.osuosl.org/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz

 

二 制作zookeeper的Docker image

1 采用ubuntu16.04基础image,并对此image安装jdk1.8

 

2 把zookeeper-3.4.9.tar.gz加压后通过文件挂载的方式传入基础image中,配置$ZOOKEEPER_HOME,但把$ZOOKEEPER_HOME/zookeeper-3.4.9/conf,接着commit image,命名为zookeeper:1.0

 

3 基于zookeeper:1.0制作正规的zookeeper image zookeeper:2.0

Dockerfile:

FROM zookeeper:1.0

MAINTAINER dean

ENV JAVA_HOME /usr/local/java/

ENV ZOOKEEPER_HOME /opt/tools/zookeeper/zookeeper-3.4.9

ENV JRE_HOME $JAVA_HOME/jre

ENV CLASSPATH .:$JAVA_HOME/lib:$JRE_HOME/lib

ENV PATH $PATH:$JAVA_HOME/bin

 4 启动docker集群

docker run -d -i -t -p 2181:2181 -p 2887:2887 -p 3887:3887 -v /usr/local/zookeeper/zookeeperServer1:/opt/tools/zookeeper/zookeeper-3.4.9/conf   -v /usr/local/zookeeper/zookeeperServer1/data:/usr/local/zookeeperLog  zookeeper:2.0  /bin/bash

 

docker run -d -i -t -p 2182:2182 -p 2888:2888 -p 3888:3888 -v /usr/local/zookeeper/zookeeperServer2:/opt/tools/zookeeper/zookeeper-3.4.9/conf   -v /usr/local/zookeeper/zookeeperServer2/data:/usr/local/zookeeperLog/  zookeeper:2.0  /bin/bash

 

 

docker run -d -i -t -p 2183:2183 -p 2889:2889 -p 3889:3889 -v /usr/local/zookeeper/zookeeperServer3:/opt/tools/zookeeper/zookeeper-3.4.9/conf   -v /usr/local/zookeeper/zookeeperServer3/data:/usr/local/zookeeperLog  zookeeper:2.0  /bin/bash

 

值得注意的是zookeeper的配置文件

server1

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/usr/local/zookeeperLog/
dataLogDir=/usr/local/zookeeperLog/
# the port at which the clients will connect
clientPort=2181

server.1=0.0.0.0:2887:3887
server.2=10.108.68.140:2888:3888
server.3=10.108.68.140:2889:3889

 

server2

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/usr/local/zookeeperLog/
dataLogDir=/usr/local/zookeeperLog/
# the port at which the clients will connect
clientPort=2182

server.1=10.108.68.140:2887:3887
server.2=0.0.0.0:2888:3888
server.3=10.108.68.140:2889:3889

 

server3

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/usr/local/zookeeperLog/
dataLogDir=/usr/local/zookeeperLog/
# the port at which the clients will connect
clientPort=2183

server.1=10.108.68.140:2887:3887
server.2=10.108.68.140:2888:3888
server.3=0.0.0.0:2889:3889

 

最后通过zkCli.sh -server 10.108.68.140:2181检查一下集群的运行情况



 

 

 

 

 

  • 大小: 91.2 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics