• zookeeper 伪分布安装


    zookeeper是一个分布式应用程序协调系统,主要会提供配置服务,分布式服务,权限服务,锁定功能以及分布式数据同步,今天主要说明一下zookeeper如何搭建伪分布

    1. 下载zk程序,并解压,,略。

    2. zk需要一个数据存放目录,其实就是zk各个节点存放数据和日志的目录,日志也可以放到其他文件夹中

    3. 修改zk的配置,拷贝conf目录下的zoo_sample.cfg 为zoo1.cfg 名字可以任意

    4. 修改其配置:

    # 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=/home/data/zookeeper/data/s1
    # the port at which the clients will connect
    clientPort=2181
    server.1=qi:2888:3888
    server.2=qi:2889:3889
    server.3=qi:2890:3890
    # 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

    如上,在配置文件中有几个参数,下面说明一下其各自的意义

    1. tickTime : zk服务器和客户端会话心跳超时间间隔,单位为毫秒

    2. initLimit: 在zk follow 和leader之间进行数据同步最大超时次数,比如 initLimit = 5 ,tickTime = 2000,则允许最大延迟则为 5 * 2000 = 10000毫秒

    3. syncLimit: 在follow 和leader之间数据同步和消息发送时,请求和应答不能超过多少个tickTIme

    4. dataDir : zk内部存储数据的磁盘位置,默认情况下zk的日志文件也保存在这个目录中。zk运行期间会将数据存储在内存,保证访问速度

    5. server.x : zk的服务器列表,格式如下:server.x = hostname:port1:port2 ,x为从1 -N的数字,说明该节点zk集群中的编号,该编号在myid中配置,hostname为当前服务器主机名或IP,port1为follow和leader之间通讯端口,port2为leader失效后选举端口

    6. myid在各自的dataDir目录中,内容就是当前服务器的编号

    实验伪分布zk,则需要三份zoo.cfg,其中port1:port2 都需要不同,如上配置,另外dataDir和clientPort也要不同,否则就会有端口被占用的异常

    之后我们就可以启动了

    zkServer.sh start zoo.cfg
    zkServer start zoo2.cfg
    zkServer start zoo3.cfg

    执行以上命令会启动三个JVM示例,可以通过jps查看

    查看各个jvm的属性

    可以看看到我们的 zoo2.cfg是Leader其他连个为follow

  • 相关阅读:
    【MSSQL】备份
    cenos7创建删除软连接ln s
    mybatis plus 条件构造器queryWrapper学习
    使用socket实现即时通讯
    vue动态合并行和列
    解决:/deep/ 不能正常使用 Expected selector
    java字符串日期格式相互转换
    Git使用git通过ssh连接linux:ssh 用户名@IP地址
    vue+element跨行跨列合并
    Centos7配置node环境
  • 原文地址:https://www.cnblogs.com/yunfeiqi/p/8504164.html
Copyright © 2020-2023  润新知