如来神掌第三式第一招----ZOOKEEPER详解

###############################################################################
# Name : Mahavairocana                                                                                                                                           
# Author : Mahavairocana                                                                                                                                         
# QQ : 10353512                                                                                                                                                     
# WeChat : shenlan-qianlan                                                                                                                                       
# Blog : http://www.cnblogs.com/Mahavairocana/                                                                                                        
# Description : You are welcome to reprint, or hyperlinks to indicate the source of the article, as well as author information.
###############################################################################

1、zookeeper: 协同工作,运行在内存中;

一个大型服务常常是由一系列子服务共同组成的。这些服务常常包含一系列动态的配置,以告知子服务当前程序运行环境的变化。那么我们需要怎样完成配置的更新呢?这些配置的更改到底是由谁来发起?如果有多个发起方同时对同一配置进行更改,那么各个不同子服务接收到消息的先后顺序将有所不同,进而导致各个子服务内部的动态配置互不相同。这一系列问题我们应该如何解决?

  答案就是我们要讲解的ZooKeeper。ZooKeeper允许我们将数据组织成为一个类似于文件系统的数据结构。通过数据结点所在的地址,我们可以访问数据结点中所包含的数据:


角色:
    Leader:领导 一个集群只能有一个Leader,分发任务等,Leader挂掉,Folloert会重新进行选举;
    Follower:跟班,
    Client:访问所有主机,需要有客户端的类库,可以位于集群内也可以不在集群,zk集群在内存中的数据结构是相同的;
    所有主机之间都需要通信,以便知道哪个服务器上线、下线;

存放数据结构:
    类似于linux文件系统
    /zk1
        /node1
    /zk2
        /node2


访问过程
    1、客户端可以连接到每个server,每个server的数据完全相同。
    2、每个follower都和leader有连接,接受leader的数据更新操作。
    3、Server记录事务日志和快照到持久存储。
    4、大多数server可用,整体服务就可用。
    5、Leader节点在接收到数据变更请求后,首先将变更写入本地磁盘,以作恢复之用。当所有的写请求持久化到磁盘以后,才会将变更应用到内存中。
    6、ZooKeeper使用了一种自定义的原子消息协议,在消息层的这种原子特性,保证了整个协调系统中的节点数据或状态的一致性。Follower基于这种消息协议能够保证本地的ZooKeeper数据与Leader节点同步,然后基于本地的存储来独立地对外提供服务。
    7、当一个Leader节点发生故障失效时,失败故障是快速响应的,消息层负责重新选择一个Leader,继续作为协调服务集群的中心,处理客户端写请求,并将ZooKeeper协调系统的数据变更同步(广播)到其他的Follower节点。


安装

[root@localhost zookeeper]# wget http://archive.apache.org/dist/zookeeper/zookeeper-3.4.9/
[root@localhost zookeeper]# tar xf zookeeper-3.4.9.tar.gz
[root@localhost zookeeper]#  mkdir /usr/soft/
[root@localhost zookeeper]# mv zookeeper-3.4.9 /usr/soft/zookeeper
[root@localhost zookeeper]# cd /usr/soft/zookeeper/
[root@localhost zookeeper]# vim /etc/e
environment  ethers       event.d/     exports      
[root@localhost zookeeper]# cat /etc/environment
ZOOKEEPER_HOME=/usr/soft/zookeeper
JAVA_HOME=/usr/soft/java
HADOOP_INSTALL=/ust/soft/hadoop
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:
/root/bin:/usr/soft/zookeeper/bin"                                                                          
[root@localhost zookeeper]# source /etc/environment
[root@localhost zookeeper]# echo $ZOOKEEPER_HOME
/usr/soft/zookeeper
[root@localhost zookeeper]#

配置:
独立模式:所有都在一台主机 (进程少)
伪分布模式:不同端口号
完全分布模式:端口可以相同,


[root@localhost conf]# cat zoo.cfg  #三台主机均为相同配置
# The number of milliseconds of each tick
tickTime=2000     #心跳周期,服务器之间通信(2秒)
# 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/zookeeper   #存放数据目录
# the port at which the clients will connect
clientPort=2181           #Server 提供供客户端连接的端口
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60       #最大为60个链接,配置为0表示不限制
#
# 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.11=s1:2888:3888
server.12=s2:2888:3888
server.13=s3:2888:3888
# zk处理集群故障的算法是2n+1 最好在基数机器数部署
# 集群失效条件:小于等于半数服务器在线,表示服务器集群故障;

