zookeeper集群安装

环境准备

安装配置

  • 解压zookeeper安装包,tar -zxvf zookeeper-3.4.12.tar.gz ,解压后目录

  • 添加zookeeper配置,进入conf目录,使用cp zoo_sample.cfg zoo.cfg 复制zoo_sample.cfgzoo.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=/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
    server.1=192.168.146.151:2188:3181
    server.2=192.168.146.152:2188:3181
    server.3=192.168.146.153:2188:3181

    主要配置说明

    clientPort运行端口号

    dataDir数据存储位置

    myid设置

    当安装zookeeper集群环境时要在dataDir目录下创建当前zookeeper的myid

    如我在192.168.146.151机器上创建在/tmp/zookeeper/myid文件,文件内容为1,依次类推

    添加server集群配置

    server.1=192.168.146.151:2188:3181-->server.myid=ip:clientPort:prot,有几台机器添加几条配置 ,注意两个端口号不可以重复(如果重复会出现端口号重复的问题),如上配置。

  • 启动运行,进入每台机器zookeeper目录中的bin文件夹,运行zkServer.sh脚本,如 sh zkServer.sh start ,运行时可在启动目录下查看zookeeper.out 控制台日志。

  • 启动好了可通过运行bin目录下的zkCli.sh脚本连接zookeeper,如

    也可通过sh zkServer.sh status 查看当前zookeeper是什么角色

注:zookeeper 集群角色分为leader、follower、observer,这里我配置的只有leader和follower,要台添加一台observer机器,在server配置后面标记为observer如:server.4=192.168.146.154:2188:3181:observer

我的博客地址

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值