Zookeeper实战记录(2)-参数解读

目录

Zookeeper实战记录-目录:https://blog.csdn.net/weixin_39565597/article/details/104401912

1、配置参数

官方配置文件详解:http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_zkMulitServerSetup
zk配置文件/opt/soft/zookeeper-3.6.5/conf/zoo.cfg各属性:

# The number of milliseconds of each tick
# 通信心跳数,Zookeeper服务器与客户端心跳时间,单位毫秒
# Zookeeper使用的基本时间,服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每隔tickTime时间就会发送一个心跳,时间单位为毫秒。它用于心跳机制,并且设置最小的session超时时间为两倍心跳时间。(session的最小超时时间是2*tickTime)
tickTime=2000

# The number of ticks that the initial 
# synchronization phase can take
# Lead节点和Follower初始通信时限(超时initLimit*tickTime=10*2000=20秒)当初始化连接时间超过20秒,则表示连接失败
initLimit=10

# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
# Leader节点和Follower节点同步通信时限(超时syncLimit*tickTime=5*2000=10秒)当主从连接时间超过10秒,则表示连接失败,主节点任务从节点挂掉,从服务器列表中移除该节点
# 通常初始化时initLimit大一些,初始化成功后,之后的通信时间syncLimit会小一些。
syncLimit=5

# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
# 主要用于保存Zookeeper中的数据。不能使用/tmp目录存储
dataDir=/opt/soft/zookeeper-3.6.5/zkData

# 用于保存zookeeper中产生的日志,如果不配置,日志信息会存于dataDir中
# dataLogDir=/opt/soft/zookeeper-3.6.5/zkLogs

# the port at which the clients will connect
# Zookeeper服务器与客户端通信端口,监听客户端连接的端口。
clientPort=2181

# the maximum number of client connections.
# increase this if you need to handle more clients
# zookeeper服务器允许客户端的最大连接数,不设置则默认不限制
#maxClientCnxns=60

# The number of snapshots to retain in dataDir
# dataDir数据中,需要保留的文件数目。默认是保留3个快照。
#autopurge.snapRetainCount=3

# Purge task interval in hours
# Set to "0" to disable auto purge feature
# 3.4.0及之后版本,ZK提供了自动清理事务日志和快照文件的功能,这个参数指定了清理频率,单位是小时,需要配置一个1或更大的整数,不配置默认是0,表示不开启自动清理功能
#autopurge.purgeInterval=1

# 集群配置信息,有多少台则配多少条
# A与dataDir/myid中的值一致,B:node1服务器名称,C:主从之间通信端口2888,D:选举leader时用的端口3888
#server.A=B:C:D

2、启动参数

分析启动命令,提示./zkServer.sh [–config ] {start|start-foreground|stop|restart|status|print-cmd}

[root@node1 zookeeper-3.5.6]# bin/zkServer.sh
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper/apache-zookeeper-3.5.6-bin/bin/../conf/zoo.cfg
Usage: ./zkServer.sh [--config <conf-dir>] {start|start-foreground|stop|restart|status|print-cmd}
# 指定配置文件,默认会寻找conf/zoo.cfg文件,自定义位置可以指定--config
[root@node1 zookeeper-3.5.6]# bin/zkServer.sh --config conf/zoo.cfg

# 启动zookeeper
# 启动时,会创建一个存储进程的zookeeper.server.pid文件在dataDir目录下,如果启动后再执行此命令,会先检测是否有该pid文件以此来检测zk状态,若已经启动则不再执行。
[root@node1 zookeeper-3.5.6]# bin/zkServer.sh start

# 前台启动zookeeper
# start启动时会检测是否有zookeeper.server.pid文件,而此启动方式不会检测该文件
[root@node1 zookeeper-3.5.6]# bin/zkServer.sh start-foreground

# 停止zookeeper进程
# stop也会检测zookeeper.server.pid文件判断zk状态,判断是否需要stop,如果stop,则会执行两条命令
# 1、kill pid杀掉进程
# 2、rm zookeeper.server.pid 删除pid进程文件(说明zk未启动时是没有该文件的)
[root@node1 zookeeper-3.5.6]# bin/zkServer.sh stop

# 重启zookeeper
# 1、执行stop;2、睡眠3秒;3、执行start
[root@node1 zookeeper-3.5.6]# bin/zkServer.sh restart

# 查看zookeeper状态
[root@node1 zookeeper-3.5.6]# bin/zkServer.sh status

# 打印启动命令
# 直接复制打印出的启动命令,可以直接启动zookeeper,但是该命令不是后台启动。
[root@node1 zookeeper-3.5.6]# bin/zkServer.sh print-cmd

# 对于除以上的其它命令则输出帮助信息
# echo "Usage: $0 [--config <conf-dir>] {start|start-foreground|stop|restart|status|print-cmd}" >&2
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值