美文网首页
Mac-ZooKeeper集群搭建&使用

Mac-ZooKeeper集群搭建&使用

作者: GIT提交不上 | 来源:发表于2021-06-15 18:08 被阅读0次

一、压缩包下载

  zookeeper-3.5.9国内镜像下载

图1.1 下载bin版本

二、本地配置

  参考链接-ZooKeeper在Mac上集群部署

  • 每个server配置的clientPort不同

  server1的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=/Users/luffy/Documents/zookeeper/server1/data
dataLogDir=/Users/luffy/Documents/zookeeper/server1/dataLog
# the port at which the clients will connect
clientPort=4051
# 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=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890

三、启用集群

  常用命令:

./zkServer.sh start - 启动
./zkServer.sh stop - 停止
./zkServer.sh restart - 重启
./zkServer.sh status - 查看状态
./zkServer.sh start-foreground - 查看日志

  分别启动三个server,查看状态,当选主成功时则整个集群启动成功。

图3-1 server1状态 图3-2 server2状态 图3-3 server3状态

四、命令使用

./zkCli.sh -server 127.0.0.1:4052

命令基本语法 功能描述
help 显示所用操作命令
ls path [watch] 使用 ls 命令查看当前 znode 中所包含的内容
ls2 path [watch] 查看当前节点数据并能看到更新次数等数据
create 普通创建(永久节点) -s(含有序列)-e临时(重启或者超时消失)
get path [watch] 获得节点的值
set 设置节点的具体值
stat 查看节点具体值
delete 删除节点
rmr 递归删除节点
stat path [watch] 设置watch事件
get path [watch] 设置watch事件

参考链接-常见命令使用1
参考链接-常见命令使用2-推荐

相关文章

网友评论

      本文标题:Mac-ZooKeeper集群搭建&使用

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