Dockerfile制作zookeeper镜像
作者:互联网
一 工作目录
root@k8s-harbor-01:/data/dockerfile/web/zookeeper# pwd
/data/dockerfile/web/zookeeper
二 准备配置文件
root@k8s-harbor-01:/data/dockerfile/web/zookeeper# cat conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/zookeeper/data
dataLogDir=/data/zookeeper/datalog
autopurge.purgeInterval=1
autopurge.snapRetainCount=3
maxClientCnxns=60
standaloneEnabled=true
admin.enableServer=true
clientPort=2181
quorumListenOnAllIPs=true
三 准备entrypoint.sh
root@k8s-harbor-01:/data/dockerfile/web/zookeeper# cat entrypoint.sh
#!/bin/bash
if [[ ! -f "$ZOO_DATA_DIR/myid" ]]; then
echo "${ZOO_MY_ID:-1}" > "$ZOO_DATA_DIR/myid"
fi
if [[ -z $ZOO_SERVERS ]]; then
ZOO_SERVERS="server.1=localhost:2888:3888;2181"
fi
for server in $ZOO_SERVERS; do
echo "$server" >> "$ZOO_CONF_DIR/zoo.cfg"
done
cd /usr/local/zookeeper
exec "$@"
四 编写Dockerfile
root@k8s-harbor-01:/data/dockerfile/web/zookeeper# cat Dockerfile
FROM 192.168.174.120/baseimages/jdk-base:1.8.0_311
ENV PATH=/usr/local/zookeeper/bin:${PATH} \
ZOO_CONF_DIR=/usr/local/zookeeper/conf \
ZOO_DATA_DIR=/data/zookeeper/data \
ZOO_DATA_LOG_DIR=/data/zookeeper/datalog \
ZOO_LOG_DIR=/data/zookeeper/logs
ADD apache-zookeeper-3.7.0-bin.tar.gz /usr/local/
RUN set -eux; \
ln -sv /usr/local/apache-zookeeper-3.7.0-bin/ /usr/local/zookeeper; \
mkdir -p "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_LOG_DIR"; \
apk add --no-cache bash
COPY conf /usr/local/zookeeper/conf/
COPY bin/zkReady.sh /usr/local/zookeeper/bin/
COPY entrypoint.sh /usr/local/zookeeper/bin/
EXPOSE 2181 2888 3888 8080
ENTRYPOINT ["entrypoint.sh"]
CMD ["zkServer.sh", "start-foreground"]
五 编写构建镜像脚本
root@k8s-harbor-01:/data/dockerfile/web/zookeeper# cat build-command.sh
#!/bin/bash
docker build -t 192.168.174.120/baseimages/zookeeker:3.7.0 .
#docker push 192.168.174.120/baseimages/zookeeker:3.7.0 .
六 构建镜像
点击查看代码
root@k8s-harbor-01:/data/dockerfile/web/zookeeper# ./build-command.sh
Sending build context to Docker daemon 50.05MB
Step 1/10 : FROM 192.168.174.120/baseimages/jdk-base:1.8.0_311
---> f7f2cc224b22
Step 2/10 : ENV PATH=/usr/local/zookeeper/bin:${PATH} ZOO_CONF_DIR=/usr/local/zookeeper/conf ZOO_DATA_DIR=/data/zookeeper/data ZOO_DATA_LOG_DIR=/data/zookeeper/datalog ZOO_LOG_DIR=/data/zookeeper/logs
---> Using cache
---> d0703fc56314
Step 3/10 : ADD apache-zookeeper-3.7.0-bin.tar.gz /usr/local/
---> Using cache
---> 28d8a26105dd
Step 4/10 : RUN set -eux; ln -sv /usr/local/apache-zookeeper-3.7.0-bin/ /usr/local/zookeeper; mkdir -p "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_LOG_DIR"; apk add --no-cache bash
---> Running in a4822a449df3
'/usr/local/zookeeper' -> '/usr/local/apache-zookeeper-3.7.0-bin/'
+ ln -sv /usr/local/apache-zookeeper-3.7.0-bin/ /usr/local/zookeeper
+ mkdir -p /data/zookeeper/datalog /data/zookeeper/data /data/zookeeper/logs
+ apk add --no-cache bash
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
(1/4) Installing ncurses-terminfo-base (6.3_p20211120-r0)
(2/4) Installing ncurses-libs (6.3_p20211120-r0)
(3/4) Installing readline (8.1.1-r0)
(4/4) Installing bash (5.1.8-r0)
Executing bash-5.1.8-r0.post-install
Executing busybox-1.34.1-r3.trigger
OK: 12 MiB in 19 packages
Removing intermediate container a4822a449df3
---> ccfab02c0dde
Step 5/10 : COPY conf /usr/local/zookeeper/conf/
---> 8f6a4ac831b8
Step 6/10 : COPY bin/zkReady.sh /usr/local/zookeeper/bin/
---> f0979344a965
Step 7/10 : COPY entrypoint.sh /usr/local/zookeeper/bin/
---> 55579e60d30f
Step 8/10 : EXPOSE 2181 2888 3888 8080
---> Running in 96e76754f8dd
Removing intermediate container 96e76754f8dd
---> 1dc017c4b855
Step 9/10 : ENTRYPOINT ["entrypoint.sh"]
---> Running in 27ae90638efa
Removing intermediate container 27ae90638efa
---> 0b58e0a0cf4c
Step 10/10 : CMD ["zkServer.sh", "start-foreground"]
---> Running in c8ec5718c2fb
Removing intermediate container c8ec5718c2fb
---> e6a3ff51c206
Successfully built e6a3ff51c206
Successfully tagged 192.168.174.120/baseimages/zookeeker:3.7.0
七 测试镜像
7.1 启动镜像
root@k8s-harbor-01:/data/dockerfile/web/zookeeper# docker run -d --name zookeeper-01 -p 2181:2181 192.168.174.120/baseimages/zookeeker:3.7.0
bdfda9a0c4248a4c3e4038194fcdbd890725d024a39dfac1d5c5b5459b1186b7
7.2 查看日志
点击查看代码
root@k8s-harbor-01:/data/dockerfile/web/zookeeper# docker logs -f bdfd
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
2021-12-03 08:58:55,439 [myid:] - INFO [main:QuorumPeerConfig@174] - Reading configuration from: /usr/local/zookeeper/bin/../conf/zoo.cfg
2021-12-03 08:58:55,449 [myid:] - INFO [main:QuorumPeerConfig@444] - clientPortAddress is 0.0.0.0:2181
2021-12-03 08:58:55,449 [myid:] - INFO [main:QuorumPeerConfig@448] - secureClientPort is not set
2021-12-03 08:58:55,449 [myid:] - INFO [main:QuorumPeerConfig@464] - observerMasterPort is not set
2021-12-03 08:58:55,450 [myid:] - INFO [main:QuorumPeerConfig@481] - metricsProvider.className is org.apache.zookeeper.metrics.impl.DefaultMetricsProvider
2021-12-03 08:58:55,454 [myid:1] - INFO [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2021-12-03 08:58:55,454 [myid:1] - INFO [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 1
2021-12-03 08:58:55,455 [myid:1] - WARN [main:QuorumPeerMain@139] - Either no config or no quorum defined in config, running in standalone mode
2021-12-03 08:58:55,457 [myid:1] - INFO [main:ManagedUtil@44] - Log4j 1.2 jmx support found and enabled.
2021-12-03 08:58:55,464 [myid:1] - INFO [PurgeTask:DatadirCleanupManager$PurgeTask@139] - Purge task started.
2021-12-03 08:58:55,475 [myid:1] - INFO [main:QuorumPeerConfig@174] - Reading configuration from: /usr/local/zookeeper/bin/../conf/zoo.cfg
2021-12-03 08:58:55,477 [myid:1] - INFO [main:QuorumPeerConfig@444] - clientPortAddress is 0.0.0.0:2181
2021-12-03 08:58:55,477 [myid:1] - INFO [main:QuorumPeerConfig@448] - secureClientPort is not set
2021-12-03 08:58:55,478 [myid:1] - INFO [main:QuorumPeerConfig@464] - observerMasterPort is not set
2021-12-03 08:58:55,478 [myid:1] - INFO [main:QuorumPeerConfig@481] - metricsProvider.className is org.apache.zookeeper.metrics.impl.DefaultMetricsProvider
2021-12-03 08:58:55,477 [myid:1] - INFO [PurgeTask:FileTxnSnapLog@124] - zookeeper.snapshot.trust.empty : false
2021-12-03 08:58:55,484 [myid:1] - INFO [main:ZooKeeperServerMain@123] - Starting server
2021-12-03 08:58:55,491 [myid:1] - INFO [PurgeTask:DatadirCleanupManager$PurgeTask@145] - Purge task completed.
2021-12-03 08:58:55,500 [myid:1] - INFO [main:ServerMetrics@62] - ServerMetrics initialized with provider org.apache.zookeeper.metrics.impl.DefaultMetricsProvider@2d209079
2021-12-03 08:58:55,502 [myid:1] - INFO [main:DigestAuthenticationProvider@47] - ACL digest algorithm is: SHA1
2021-12-03 08:58:55,502 [myid:1] - INFO [main:DigestAuthenticationProvider@61] - zookeeper.DigestAuthenticationProvider.enabled = true
2021-12-03 08:58:55,503 [myid:1] - INFO [main:FileTxnSnapLog@124] - zookeeper.snapshot.trust.empty : false
2021-12-03 08:58:55,515 [myid:1] - INFO [main:ZookeeperBanner@42] -
2021-12-03 08:58:55,521 [myid:1] - INFO [main:ZookeeperBanner@42] - ______ _
2021-12-03 08:58:55,521 [myid:1] - INFO [main:ZookeeperBanner@42] - |___ / | |
2021-12-03 08:58:55,521 [myid:1] - INFO [main:ZookeeperBanner@42] - / / ___ ___ | | __ ___ ___ _ __ ___ _ __
2021-12-03 08:58:55,521 [myid:1] - INFO [main:ZookeeperBanner@42] - / / / _ \ / _ \ | |/ / / _ \ / _ \ | '_ \ / _ \ | '__|
2021-12-03 08:58:55,522 [myid:1] - INFO [main:ZookeeperBanner@42] - / /__ | (_) | | (_) | | < | __/ | __/ | |_) | | __/ | |
2021-12-03 08:58:55,522 [myid:1] - INFO [main:ZookeeperBanner@42] - /_____| \___/ \___/ |_|\_\ \___| \___| | .__/ \___| |_|
2021-12-03 08:58:55,522 [myid:1] - INFO [main:ZookeeperBanner@42] - | |
2021-12-03 08:58:55,522 [myid:1] - INFO [main:ZookeeperBanner@42] - |_|
2021-12-03 08:58:55,522 [myid:1] - INFO [main:ZookeeperBanner@42] -
2021-12-03 08:58:55,524 [myid:1] - INFO [main:Environment@98] - Server environment:zookeeper.version=3.7.0-e3704b390a6697bfdf4b0bef79e3da7a4f6bac4b, built on 2021-03-17 09:46 UTC
2021-12-03 08:58:55,524 [myid:1] - INFO [main:Environment@98] - Server environment:host.name=bdfda9a0c424
2021-12-03 08:58:55,526 [myid:1] - INFO [main:Environment@98] - Server environment:java.version=1.8.0_311
2021-12-03 08:58:55,526 [myid:1] - INFO [main:Environment@98] - Server environment:java.vendor=Oracle Corporation
2021-12-03 08:58:55,526 [myid:1] - INFO [main:Environment@98] - Server environment:java.home=/usr/local/jdk1.8.0_311/jre
2021-12-03 08:58:55,527 [myid:1] - INFO [main:Environment@98] - Server environment:java.class.path=/usr/local/zookeeper/bin/../zookeeper-server/target/classes:/usr/local/zookeeper/bin/../build/classes:/usr/local/zookeeper/bin/../zookeeper-server/target/lib/*.jar:/usr/local/zookeeper/bin/../build/lib/*.jar:/usr/local/zookeeper/bin/../lib/zookeeper-prometheus-metrics-3.7.0.jar:/usr/local/zookeeper/bin/../lib/zookeeper-jute-3.7.0.jar:/usr/local/zookeeper/bin/../lib/zookeeper-3.7.0.jar:/usr/local/zookeeper/bin/../lib/snappy-java-1.1.7.7.jar:/usr/local/zookeeper/bin/../lib/slf4j-log4j12-1.7.30.jar:/usr/local/zookeeper/bin/../lib/slf4j-api-1.7.30.jar:/usr/local/zookeeper/bin/../lib/simpleclient_servlet-0.9.0.jar:/usr/local/zookeeper/bin/../lib/simpleclient_hotspot-0.9.0.jar:/usr/local/zookeeper/bin/../lib/simpleclient_common-0.9.0.jar:/usr/local/zookeeper/bin/../lib/simpleclient-0.9.0.jar:/usr/local/zookeeper/bin/../lib/netty-transport-native-unix-common-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-transport-native-epoll-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-transport-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-resolver-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-handler-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-common-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-codec-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-buffer-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/metrics-core-4.1.12.1.jar:/usr/local/zookeeper/bin/../lib/log4j-1.2.17.jar:/usr/local/zookeeper/bin/../lib/jline-2.14.6.jar:/usr/local/zookeeper/bin/../lib/jetty-util-ajax-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-util-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-servlet-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-server-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-security-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-io-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-http-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/javax.servlet-api-3.1.0.jar:/usr/local/zookeeper/bin/../lib/jackson-databind-2.10.5.1.jar:/usr/local/zookeeper/bin/../lib/jackson-core-2.10.5.jar:/usr/local/zookeeper/bin/../lib/jackson-annotations-2.10.5.jar:/usr/local/zookeeper/bin/../lib/commons-cli-1.4.jar:/usr/local/zookeeper/bin/../lib/audience-annotations-0.12.0.jar:/usr/local/zookeeper/bin/../zookeeper-*.jar:/usr/local/zookeeper/bin/../zookeeper-server/src/main/resources/lib/*.jar:/usr/local/zookeeper/bin/../conf:/usr/local/jdk/lib/:/usr/local/jdk/jre/lib/
2021-12-03 08:58:55,527 [myid:1] - INFO [main:Environment@98] - Server environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2021-12-03 08:58:55,528 [myid:1] - INFO [main:Environment@98] - Server environment:java.io.tmpdir=/tmp
2021-12-03 08:58:55,528 [myid:1] - INFO [main:Environment@98] - Server environment:java.compiler=<NA>
2021-12-03 08:58:55,528 [myid:1] - INFO [main:Environment@98] - Server environment:os.name=Linux
2021-12-03 08:58:55,528 [myid:1] - INFO [main:Environment@98] - Server environment:os.arch=amd64
2021-12-03 08:58:55,528 [myid:1] - INFO [main:Environment@98] - Server environment:os.version=5.4.0-91-generic
2021-12-03 08:58:55,528 [myid:1] - INFO [main:Environment@98] - Server environment:user.name=root
2021-12-03 08:58:55,528 [myid:1] - INFO [main:Environment@98] - Server environment:user.home=/root
2021-12-03 08:58:55,529 [myid:1] - INFO [main:Environment@98] - Server environment:user.dir=/usr/local/apache-zookeeper-3.7.0-bin
2021-12-03 08:58:55,529 [myid:1] - INFO [main:Environment@98] - Server environment:os.memory.free=25MB
2021-12-03 08:58:55,529 [myid:1] - INFO [main:Environment@98] - Server environment:os.memory.max=889MB
2021-12-03 08:58:55,529 [myid:1] - INFO [main:Environment@98] - Server environment:os.memory.total=31MB
2021-12-03 08:58:55,529 [myid:1] - INFO [main:ZooKeeperServer@138] - zookeeper.enableEagerACLCheck = false
2021-12-03 08:58:55,530 [myid:1] - INFO [main:ZooKeeperServer@151] - zookeeper.digest.enabled = true
2021-12-03 08:58:55,530 [myid:1] - INFO [main:ZooKeeperServer@155] - zookeeper.closeSessionTxn.enabled = true
2021-12-03 08:58:55,530 [myid:1] - INFO [main:ZooKeeperServer@1499] - zookeeper.flushDelay=0
2021-12-03 08:58:55,530 [myid:1] - INFO [main:ZooKeeperServer@1508] - zookeeper.maxWriteQueuePollTime=0
2021-12-03 08:58:55,530 [myid:1] - INFO [main:ZooKeeperServer@1517] - zookeeper.maxBatchSize=1000
2021-12-03 08:58:55,531 [myid:1] - INFO [main:ZooKeeperServer@260] - zookeeper.intBufferStartingSizeBytes = 1024
2021-12-03 08:58:55,532 [myid:1] - INFO [main:BlueThrottle@141] - Weighed connection throttling is disabled
2021-12-03 08:58:55,533 [myid:1] - INFO [main:ZooKeeperServer@1300] - minSessionTimeout set to 4000
2021-12-03 08:58:55,534 [myid:1] - INFO [main:ZooKeeperServer@1309] - maxSessionTimeout set to 40000
2021-12-03 08:58:55,536 [myid:1] - INFO [main:ResponseCache@45] - getData response cache size is initialized with value 400.
2021-12-03 08:58:55,536 [myid:1] - INFO [main:ResponseCache@45] - getChildren response cache size is initialized with value 400.
2021-12-03 08:58:55,538 [myid:1] - INFO [main:RequestPathMetricsCollector@109] - zookeeper.pathStats.slotCapacity = 60
2021-12-03 08:58:55,538 [myid:1] - INFO [main:RequestPathMetricsCollector@110] - zookeeper.pathStats.slotDuration = 15
2021-12-03 08:58:55,538 [myid:1] - INFO [main:RequestPathMetricsCollector@111] - zookeeper.pathStats.maxDepth = 6
2021-12-03 08:58:55,538 [myid:1] - INFO [main:RequestPathMetricsCollector@112] - zookeeper.pathStats.initialDelay = 5
2021-12-03 08:58:55,538 [myid:1] - INFO [main:RequestPathMetricsCollector@113] - zookeeper.pathStats.delay = 5
2021-12-03 08:58:55,539 [myid:1] - INFO [main:RequestPathMetricsCollector@114] - zookeeper.pathStats.enabled = false
2021-12-03 08:58:55,541 [myid:1] - INFO [main:ZooKeeperServer@1536] - The max bytes for all large requests are set to 104857600
2021-12-03 08:58:55,541 [myid:1] - INFO [main:ZooKeeperServer@1550] - The large request threshold is set to -1
2021-12-03 08:58:55,542 [myid:1] - INFO [main:AuthenticationHelper@66] - zookeeper.enforce.auth.enabled = false
2021-12-03 08:58:55,543 [myid:1] - INFO [main:AuthenticationHelper@67] - zookeeper.enforce.auth.schemes = []
2021-12-03 08:58:55,543 [myid:1] - INFO [main:ZooKeeperServer@361] - Created server with tickTime 2000 minSessionTimeout 4000 maxSessionTimeout 40000 clientPortListenBacklog -1 datadir /data/zookeeper/datalog/version-2 snapdir /data/zookeeper/data/version-2
2021-12-03 08:58:55,585 [myid:1] - INFO [main:Log@169] - Logging initialized @619ms to org.eclipse.jetty.util.log.Slf4jLog
2021-12-03 08:58:55,706 [myid:1] - WARN [main:ContextHandler@1660] - o.e.j.s.ServletContextHandler@6895a785{/,null,STOPPED} contextPath ends with /*
2021-12-03 08:58:55,706 [myid:1] - WARN [main:ContextHandler@1671] - Empty contextPath
2021-12-03 08:58:55,728 [myid:1] - INFO [main:Server@375] - jetty-9.4.38.v20210224; built: 2021-02-24T20:25:07.675Z; git: 288f3cc74549e8a913bf363250b0744f2695b8e6; jvm 1.8.0_311-b11
2021-12-03 08:58:55,749 [myid:1] - INFO [main:DefaultSessionIdManager@334] - DefaultSessionIdManager workerName=node0
2021-12-03 08:58:55,750 [myid:1] - INFO [main:DefaultSessionIdManager@339] - No SessionScavenger set, using defaults
2021-12-03 08:58:55,751 [myid:1] - INFO [main:HouseKeeper@132] - node0 Scavenging every 660000ms
2021-12-03 08:58:55,757 [myid:1] - WARN [main:ConstraintSecurityHandler@759] - ServletContext@o.e.j.s.ServletContextHandler@6895a785{/,null,STARTING} has uncovered http methods for path: /*
2021-12-03 08:58:55,764 [myid:1] - INFO [main:ContextHandler@916] - Started o.e.j.s.ServletContextHandler@6895a785{/,null,AVAILABLE}
2021-12-03 08:58:55,774 [myid:1] - INFO [main:AbstractConnector@331] - Started ServerConnector@617faa95{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2021-12-03 08:58:55,777 [myid:1] - INFO [main:Server@415] - Started @809ms
2021-12-03 08:58:55,777 [myid:1] - INFO [main:JettyAdminServer@181] - Started AdminServer on address 0.0.0.0, port 8080 and command URL /commands
2021-12-03 08:58:55,780 [myid:1] - INFO [main:ServerCnxnFactory@169] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2021-12-03 08:58:55,781 [myid:1] - WARN [main:ServerCnxnFactory@309] - maxCnxns is not configured, using default value 0.
2021-12-03 08:58:55,782 [myid:1] - INFO [main:NIOServerCnxnFactory@652] - Configuring NIO connection handler with 10s sessionless connection timeout, 1 selector thread(s), 4 worker threads, and 64 kB direct buffers.
2021-12-03 08:58:55,783 [myid:1] - INFO [main:NIOServerCnxnFactory@660] - binding to port 0.0.0.0/0.0.0.0:2181
2021-12-03 08:58:55,794 [myid:1] - INFO [main:WatchManagerFactory@42] - Using org.apache.zookeeper.server.watch.WatchManager as watch manager
2021-12-03 08:58:55,794 [myid:1] - INFO [main:WatchManagerFactory@42] - Using org.apache.zookeeper.server.watch.WatchManager as watch manager
2021-12-03 08:58:55,795 [myid:1] - INFO [main:ZKDatabase@133] - zookeeper.snapshotSizeFactor = 0.33
2021-12-03 08:58:55,795 [myid:1] - INFO [main:ZKDatabase@153] - zookeeper.commitLogCount=500
2021-12-03 08:58:55,798 [myid:1] - INFO [main:SnapStream@61] - zookeeper.snapshot.compression.method = CHECKED
2021-12-03 08:58:55,798 [myid:1] - INFO [main:FileTxnSnapLog@479] - Snapshotting: 0x0 to /data/zookeeper/data/version-2/snapshot.0
2021-12-03 08:58:55,800 [myid:1] - INFO [main:ZKDatabase@290] - Snapshot loaded in 6 ms, highest zxid is 0x0, digest is 1371985504
2021-12-03 08:58:55,801 [myid:1] - INFO [main:FileTxnSnapLog@479] - Snapshotting: 0x0 to /data/zookeeper/data/version-2/snapshot.0
2021-12-03 08:58:55,802 [myid:1] - INFO [main:ZooKeeperServer@543] - Snapshot taken in 0 ms
2021-12-03 08:58:55,812 [myid:1] - INFO [main:RequestThrottler@75] - zookeeper.request_throttler.shutdownTimeout = 10000
2021-12-03 08:58:55,812 [myid:1] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@137] - PrepRequestProcessor (sid:0) started, reconfigEnabled=false
2021-12-03 08:58:55,822 [myid:1] - INFO [main:ContainerManager@84] - Using checkIntervalMs=60000 maxPerMinute=10000 maxNeverUsedIntervalMs=0
2021-12-03 08:58:55,822 [myid:1] - INFO [main:ZKAuditProvider@42] - ZooKeeper audit is disabled.
八 客户端测试
点击查看代码
root@zk-01:~# /usr/local/zookeeper/bin/zkCli.sh -server 192.168.174.120:2181
Connecting to 192.168.174.120:2181
2021-12-03 09:09:09,109 [myid:] - INFO [main:Environment@98] - Client environment:zookeeper.version=3.7.0-e3704b390a6697bfdf4b0bef79e3da7a4f6bac4b, built on 2021-03-17 09:46 UTC
2021-12-03 09:09:09,126 [myid:] - INFO [main:Environment@98] - Client environment:host.name=192.168.174.103
2021-12-03 09:09:09,126 [myid:] - INFO [main:Environment@98] - Client environment:java.version=17.0.1
2021-12-03 09:09:09,146 [myid:] - INFO [main:Environment@98] - Client environment:java.vendor=Oracle Corporation
2021-12-03 09:09:09,146 [myid:] - INFO [main:Environment@98] - Client environment:java.home=/usr/local/jdk-17.0.1
2021-12-03 09:09:09,147 [myid:] - INFO [main:Environment@98] - Client environment:java.class.path=/usr/local/zookeeper/bin/../zookeeper-server/target/classes:/usr/local/zookeeper/bin/../build/classes:/usr/local/zookeeper/bin/../zookeeper-server/target/lib/*.jar:/usr/local/zookeeper/bin/../build/lib/*.jar:/usr/local/zookeeper/bin/../lib/zookeeper-prometheus-metrics-3.7.0.jar:/usr/local/zookeeper/bin/../lib/zookeeper-jute-3.7.0.jar:/usr/local/zookeeper/bin/../lib/zookeeper-3.7.0.jar:/usr/local/zookeeper/bin/../lib/snappy-java-1.1.7.7.jar:/usr/local/zookeeper/bin/../lib/slf4j-log4j12-1.7.30.jar:/usr/local/zookeeper/bin/../lib/slf4j-api-1.7.30.jar:/usr/local/zookeeper/bin/../lib/simpleclient_servlet-0.9.0.jar:/usr/local/zookeeper/bin/../lib/simpleclient_hotspot-0.9.0.jar:/usr/local/zookeeper/bin/../lib/simpleclient_common-0.9.0.jar:/usr/local/zookeeper/bin/../lib/simpleclient-0.9.0.jar:/usr/local/zookeeper/bin/../lib/netty-transport-native-unix-common-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-transport-native-epoll-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-transport-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-resolver-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-handler-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-common-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-codec-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/netty-buffer-4.1.59.Final.jar:/usr/local/zookeeper/bin/../lib/metrics-core-4.1.12.1.jar:/usr/local/zookeeper/bin/../lib/log4j-1.2.17.jar:/usr/local/zookeeper/bin/../lib/jline-2.14.6.jar:/usr/local/zookeeper/bin/../lib/jetty-util-ajax-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-util-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-servlet-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-server-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-security-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-io-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/jetty-http-9.4.38.v20210224.jar:/usr/local/zookeeper/bin/../lib/javax.servlet-api-3.1.0.jar:/usr/local/zookeeper/bin/../lib/jackson-databind-2.10.5.1.jar:/usr/local/zookeeper/bin/../lib/jackson-core-2.10.5.jar:/usr/local/zookeeper/bin/../lib/jackson-annotations-2.10.5.jar:/usr/local/zookeeper/bin/../lib/commons-cli-1.4.jar:/usr/local/zookeeper/bin/../lib/audience-annotations-0.12.0.jar:/usr/local/zookeeper/bin/../zookeeper-*.jar:/usr/local/zookeeper/bin/../zookeeper-server/src/main/resources/lib/*.jar:/usr/local/zookeeper/bin/../conf:.:/usr/local/jdk/lib:/usr/local/jdk/jre/lib:/usr/local/jdk/lib/tools.jar
2021-12-03 09:09:09,147 [myid:] - INFO [main:Environment@98] - Client environment:java.library.path=/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
2021-12-03 09:09:09,147 [myid:] - INFO [main:Environment@98] - Client environment:java.io.tmpdir=/tmp
2021-12-03 09:09:09,148 [myid:] - INFO [main:Environment@98] - Client environment:java.compiler=<NA>
2021-12-03 09:09:09,148 [myid:] - INFO [main:Environment@98] - Client environment:os.name=Linux
2021-12-03 09:09:09,148 [myid:] - INFO [main:Environment@98] - Client environment:os.arch=amd64
2021-12-03 09:09:09,148 [myid:] - INFO [main:Environment@98] - Client environment:os.version=5.4.0-91-generic
2021-12-03 09:09:09,148 [myid:] - INFO [main:Environment@98] - Client environment:user.name=root
2021-12-03 09:09:09,148 [myid:] - INFO [main:Environment@98] - Client environment:user.home=/root
2021-12-03 09:09:09,148 [myid:] - INFO [main:Environment@98] - Client environment:user.dir=/root
2021-12-03 09:09:09,149 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.free=27MB
2021-12-03 09:09:09,150 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.max=256MB
2021-12-03 09:09:09,150 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.total=34MB
2021-12-03 09:09:09,155 [myid:] - INFO [main:ZooKeeper@637] - Initiating client connection, connectString=192.168.174.120:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@17f6480
2021-12-03 09:09:09,163 [myid:] - INFO [main:X509Util@77] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2021-12-03 09:09:09,206 [myid:] - INFO [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes
2021-12-03 09:09:09,276 [myid:] - INFO [main:ClientCnxn@1726] - zookeeper.request.timeout value is 0. feature enabled=false
Welcome to ZooKeeper!
2021-12-03 09:09:09,322 [myid:192.168.174.120:2181] - INFO [main-SendThread(192.168.174.120:2181):ClientCnxn$SendThread@1171] - Opening socket connection to server 192.168.174.120/192.168.174.120:2181.
2021-12-03 09:09:09,322 [myid:192.168.174.120:2181] - INFO [main-SendThread(192.168.174.120:2181):ClientCnxn$SendThread@1173] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2021-12-03 09:09:09,428 [myid:192.168.174.120:2181] - INFO [main-SendThread(192.168.174.120:2181):ClientCnxn$SendThread@1005] - Socket connection established, initiating session, client: /192.168.174.103:58094, server: 192.168.174.120/192.168.174.120:2181
2021-12-03 09:09:09,458 [myid:192.168.174.120:2181] - INFO [main-SendThread(192.168.174.120:2181):ClientCnxn$SendThread@1438] - Session establishment complete on server 192.168.174.120/192.168.174.120:2181, session id = 0x100017f69a60000, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: 192.168.174.120:2181(CONNECTED) 0]
九 上传镜像到harbor
root@k8s-harbor-01:/data/dockerfile/web/zookeeper# docker push 192.168.174.120/baseimages/zookeeker:3.7.0
十 docker-compose示例
version: '3.1'
services:
zoo1:
image: zookeeper
restart: always
hostname: zoo1
ports:
- 2181:2181
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
zoo2:
image: zookeeper
restart: always
hostname: zoo2
ports:
- 2182:2181
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
zoo3:
image: zookeeper
restart: always
hostname: zoo3
ports:
- 2183:2181
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
标签:03,12,zookeeper,2021,myid,镜像,main,Dockerfile 来源: https://www.cnblogs.com/wangguishe/p/15639052.html