1、准备工作
docker pull zookeeper:3.6.3
Pwd="/data/software/zookeeper"
mkdir -p ${Pwd}/{logs,data,conf}
2、创建TEST容器,将conf目录COPY出来,在映射进去,方便后续维护管理!
docker run -itd --name zookeeper zookeeper:3.6.3
docker cp zookeeper:/conf ${Pwd}
docker rm -f zookeeper
3、运行容器
docker run -itd --name zookeeper \
-v ${Pwd}/data:/data \
-v ${Pwd}/logs:/datalog \
-v ${Pwd}/conf:/conf \
-v /etc/localtime:/etc/localtime \
-p 2181:2181 \
--restart=always \
zookeeper:3.6.3
4、测试链接zookeeper文章来源:https://www.toymoban.com/news/detail-731341.html
docker exec -it zookeeper zkCli.sh
正常输出内容:文章来源地址https://www.toymoban.com/news/detail-731341.html
Connecting to localhost:2181
2023-09-24 00:23:01,538 [myid:] - INFO [main:Environment@98] - Client environment:zookeeper.version=3.6.3--6401e4ad2087061bc6b9f80dec2d69f2e3c8660a, built on 04/08/2021 16:35 GMT
2023-09-24 00:23:01,546 [myid:] - INFO [main:Environment@98] - Client environment:host.name=a23908e4020e
2023-09-24 00:23:01,546 [myid:] - INFO [main:Environment@98] - Client environment:java.version=11.0.13
2023-09-24 00:23:01,550 [myid:] - INFO [main:Environment@98] - Client environment:java.vendor=Oracle Corporation
2023-09-24 00:23:01,550 [myid:] - INFO [main:Environment@98] - Client environment:java.home=/usr/local/openjdk-11
2023-09-24 00:23:01,550 [myid:] - INFO [main:Environment@98] - Client environment:java.class.path=/apache-zookeeper-3.6.3-bin/bin/../zookeeper-server/target/classes:/apache-zookeeper-3.6.3-bin/bin/../build/classes:/apache-zookeeper-3.6.3-bin/bin/../zookeeper-server/target/lib/*.jar:/apache-zookeeper-3.6.3-bin/bin/../build/lib/*.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/zookeeper-prometheus-metrics-3.6.3.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/zookeeper-jute-3.6.3.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/zookeeper-3.6.3.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/snappy-java-1.1.7.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/slf4j-log4j12-1.7.25.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/slf4j-api-1.7.25.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/simpleclient_servlet-0.6.0.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/simpleclient_hotspot-0.6.0.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/simpleclient_common-0.6.0.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/simpleclient-0.6.0.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/netty-transport-native-unix-common-4.1.63.Final.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/netty-transport-native-epoll-4.1.63.Final.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/netty-transport-4.1.63.Final.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/netty-resolver-4.1.63.Final.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/netty-handler-4.1.63.Final.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/netty-common-4.1.63.Final.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/netty-codec-4.1.63.Final.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/netty-buffer-4.1.63.Final.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/metrics-core-3.2.5.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/log4j-1.2.17.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/json-simple-1.1.1.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/jline-2.14.6.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/jetty-util-ajax-9.4.39.v20210325.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/jetty-util-9.4.39.v20210325.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/jetty-servlet-9.4.39.v20210325.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/jetty-server-9.4.39.v20210325.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/jetty-security-9.4.39.v20210325.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/jetty-io-9.4.39.v20210325.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/jetty-http-9.4.39.v20210325.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/jackson-databind-2.10.5.1.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/jackson-core-2.10.5.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/jackson-annotations-2.10.5.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/commons-cli-1.2.jar:/apache-zookeeper-3.6.3-bin/bin/../lib/audience-annotations-0.5.0.jar:/apache-zookeeper-3.6.3-bin/bin/../zookeeper-*.jar:/apache-zookeeper-3.6.3-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/conf:
2023-09-24 00:23:01,551 [myid:] - INFO [main:Environment@98] - Client environment:java.library.path=/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
2023-09-24 00:23:01,551 [myid:] - INFO [main:Environment@98] - Client environment:java.io.tmpdir=/tmp
2023-09-24 00:23:01,551 [myid:] - INFO [main:Environment@98] - Client environment:java.compiler=<NA>
2023-09-24 00:23:01,551 [myid:] - INFO [main:Environment@98] - Client environment:os.name=Linux
2023-09-24 00:23:01,551 [myid:] - INFO [main:Environment@98] - Client environment:os.arch=amd64
2023-09-24 00:23:01,551 [myid:] - INFO [main:Environment@98] - Client environment:os.version=3.10.0-1160.el7.x86_64
2023-09-24 00:23:01,551 [myid:] - INFO [main:Environment@98] - Client environment:user.name=root
2023-09-24 00:23:01,551 [myid:] - INFO [main:Environment@98] - Client environment:user.home=/root
2023-09-24 00:23:01,552 [myid:] - INFO [main:Environment@98] - Client environment:user.dir=/apache-zookeeper-3.6.3-bin
2023-09-24 00:23:01,552 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.free=116MB
2023-09-24 00:23:01,555 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.max=256MB
2023-09-24 00:23:01,556 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.total=124MB
2023-09-24 00:23:01,564 [myid:] - INFO [main:ZooKeeper@1006] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@735b478
2023-09-24 00:23:01,573 [myid:] - INFO [main:X509Util@77] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2023-09-24 00:23:01,589 [myid:] - INFO [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes
2023-09-24 00:23:01,605 [myid:] - INFO [main:ClientCnxn@1736] - zookeeper.request.timeout value is 0. feature enabled=false
Welcome to ZooKeeper!
2023-09-24 00:23:01,641 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1181] - Opening socket connection to server localhost/127.0.0.1:2181.
2023-09-24 00:23:01,642 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
2023-09-24 00:23:01,660 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1013] - Socket connection established, initiating session, client: /127.0.0.1:42962, server: localhost/127.0.0.1:2181
JLine support is enabled
2023-09-24 00:23:01,691 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1448] - Session establishment complete on server localhost/127.0.0.1:2181, session id = 0x100020e83f70001, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0]
到了这里,关于Docker部署ZooKeeper分布式协调服务的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!