# 查看状态 [root@archtx apache-zookeeper-3.5.6]# bin/zkServer.sh status /usr/bin/java ZooKeeper JMX enabled by default Using config: /opt/apache-zookeeper-3.5.6/bin/../conf/zoo.cfg Client port found: 2181. Client address: localhost. Mode: standalone
# 启动客户端 [root@archtx apache-zookeeper-3.5.6]# bin/zkCli.sh /usr/bin/java Connecting to localhost:2181 ..... Welcome to ZooKeeper! 2021-09-02 16:03:25,244 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) JLine support is enabled 2021-09-02 16:03:25,317 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@959] - Socket connection established, initiating session, client: /127.0.0.1:54148, server: localhost/127.0.0.1:2181 2021-09-02 16:03:25,331 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1394] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x1000a8aa8090000, negotiated timeout = 30000
-------------------zoo_sample.cfg content begin------------------ # 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. # # 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
tickTime : the basic time unit in milliseconds used by ZooKeeper. It is used to do heartbeats and the minimum session timeout will be twice the tickTime.
dataDir : the location to store the in-memory database snapshots and, unless specified otherwise, the transaction log of updates to the database.
clientPort : the port to listen for client connections