欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ZooKeeper学习

程序员文章站 2022-06-06 19:45:18
...

ZooKeeper是基于ZAB协议(原子消息广播协议)

目前用的版本3.5.5  下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/

以自己机器为例:

下载好后,解压放在/tools/zookeeper  去掉了3.5.5版本号。

然后在zookeeper下创建data、datalog,在data下创建myid文件,myid文件中放内容1数字就行


ZooKeeper学习
            
    
    博客分类: 架构  
 

 把conf下的sample_zoo.cfg 改为zoo.cfg

ZooKeeper学习
            
    
    博客分类: 架构  
以上是三台机器分别跑三个zookeeper,需要启动三个。便于测试只有一台机器以下跑一台zookeeper,需注掉

另外两个

server.1=127.0.0.1:2888:3888

#server.2=127.0.0.1:2888:3888

 

#server.3=127.0.0.1:2888:3888

 

启动zookeeper,进入到zookeeper的bin目录:


ZooKeeper学习
            
    
    博客分类: 架构  
 

 

可查看启动时报错:./zkServer.sh start-foreground

找不到启动主类,如下图:


ZooKeeper学习
            
    
    博客分类: 架构  
 

ZooKeeper学习
            
    
    博客分类: 架构  

ZooKeeper学习
            
    
    博客分类: 架构  

ZooKeeper学习
            
    
    博客分类: 架构  
ZooKeeper学习
            
    
    博客分类: 架构  
 把zookeeper-3.5.5.jar添加到zookeeper目录下,然后再启动



ZooKeeper学习
            
    
    博客分类: 架构  
 

客户端脚本连接:

 

dw:bin cs$ ./zkCli.sh -server 127.0.0.1:2180

以下表示连接成功:

WatchedEvent state:SyncConnected type:None path:null


ZooKeeper学习
            
    
    博客分类: 架构  
 

ZooKeeper学习
            
    
    博客分类: 架构  
 
ZooKeeper学习
            
    
    博客分类: 架构  
 
ZooKeeper学习
            
    
    博客分类: 架构  

ZooKeeper学习
            
    
    博客分类: 架构  

ZooKeeper学习
            
    
    博客分类: 架构  

  • ZooKeeper学习
            
    
    博客分类: 架构  
  • 大小: 89.5 KB
  • ZooKeeper学习
            
    
    博客分类: 架构  
  • 大小: 12.3 KB
  • ZooKeeper学习
            
    
    博客分类: 架构  
  • 大小: 24.7 KB
  • ZooKeeper学习
            
    
    博客分类: 架构  
  • 大小: 15.4 KB
  • ZooKeeper学习
            
    
    博客分类: 架构  
  • 大小: 15.7 KB
  • ZooKeeper学习
            
    
    博客分类: 架构  
  • 大小: 35.6 KB
  • ZooKeeper学习
            
    
    博客分类: 架构  
  • 大小: 81.5 KB