Introduction to the

ZooKeeper is a distributed, open source distributed application coordination service. It is an open source implementation of Google’s Chubby and an important component of Hadoop and Hbase.

It provides consistency services for distributed applications, including configuration and maintenance, domain name service, distributed synchronization, and group service.

ZooKeeper aims to encapsulate key services that are complex and error-prone, and provide users with easy-to-use interfaces, efficient performance, and stable functions. ZooKeeper contains a simple set of primitives that provide Java and C interfaces.

The installation

Decompress to the specified directory D:\zookeeper

CFG file name (D:\ zookeeper. conf) to zoo.cfg

Modify the log location. The specific configuration file is as follows:

# 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=D:\\zookeeper\\data
dataLogDir=D:\\zookeeper\\log
# 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
Copy the code

Simple configuration file parsing

  • 1. TickTime: Indicates the interval for maintaining heartbeat between Zookeeper servers or between clients and servers. That is, each tickTime sends a heartbeat.
  • DataDir: The directory in which Zookeeper saves data. By default, Zookeeper saves log files that write data in this directory.
  • DataLogDir: Indicates the directory where Zookeeper saves log files
  • ClientPort: This port is used by the client to connect to the Zookeeper server. Zookeeper listens to this port and receives the access request from the client.

Start the

Go to the bin directory and start zkServer.cmd, which will start a Java process

D:\zookeeper\bin>zkServer.cmd
Copy the code

When started, JPS can see the process of QuorumPeerMain

D: \ zookeeper \ bin > zkCli. CMD 127.0.0.1:2181Copy the code