Docker下安装zookeeper

1,安装&启动步骤
#step1 获取镜像
$ docker pull zookeeper

#step2 查看镜像
$ docker images

#step3 启动镜像
$ docker run -d --name zookeeper -p 2181:2181  --restart always  -v /etc/localtime:/etc/localtime zookeeper

#step4 查看zookeeper日志
$ docker logs zookeeper
or
$ docker logs zookeeper容器id

#step5 进入zookeeper容器
$ docker exec -it zookeeper容器id /bin/bash

#step6 使用zkCli.sh开启客户端,连接Zookeeper
$ ./apache-zookeeper-3.6.1-bin/zkCli.sh
2,zookeeper一些操作

这一部分资料摘抄自 https://blog.csdn.net/TimEcho/article/details/106980914

[zk: localhost:2181(CONNECTED) 0] ls /
[services, zookeeper]
[zk: localhost:2181(CONNECTED) 1] ls /services     查看入驻的微服务
[cloud-provider-payment]
[zk: localhost:2181(CONNECTED) 2] ls /services/cloud-provider-payment   获取流水号
[00be11a8-7864-4cc5-bb33-3a5650179ea4]
[zk: localhost:2181(CONNECTED) 3] ls /services/cloud-provider-payment/00be11a8-7864-4cc5-bb33-3a5650179ea4
[]
通过流水号来查看微服务信息
[zk: localhost:2181(CONNECTED) 4] get /services/cloud-provider-payment/00be11a8-7864-4cc5-bb33-3a5650179ea4  
{
     "name":"cloud-provider-payment","id":"00be11a8-7864-4cc5-bb33-3a5650179ea4","address":"Shjango","port":8004,"sslPort":null,"payload":{
     "@class"
:"org.springframework.cloud.zookeeper.discovery.ZookeeperInstance","id":"application-1","name":"cloud-provider-payment","metadata":{
     }},"registr
ationTimeUTC":1593225474717,"serviceType":"DYNAMIC","uriSpec":{
     "parts":[{
     "value":"scheme","variable":true},{
     "value":"://","variable":false},{
     "v
alue":"address","variable":true},{
     "value":":","variable":false},{
     "value":"port","variable":true}]}}

你可能感兴趣的:(docker,zookeeper)