[Docker系列·11]搭建ZooKeeper伺服器

六翁發表於2017-01-04

搭建ZooKeeper伺服器

1 Docker-Ubuntu-Zookeeper

工作目錄:/home/erichan/docker-room/ubuntu-zookeeper

1.1 製作映象

erichan@ubuntu14_04_1-pd:~/docker-room/ubuntu-zookeeper$ nano Dockerfile
# Version: 0.0.1
FROM feuyeux/ubuntu-java7
MAINTAINER Eric Han "feuyeux@gmail.com"
RUN apt-get update && apt-get install -y wget
RUN wget http://apache.fayea.com/apache-mirror/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
RUN tar -xzf zookeeper-3.4.6.tar.gz -C /opt
RUN cp /opt/zookeeper-3.4.6/conf/zoo_sample.cfg /opt/zookeeper-3.4.6/conf/zoo.cfg
RUN mkdir -p /tmp/zookeeper
ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
EXPOSE 2181 2888 3888
WORKDIR /opt/zookeeper-3.4.6
VOLUME ["/opt/zookeeper-3.4.6/conf", "/tmp/zookeeper"]
ENTRYPOINT ["/opt/zookeeper-3.4.6/bin/zkServer.sh"]
CMD ["start-foreground"]

1.2 建立映象

erichan@ubuntu14_04_1-pd:~/docker-room/ubuntu-zookeeper$ d build -t feuyeux/zookeeper:3.4.6 .

1.3 測試映象

erichan@ubuntu14_04_1-pd:~/docker-room$ d run --name zk346 -d feuyeux/zookeeper:3.4.6
eab5250575338e52ef6232020deec5b8ef175caf63f1547fdc02413c4a29a5f8
erichan@ubuntu14_04_1-pd:~/docker-room$ d ps
CONTAINER ID        IMAGE                     COMMAND                CREATED             STATUS              PORTS                                  NAMES
eab525057533        feuyeux/zookeeper:3.4.6   "/opt/zookeeper-3.4.   5 seconds ago       Up 4 seconds        3888/tcp, 2181/tcp, 22/tcp, 2888/tcp   zk346    
erichan@ubuntu14_04_1-pd:~/docker-room$ d logs zk346
JMX enabled by default
Using config: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
2014-08-24 11:52:30,063 [myid:] - INFO  [main:QuorumPeerConfig@103] - Reading configuration from: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
2014-08-24 11:52:30,067 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2014-08-24 11:52:30,067 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2014-08-24 11:52:30,067 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2014-08-24 11:52:30,067 [myid:] - WARN  [main:QuorumPeerMain@113] - Either no config or no quorum defined in config, running  in standalone mode
2014-08-24 11:52:30,082 [myid:] - INFO  [main:QuorumPeerConfig@103] - Reading configuration from: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
2014-08-24 11:52:30,083 [myid:] - INFO  [main:ZooKeeperServerMain@95] - Starting server
2014-08-24 11:52:30,088 [myid:] - INFO  [main:Environment@100] - Server environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2014-08-24 11:52:30,088 [myid:] - INFO  [main:Environment@100] - Server environment:host.name=eab525057533
2014-08-24 11:52:30,089 [myid:] - INFO  [main:Environment@100] - Server environment:java.version=1.7.0_55
2014-08-24 11:52:30,089 [myid:] - INFO  [main:Environment@100] - Server environment:java.vendor=Oracle Corporation
2014-08-24 11:52:30,089 [myid:] - INFO  [main:Environment@100] - Server environment:java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre
2014-08-24 11:52:30,089 [myid:] - INFO  [main:Environment@100] - Server environment:java.class.path=/opt/zookeeper-3.4.6/bin/../build/classes:/opt/zookeeper-3.4.6/bin/../build/lib/*.jar:/opt/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/opt/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/opt/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/opt/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/opt/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/opt/zookeeper-3.4.6/bin/../conf:
2014-08-24 11:52:30,089 [myid:] - INFO  [main:Environment@100] - Server environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
2014-08-24 11:52:30,089 [myid:] - INFO  [main:Environment@100] - Server environment:java.io.tmpdir=/tmp
2014-08-24 11:52:30,089 [myid:] - INFO  [main:Environment@100] - Server environment:java.compiler=<NA>
2014-08-24 11:52:30,091 [myid:] - INFO  [main:Environment@100] - Server environment:os.name=Linux
2014-08-24 11:52:30,091 [myid:] - INFO  [main:Environment@100] - Server environment:os.arch=amd64
2014-08-24 11:52:30,091 [myid:] - INFO  [main:Environment@100] - Server environment:os.version=3.13.0-34-generic
2014-08-24 11:52:30,091 [myid:] - INFO  [main:Environment@100] - Server environment:user.name=root
2014-08-24 11:52:30,091 [myid:] - INFO  [main:Environment@100] - Server environment:user.home=/root
2014-08-24 11:52:30,092 [myid:] - INFO  [main:Environment@100] - Server environment:user.dir=/opt/zookeeper-3.4.6
2014-08-24 11:52:30,096 [myid:] - INFO  [main:ZooKeeperServer@755] - tickTime set to 2000
2014-08-24 11:52:30,096 [myid:] - INFO  [main:ZooKeeperServer@764] - minSessionTimeout set to -1
2014-08-24 11:52:30,096 [myid:] - INFO  [main:ZooKeeperServer@773] - maxSessionTimeout set to -1
2014-08-24 11:52:30,114 [myid:] - INFO  [main:NIOServerCnxnFactory@94] - binding to port 0.0.0.0/0.0.0.0:2181
erichan@ubuntu14_04_1-pd:~/docker-room$ 

參考: https://github.com/jplock/docker-zookeeper

2 ZK Cluster

使用不同Docker網路模型搭建Zookeeper叢集 作者: 微垣


相關文章