首先我确定防火墙关了,myid里面正确,端口没有被占用。附错误信息
2018-01-22 23:54:51,572 [myid:] - INFO  [main:QuorumPeerConfig@103] - Reading configuration from: /usr/local/zookeeper/zookeeper01/bin/../conf/zoo.cfg
2018-01-22 23:54:51,576 [myid:] - INFO  [main:QuorumPeerConfig@340] - Defaulting to majority quorums
2018-01-22 23:54:51,579 [myid:1] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2018-01-22 23:54:51,579 [myid:1] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2018-01-22 23:54:51,580 [myid:1] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2018-01-22 23:54:51,591 [myid:1] - INFO  [main:QuorumPeerMain@127] - Starting quorum peer
2018-01-22 23:54:51,600 [myid:1] - INFO  [main:NIOServerCnxnFactory@94] - binding to port 0.0.0.0/0.0.0.0:2181
2018-01-22 23:54:51,615 [myid:1] - INFO  [main:QuorumPeer@959] - tickTime set to 2000
2018-01-22 23:54:51,615 [myid:1] - INFO  [main:QuorumPeer@979] - minSessionTimeout set to -1
2018-01-22 23:54:51,615 [myid:1] - INFO  [main:QuorumPeer@990] - maxSessionTimeout set to -1
2018-01-22 23:54:51,615 [myid:1] - INFO  [main:QuorumPeer@1005] - initLimit set to 10
2018-01-22 23:54:51,630 [myid:1] - INFO  [Thread-1:QuorumCnxManager$Listener@504] - My election bind port: slave-01/172.17.0.4:3881
2018-01-22 23:54:51,631 [myid:1] - ERROR [slave-01/172.17.0.4:3881:QuorumCnxManager$Listener@517] - Exception while listening
java.net.BindException: Cannot assign requested address
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
        at java.net.ServerSocket.bind(ServerSocket.java:376)
        at java.net.ServerSocket.bind(ServerSocket.java:330)
        at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java:507)
2018-01-22 23:54:51,638 [myid:1] - INFO  [QuorumPeer[myid=1]/0.0.0.0:2181:QuorumPeer@714] - LOOKING
2018-01-22 23:54:51,639 [myid:1] - INFO  [QuorumPeer[myid=1]/0.0.0.0:2181:FastLeaderElection@815] - New election. My id =  1, proposed zxid=0x0
2018-01-22 23:54:51,641 [myid:1] - INFO  [WorkerReceiver[myid=1]:FastLeaderElection@597] - 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)
"zookeeper.out" 279L, 24203C
搞不懂啥情况,再附上配置文件
#
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=/usr/local/zookeeper/zookeeper01/data
dataLogDir=/usr/local/zookeeper/zookeeper01/zkLog
# 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=slave-01:2881:3881
server.2=slave-02:2882:3882
server.3=slave-03:2883:3883求各位大神解答