ZooKeeper Getting Started Tutorial

ZooKeeper Introduction

  • Coordination is a reliable system for large distributed systems;
  • Available features include: configuration maintenance, name services, distributed synchronization, group services;
  • Is a good goal to encapsulate complex error-prone key positions, it will be easy to use interface and performance efficient and stable system functions available to users;
  • Zookeeper has become the basis for Hadoop ecosystem components.

Installation ZooKeeper

1. ZooKeeper downloaded from the official website
Download: https://archive.apache.org/dist/zookeeper/

Here I downloaded version 3.5.5bin of
reasons: from the latest version 3.5.5 beginning with the name of the bin bag which is what we want to download directly using binary packages are compiled, but before ordinary tar.gz package which is the only source package can not be used directly.
Did not start downloading bin bag, a problem use, there are also records about

Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain

Here Insert Picture Description
2. Extract Configuration

tar -zxf apache-zookeeper-3.5.5-bin.tar.gz -C /usr/myapp

3. Create data logs and two directories under the main directory for storing data and logs:

cd /usr/myapp/apache-zookeeper-3.5.5-bin
mkdir data
mkdir logs

4. Configure ZooKeeper
New zoo.cfg file in the conf directory, writes the following save:

tickTime=2000
dataDir=/usr/myapp/apache-zookeeper-3.5.5-bin/data
dataLogDir=/usr/myapp/apache-zookeeper-3.5.5-bin/logs
clientPort=2181

tickTime microseconds, for the session to register and heartbeat cycle and ZooKeeper client services. When the session timeout length twice the minimum tickTime
state storage location dataDir ZooKeeper to see to know the name of the book data directory. Check your system this directory exists, if you manually created does not exist, and give write permission.
clientPort client connection port. Different servers can set a different listening port, default is 2181

5. Start stop ZooKeeper
into the bin directory, start, stop, restart, and view the current sub-node status (including the cluster is what role) do not perform:

./zkServer.sh start
./zkServer.sh stop
./zkServer.sh restart
./zkServer.sh status

6. zkCli connecting the ZooKeeper (bin directory)

zkCli.sh -server localhost:2181

After a successful connection can use the following command:
Here Insert Picture Description

Published 22 original articles · won praise 9 · views 5064

Guess you like

Origin blog.csdn.net/qq_36470898/article/details/104086944