这几天在学习dobbo+zookeeper的搭建,中间费了不少心里,把过程和经验记录在这里了
首先是zookeeper的安装,zookeeper可以为分布式应用程序协调服务,可以前往zookeeper的官网进行下载https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/这个是清华大学的节点,我下载的是3.4.11版本。下载解压后,首先修改conf目录下的zoo_sample.cfg配置文件,我修改好的配置文件如下图:
# 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=C:\Work\JAVA_PACKAGE\zookeeper-3.4.11\\data
dataLogDir=C:\Work\JAVA_PACKAGE\zookeeper-3.4.11\\log
# 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
(其中dataDir和dataLogDir需要依据自己的目录修改。tickTime是每次心跳的间隔时间,单位是毫秒;dataDir是数据保存目录;dataLogDir是日志文件保存目录;clientPort是zookeeper的端口,zookeeper会监控这个端口,接受请求)
然后启动zookeeper,在zookeeper的安装路径下的bin目录中启动zkServer.cmd 这个脚本:
zkServer.cmd
我们可以启动下zookeeper的客户端来连接下:
zkCli.cmd 127.0.0.1:2181
如果出现下列的信息,就说明成功了