美文网首页
云服务器搭建六:linux安装Zookeeper

云服务器搭建六:linux安装Zookeeper

作者: 蜻蜓队长家长 | 来源:发表于2019-07-25 11:55 被阅读0次

    linux安装Zookeeper

    ZooKeeper是一种集中式服务,用于维护配置信息,命名,提供分布式同步和提供组服务。所有这些类型的服务都以分布式应用程序的某种形式使用。每次实施它们都需要做很多工作来修复不可避免的错误和竞争条件。由于难以实现这些类型的服务,应用程序最初通常会吝啬它们,这使得它们在变化的情况下变得脆弱并且难以管理。即使正确完成,这些服务的不同实现也会在部署应用程序时导致管理复杂性。

    • 下载
      选择zookeeper版本,手动下载上传至服务器或者yum下载http://mirror.bit.edu.cn/apache/zookeeper
      注意3.5.5要下载bin源码包,否则需要配置maven环境 执行maven clean install
    wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.5.5/apache-zookeeper-3.5.5-bin.tar.gz
    
    
    • 解压
    tar -zxvf apache-zookeeper-3.5.5-bin.tar.gz
    
    • 拷贝zoo_samle.cfg为zoo.cfg
    #进入到conf目录
    cd apache-zookeeper-3.5.5-bin/conf
    #拷贝zoo_samle.cfg为zoo.cfg
    cp zoo_sample.cfg zoo.cfg
    
    • 编辑zoo.cfg文件
    vim /usr/local/apache-zookeeper-3.5.5-bin/conf/zoo.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=/usr/local/apache-zookeeper-3.5.5-bin/tmp/zookeeper
    # 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
    
    • 设置环境变量
    export ZOOKEEPER_HOME=/usr/local/apache-zookeeper-3.5.5-bin
    export PATH=$ZOOKEEPER_HOME/bin:$PATH
    

    或者编辑 vim ~/.bashrc 文本,写入以上变量,然后使用 source ~/.bashrc 生效

    • 启动
    /usr/local/apache-zookeeper-3.5.5-bin/bin/zkServer.sh start
    
    • 查看状态
    /usr/local/apache-zookeeper-3.5.5-bin/bin/zkServer.sh status
    
    • 停止
    /usr/local/apache-zookeeper-3.5.5-bin/bin/zkServer.sh stop
    
    • 注意
      1.出现 Client port found: 2181. Client address: localhost.

      解决方案
      1、不能和Tomcat部署在同一台机器上,因为zookeeper和tomcat同样默认使用的都是8080端口;
      2、修改端口,如果必须部署到一台服务器上,则选择修改tomcat的端口号,将tomcat的8080释放出来;

    2.出现Starting zookeeper ... FAILED TO START


    因为apache-zookeeper-3.5.5.tar.gz为源码包,未进行编译打包
    解决方案
    1.配置maven环境 执行maven clean install进行打包
    2.直接下载apache-zookeeper-3.5.5-bin.tar.gz使用

    相关文章

      网友评论

          本文标题:云服务器搭建六:linux安装Zookeeper

          本文链接:https://www.haomeiwen.com/subject/epxalctx.html