在单机环境下和创建集群. 需要注意的点: 配置数据文件myid 1/2/3 对应server.1/2/3 通过./zkCli.sh -server [ip]:[port] 检测集群是否创建成功 在zoo.cfg配置文件下最下方写上 # The number of milliseconds of each tick tickTime= # The number of ticks that the initial # synchronization phase can take initLimit
public class CreateGroup implements Watcher { private static final int SESSION_TIMEOUT=5000; //ZooKeeper类是客户端API的主要类,用于维护客户端和ZooKeeper服务之间的连接 private ZooKeeper zk; //锁存器(latch)此计数器为1,表示在释放所有等待线程之前需要发生的事件数, private CountDownLatch connectedSignal= new