Dubbo实战_06_环境搭建_ZooKeeper注册中心

目录

一、Apache Dubbo支持的几个注册中心

二、进入 ZooKeeper 官网,下载zk

三、解压并配置zk

 四、使用zkCli.cmd测试 

1、启动ZK

2、连接ZK


一、Apache Dubbo支持的几个注册中心

打开官网:http://dubbo.apache.org/

点击文档 (https://dubbo.apache.org/zh/docs/

如下,可看到支持5个注册中心,官方推荐使用 Zookeeper 注册中心

二、进入 ZooKeeper 官网,下载zk

进入 ZooKeeper 官网

https://zookeeper.apache.org/

点击 in the archive.   

下载需要的版本(一般最新的,属于公测版,我们不要下载)

三、解压并配置zk

下载并解压

解压zookeeper

解压运行 zkServer.cmd ,初次运行会报错,没有zoo.cfg配置文件

修改zoo.cfg配置文件

将 conf 下的 zoo_sample.cfg 复制一份改名为 zoo.cfg 即可。

注意几个重要位置:

dataDir=./   临时数据存储的目录(可写相对路径)

clientPort=2181   zookeeper的端口号

修改完成后再次启动zookeeper

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=../data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

 四、使用zkCli.cmd测试 

ls /:列出zookeeper根下保存的所有节点

create –e /atXXX 123:创建一个atXXX节点,值为123

get /atXXX:获取/atXXX节点的值

1、启动ZK

打开cmd命令界面,命令行启动zk

D:\soft_install_dir\zookeeper-3.4.11\bin>zkServer.cmd

2、连接ZK

再打开一个cmd命令界面,输入如下命令,进行zk连接:

D:\soft_install_dir\zookeeper-3.4.11\bin>zkCli.cmd

Connecting to localhost:2181

[zk: localhost:2181(CONNECTED) 0] get /

cZxid = 0x0

ctime = Thu Jan 01 08:00:00 CST 1970

mZxid = 0x0

mtime = Thu Jan 01 08:00:00 CST 1970

pZxid = 0x2

cversion = 0

dataVersion = 0

aclVersion = 0

ephemeralOwner = 0x0

dataLength = 0

numChildren = 2

[zk: localhost:2181(CONNECTED) 1] ls /

[dubbo, zookeeper]

[zk: localhost:2181(CONNECTED) 2] get /dubbo

192.168.1.101

[zk: localhost:2181(CONNECTED) 3] create -e /yyh 123456

Created /yyh

[zk: localhost:2181(CONNECTED) 4] ls /

[dubbo, yyh, zookeeper]

[zk: localhost:2181(CONNECTED) 5] get /yyh

123456

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

被开发耽误的大厨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值