查看进程、端口

[root@master conf]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/soft/zookeeper/bin/../conf/zoo.cfg
Mode: leader
[root@master conf]# ps -ef | grep zo
root      2311     1  6 23:36 pts/0    00:00:01 java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/soft/zookeeper/bin/../build/classes:/usr/soft/zookeeper/bin/../build/lib/*.jar:/usr/soft/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/soft/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/soft/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/usr/soft/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/soft/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/soft/zookeeper/bin/../zookeeper-3.4.9.jar:/usr/soft/zookeeper/bin/../src/java/lib/*.jar:/usr/soft/zookeeper/bin/../conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/soft/zookeeper/bin/../conf/zoo.cfg
root      2376  2074  0 23:36 pts/0    00:00:00 grep zo
[root@master conf]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1366/sshd           
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1444/master         
tcp        0      0 :::22                       :::*                        LISTEN      1366/sshd           
tcp        0      0 ::1:25                      :::*                        LISTEN      1444/master         
tcp        0      0 :::45307                    :::*                        LISTEN      2311/java           
tcp        0      0 :::2181                     :::*                        LISTEN      2311/java           
tcp        0      0 ::ffff:10.0.1.1:2888        :::*                        LISTEN      2311/java           
tcp        0      0 ::ffff:10.0.1.1:3888        :::*                        LISTEN      2311/java           

查看角色;

[root@master conf]#  zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/soft/zookeeper/bin/../conf/zoo.cfg
Mode: leader

[root@slave01 conf]#  zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/soft/zookeeper/bin/../conf/zoo.cfg
Mode: follower

[root@slave02 ~]#  zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/soft/zookeeper/bin/../conf/zoo.cfg
Mode: follower

切换角色  (master回复后,不会重新进行选举,以当前运行为准;)

[root@master conf]# killall java
[root@master conf]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1366/sshd           
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1444/master         
tcp        0      0 :::22                       :::*                        LISTEN      1366/sshd           
tcp        0      0 ::1:25                      :::*                        LISTEN      1444/master         


[root@slave01 conf]#  zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/soft/zookeeper/bin/../conf/zoo.cfg
Mode: follower


[root@slave02 ~]#  zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/soft/zookeeper/bin/../conf/zoo.cfg
Mode: leader

查看配置

远程获得server的信息
$>echo conf | nc ip 2181 === nc ip 2181 --> conf
conf    //配置信息
cons    //连接信息
dump    //未处理会话节点
envi    //环境信息
reqs    //未处理请求
ruok    //are you ok? imok
stat        //统计信息
wchs    //服务器watch的详细信息
wchp    //列出指定路径下的服务器信息



[root@slave02 ~]# echo conf | nc slave02 2181
clientPort=2181
dataDir=/tmp/zookeeper/version-2
dataLogDir=/tmp/zookeeper/version-2
tickTime=2000
maxClientCnxns=60
minSessionTimeout=4000
maxSessionTimeout=40000
serverId=3
initLimit=10
syncLimit=5
electionAlg=3
electionPort=3888
quorumPort=2888
peerType=0

[root@slave02 ~]# echo envi | nc slave02 2181    Environment:
zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT
host.name=slave02
java.version=1.8.0_161
java.vendor=Oracle Corporation
java.home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9.x86_64/jre
java.class.path=/usr/soft/zookeeper/bin/../build/classes:/usr/soft/zookeeper/bin/../build/lib/*.jar:/usr/soft/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/soft/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/soft/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/usr/soft/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/soft/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/soft/zookeeper/bin/../zookeeper-3.4.9.jar:/usr/soft/zookeeper/bin/../src/java/lib/*.jar:/usr/soft/zookeeper/bin/../conf:
java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
java.io.tmpdir=/tmp
java.compiler=<NA>
os.name=Linux
os.arch=amd64
os.version=2.6.32-504.el6.x86_64
user.name=root
user.home=/root
user.dir=/root


[root@slave02 ~]# echo ruok | nc slave02 2181   ##查询是否ok
imok[root@slave02 ~]# 

客户端命令

客户端命令:

通过客户端脚本zkCli.sh连接到服务器
$>zkCli.sh -server s0:2181
//连接成功后如下信息
Welcome to ZooKeeper...
[...]help        //输出帮助信息

通过客户端脚本zkCli.sh连接到服务器
[...]ls /                //列出zk中包含的内容
[...]create /node1 helloworld    //创建/node1节点并指定
                                                   关联字符串
[...]get /node1            //查询节点数据
[...]set /node1 howareyou    //向节点写入数据
[...]delete /node1         //删除节点
[...]ls /                //列出根节点


通过客户端脚本zkCli.sh连接到服务器
[ZooKeeper Stat Structure]
czxid    The zxid of the change that caused this znode to be created.
mzxi                    The zxid of the change that last modified this znode.
ctime    The time in milliseconds from epoch when this znode was created.
mtime    The time in milliseconds from epoch when this znode was last modified.
version    The number of changes to the data of this znode.
cversion           The number of changes to the children of this znode.
aversion           The number of changes to the ACL of this znode.
ephemeralOwner The session id of the owner of this znode if the znode is an  
                             ephemeral node. If it is not an ephemeral node, it will be zero.
dataLength       The length of the data field of this znode.
numChildren     The number of children of this znode.


[root@slave02 ~]# zkCli.sh -server slave02:2181
[zk: slave02:2181(CONNECTED) 0] h
ZooKeeper -server host:port cmd args
        stat path [watch]
        set path data [version]
        ls path [watch]
        delquota [-n|-b] path
        ls2 path [watch]
        setAcl path acl
        setquota -n|-b val path
        history
        redo cmdno
        printwatches on|off
        delete path [version]
        sync path
        listquota path
        rmr path
        get path [watch]
        create [-s] [-e] path data acl
        addauth scheme auth
        quit
        getAcl path
        close
        connect host:port
[zk: slave02:2181(CONNECTED) 1] ls /
[zookeeper]
[zk: slave02:2181(CONNECTED) 4] ls /zookeeper
[quota]
[zk: slave02:2181(CONNECTED) 5] ls /zookeeper/quota
[]
[zk: slave02:2181(CONNECTED) 13] create /zookeeper test
Node already exists: /zookeeper
[zk: slave02:2181(CONNECTED) 14] create /zookeeper test1
Node already exists: /zookeeper
[zk: slave02:2181(CONNECTED) 15] create /root test      
Created /root

[zk: slave02:2181(CONNECTED) 20] get /root
test
cZxid = 0x400000006
ctime = Wed Jan 31 01:14:11 CST 2018
mZxid = 0x400000006
mtime = Wed Jan 31 01:14:11 CST 2018
pZxid = 0x400000006
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 4
numChildren = 0
[zk: slave02:2181(CONNECTED) 21] set /root test000
cZxid = 0x400000006
ctime = Wed Jan 31 01:14:11 CST 2018
mZxid = 0x400000007
mtime = Wed Jan 31 01:15:55 CST 2018
pZxid = 0x400000006
cversion = 0
dataVersion = 1  #数据每增加一次,版本增加一次;
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 7
numChildren = 0
[zk: slave02:2181(CONNECTED) 22]
[zk: slave02:2181(CONNECTED) 22] close
2018-01-31 01:20:37,452 [myid:] - INFO  [main:ZooKeeper@684] - Session: 0x36147c361070001 closed
[zk: slave02:2181(CLOSED) 23] 2018-01-31 01:20:37,455 [myid:] - INFO  [main-EventThread:ClientCnxn$EventThread@519] - EventThread shut down for session: 0x36147c361070001

踩坑

排错日志: zookeeper.out,经过查看,为master 主机host加错导致

[root@master conf]# cat zookeeper.out 
2018-01-30 23:33:01,792 [myid:] - INFO  [main:QuorumPeerConfig@124] - Reading configuration from: /usr/soft/zookeeper/bin/../conf/zoo.cfg
2018-01-30 23:33:01,867 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: master to address: master/127.0.0.1
2018-01-30 23:33:01,868 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: slave02 to address: slave02/10.0.3.1
2018-01-30 23:33:01,872 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: slave01 to address: slave01/10.0.2.1
2018-01-30 23:33:01,873 [myid:] - INFO  [main:QuorumPeerConfig@352] - Defaulting to majority quorums
2018-01-30 23:33:01,887 [myid:1] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2018-01-30 23:33:01,888 [myid:1] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2018-01-30 23:33:01,889 [myid:1] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2018-01-30 23:33:01,928 [myid:1] - INFO  [main:QuorumPeerMain@127] - Starting quorum peer
2018-01-30 23:33:01,960 [myid:1] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
2018-01-30 23:33:01,981 [myid:1] - INFO  [main:QuorumPeer@1019] - tickTime set to 2000
2018-01-30 23:33:01,982 [myid:1] - INFO  [main:QuorumPeer@1039] - minSessionTimeout set to -1
2018-01-30 23:33:01,983 [myid:1] - INFO  [main:QuorumPeer@1050] - maxSessionTimeout set to -1
2018-01-30 23:33:01,984 [myid:1] - INFO  [main:QuorumPeer@1065] - initLimit set to 10
2018-01-30 23:33:02,038 [myid:1] - INFO  [ListenerThread:QuorumCnxManager$Listener@534] - My election bind port: master/127.0.0.1:3888
2018-01-30 23:33:02,070 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer@774] - LOOKING
2018-01-30 23:33:02,083 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@818] - New election. My id =  1, proposed zxid=0x0
2018-01-30 23:33:02,085 [myid:1] - INFO  [WorkerReceiver[myid=1]:FastLeaderElection@600] - Notification: 1 (message format version), 1 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LOOKING (n.state), 1 (n.sid), 0x0 (n.peerEpoch) LOOKING (my state)
2018-01-30 23:33:02,097 [myid:1] - INFO  [WorkerSender[myid=1]:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (2, 1)
2018-01-30 23:33:02,098 [myid:1] - INFO  [WorkerSender[myid=1]:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (3, 1)
2018-01-30 23:33:02,299 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (2, 1)
2018-01-30 23:33:02,306 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (3, 1)
2018-01-30 23:33:02,306 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 400
2018-01-30 23:33:02,709 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (2, 1)
2018-01-30 23:33:02,711 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (3, 1)
2018-01-30 23:33:02,712 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 800
2018-01-30 23:33:03,513 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (2, 1)
2018-01-30 23:33:03,515 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (3, 1)
2018-01-30 23:33:03,517 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 1600
2018-01-30 23:33:05,120 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (2, 1)
2018-01-30 23:33:05,121 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (3, 1)
2018-01-30 23:33:05,122 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 3200
2018-01-30 23:33:08,331 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (2, 1)
2018-01-30 23:33:08,335 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (3, 1)
2018-01-30 23:33:08,336 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 6400
2018-01-30 23:33:09,348 [myid:1] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /127.0.0.1:45205
2018-01-30 23:33:09,361 [myid:1] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@827] - Processing srvr command from /127.0.0.1:45205
2018-01-30 23:33:09,375 [myid:1] - INFO  [Thread-1:NIOServerCnxn@1008] - Closed socket connection for client /127.0.0.1:45205 (no session established for client)
2018-01-30 23:33:14,738 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (2, 1)
2018-01-30 23:33:14,740 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (3, 1)
2018-01-30 23:33:14,740 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 12800
2018-01-30 23:33:27,542 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (2, 1)
2018-01-30 23:33:27,544 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (3, 1)
2018-01-30 23:33:27,544 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 25600
2018-01-30 23:33:53,146 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (2, 1)
2018-01-30 23:33:53,148 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (3, 1)
2018-01-30 23:33:53,150 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 51200
2018-01-30 23:34:44,352 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (2, 1)
2018-01-30 23:34:44,353 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@199] - Have smaller server identifier, so dropping the connection: (3, 1)
2018-01-30 23:34:44,354 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 60  0
2018-01-30 23:35:10,982 [myid:1] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /127.0.0.1:45214
2018-01-30 23:35:10,984 [myid:1] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@827] - Processing srvr command from /127.0.0.1:45214
2018-01-30 23:35:10,987 [myid:1] - INFO  [Thread-2:NIOServerCnxn@1008] - Closed socket connection for client /127.0.0.1:45214 (no session established for client)



myid: 文件位于datadir目录下,只存放n

原文地址:https://www.cnblogs.com/Mahavairocana/p/8385399.html