Docker下使用Zookeeper操作

获取镜像:
[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}]}}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值