获取镜像:
[root@localhost ~]# docker pull zookeeper
查看镜像:
[root@localhost ~]# docker images
安装镜像,得到docker容器,zk为容器名
[root@localhost ~]# docker run --name zk -p 2181:2181 --restart always -d 454af3da184c
查看当前启动的镜像
[root@localhost ~]# docker ps
查看zookeeper日志:
[root@localhost ~]# docker logs zk
进入zookeeper容器:
[root@localhost ~]# docker exec -it zk bash
使用zkCli.sh开启客户端,连接Zookeeper:
root@26a5b3c9334e:/apache-zookeeper-3.6.1-bin# zkCli.sh
查看当前入驻的微服务
[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}]}}