PWD:bin pwd$ zkServer.sh
ZooKeeper JMX enabled by default
Using config: /Users/pwd/Library/Developer/zookeeper/zookeeper/bin/../conf/zoo.cfg
Usage: /Users/pwd/Library/Developer/zookeeper/zookeeper/bin/zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}
PWD:bin pwd$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /Users/pwd/Library/Developer/zookeeper/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
PWD:bin pwd$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /Users/pwd/Library/Developer/zookeeper/zookeeper/bin/../conf/zoo.cfg
Mode: standalone
PWD:bin pwd$ zkServer.sh status |jps
ZooKeeper JMX enabled by default
Using config: /Users/pwd/Library/Developer/zookeeper/zookeeper/bin/../conf/zoo.cfg
21668 RegistryApplication
59765 QuorumPeerMain
728
59867 Jps
mkdir -p cluster/node-2182 cluster/node-2182/data cluster/node-2182/log
mkdir -p cluster/node-2183 cluster/node-2183/data cluster/node-2183/log
mkdir -p cluster/node-2184 cluster/node-2184/data cluster/node-2184/log
touch cluster/node-2182/zoo.cfg
touch cluster/node-2183/zoo.cfg
touch cluster/node-2184/zoo.cfg
node-2182/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/pwd/Library/Developer/zookeeper/cluster/node-2182/data
dataLogDir=/Users/pwd/Library/Developer/zookeeper/cluster/node-2182/log
# the port at which the clients will connect
clientPort=2182
# 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=localhost:21811:21821
server.2=localhost:21812:21822
server.3=localhost:21813:21823
node-2183/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/pwd/Library/Developer/zookeeper/cluster/node-2183/data
dataLogDir=/Users/pwd/Library/Developer/zookeeper/cluster/node-2183/log
# the port at which the clients will connect
clientPort=2183
# 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=localhost:21811:21821
server.2=localhost:21812:21822
server.3=localhost:21813:21823
node-2184/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/pwd/Library/Developer/zookeeper/cluster/node-2184/data
dataLogDir=/Users/pwd/Library/Developer/zookeeper/cluster/node-2184/log
# the port at which the clients will connect
clientPort=2184
# 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=localhost:21811:21821
server.2=localhost:21812:21822
server.3=localhost:21813:21823
# myid中的服务号和各个配置文件中的服务号保持一致
echo "1" > node-2182/data/myid
echo "2" > node-2183/data/myid
echo "3" > node-2184/data/myid
zkServer.sh start node-2182/zoo.cfg
zkServer.sh start node-2183/zoo.cfg
zkServer.sh start node-2184/zoo.cfg
验证
zkCli.sh -server localhost:2182,localhost:2183,localhost:2184

