Zookeeper 单节点安装与配置

1.Zookeeper单节点安装
第一步:安装jdk
第二步:把zookeeper的压缩包上传到linux系统。
第三步:解压缩压缩包:tar -zxvf zookeeper-3.4.6.tar.gz
第四步:进入zookeeper-3.4.6目录,创建data文件夹。
第五步:把zoo_sample.cfg改名为zoo.cfg
              [root@localhost conf]# mv zoo_sample.cfg  zoo.cfg
第六步:修改data属性:dataDir=/root/zookeeper-3.4.6/data
节点启动中常用命令:
    启动:        [root@localhost bin]# ./zkServer.sh start
    关闭:     [root@localhost bin]# ./zkServer.sh stop
    查看状态: [root@localhost bin]# ./zkServer.sh status
    查看进程是否启动:jps(有QuorumPeerMain说明启动成功)
    启动客户端:bin/zkCli.sh
    退出客户端:quit

2. Zookeeper单节点配置参数说明:
    配置文件存放在$ZOOKEEPER_HOME/conf/目录下,将zoo_sample.cfd文件名称改为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=/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.
#
#
# 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
配置说明:
    ① tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
    ② initLimit
     LF初始通信时限,集群中的follower跟随者服务器(F)与leader领导者服务器(L)之间初始连接时能容忍的最多心跳数(tickTime的数量),用它来限定集群中的Zookeeper服务器连接到Leader的时限。
     投票选举新leader的初始化时间, Follower在启动过程中,会从Leader同步所有最新数据,然后确定自己能够对外服务的起始状态, Leader允许F在initLimit时间内完成这个工作。
    ③ syncLimit
     syncLimit:LF同步通信时限,集群中Leader与Follower之间的最大响应时间单位,假如响应超过syncLimit*tickTime,Leader认为Follower死掉,从服务器列表中删除Follower。
     在运行过程中,Leader负责与ZK集群中所有机器进行通信,列如通过一些心跳检测机制,来检测机器的存货状态,如果Zookeeper默认端口:2181发生心跳包在syncLimit之后,还没有从F那收到响应,那么就认为这个F已经不在线了。
    ④ dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里(一般需要修改)。
    ⑤ clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。

猜你喜欢

转载自blog.csdn.net/luomingkui1109/article/details/80281500