# 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:\Users\apache-zookeeper-3.6.2\data
# 暴露端口
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
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
1.4 点击bin目录下的zkServer.cmd,启动zookeeper
项目结构
2.1. user-api 用户服务接口
com.lbb.model.User 用户实体类
package com.lbb.model;import java.io.Serializable;publicclassUserimplementsSerializable{private Long id;private String name;private String address;public Long getId(){return id;}publicvoidsetId(Long id){this.id = id;}public String getName(){return name;}publicvoidsetName(String name){this.name = name;}public String getAddress(){return address;}publicvoidsetAddress(String address){this.address = address;}@Overridepublic String toString(){return"User{"+"id="+ id +", name='"+ name +'\''+", address='"+ address +'\''+'}';}}
com.lbb.service.IUserService 用户接口
package com.lbb.service;import com.lbb.model.User;publicinterfaceIUserService{
User getUserInfo();}
package com.lbb.service;import com.lbb.model.User;import org.apache.dubbo.config.annotation.Service;@ServicepublicclassUserServiceimplementsIUserService{@Overridepublic User getUserInfo(){
User user =newUser();
user.setId(1L);
user.setName("lbb");
user.setAddress("上海市青浦区华新镇");return user;}}
1. Zookeeper搭建1.1 下载 Zookeeper1.2 在zookeeper根目录下创建data文件夹1.3 在zookeeper的conf目录下创建zoo.config,修改里面的dataDir配置# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# Th