Zookeeper Introduction and cluster installations

1.Zookeeper concept Description:

    Zookeeper is a distributed coordination services; to provide coordinated services for users of distributed applications, zookeeper is distributed to other programs and services. Zookeeper itself is a distributed program (as long as more than half of nodes alive, zk will be able to normal service), the service covers Zookeeper offered: from the main coordinator, server nodes offline dynamic, unified configuration management, distributed shared lock, unified name service, although you can provide a variety of services, but the zookeeper at the bottom really only provides two functions:

 

Data management (storage, reading) submitted by the user program; and to provide data for the user node monitoring service program;

2.zookeeper cluster mechanism
Half mechanism: More than half of the cluster machines to survive, the cluster is available.
zookeeper adapted to fit on the odd machine! ! !
Installation
machine deployment
installed on three virtual machines
installed JDK


upload
upload tool.
Extracting
tar -zxvf zookeeper-3.4.5.tar.gz (decompression)
Rename
mv zookeeper-3.4.5 zookeeper (rename a folder is ZooKeeper zookeeper-3.4.5)
modify environment variables

vi / etc / profile (revised document)
add content to see their own situation:

export ZOOKEEPER_HOME=/home/apps/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin

Modify the configuration file

ZooKeeper CD / the conf
CP zoo_sample.cfg zoo.cfg
VI zoo.cfg
add content:
dataDir = / Home / Apps / ZooKeeper / Data
dataLogDir = / Home / Apps / ZooKeeper / log
server.1 = Slave1: 2888: 3888 (host name , heartbeat port, data port)
server.2 = slave2: 2888: 3888
server.3 = slave3: 2888: 3888


Create a folder:
cd / Home / Apps / ZooKeeper /
mkdir -m 755 the Data
mkdir -m 755 log


New folder contents myid file data file, myid is:
cd data
vi myid
add content:
1

will be sent to a clustered on other machines
scp -r / Home / Apps / ZooKeeper hadoop @ slave2: / Home / Apps /
scp -r / Home / Apps / ZooKeeper hadoop @ slave3: / Home / Apps /
modify other machine's configuration file
to the slave2: myid modified as follows: 2
on the slave3: myid modified as follows: 3
start (each machine)
zkServer.sh start
See cluster status
JPS (see process)
zkServer.sh status (See cluster state information from the master)
zookeeper command structure and
zookeeper characteristics
1, Zookeeper: Leader a cluster, composed of a plurality of follower
2, consistent with global data: each server retain an identical copy of the data, whether client is connected to which server, the data are consistent
3, a distributed read and write, update request forwarded by the leader embodiment
4, the update order request from a client requests the same update their send the order execution
5, the data update atomicity, a data update either succeed or fail
6, real-time, within a certain time frame, client can read the latest number

zookeeper data structure
1, the hierarchical directory structure, file names conform to the conventional system specification (see below)
2, in each node is called znode zookeeper, and it has a unique path identifier
3, Znode node and child nodes can contain data (but not EPHEMERAL type of node has child nodes, next explained in detail)
4, the client application may be provided on the monitor node (explained in detail subsequent)
data structure of

 

3. The node type
1, Znode there are two types:
short (ephemeral) (disconnect yourself delete)
persistent (persistent) (disconnected without deleting)
2, znode there are four forms of directory node (default is persistent)
PERSISTENT
PERSISTENT_SEQUENTIAL (persistent sequence / test0000000019)
Ephemeral
EPHEMERAL_SEQUENTIAL
. 3, provided when creating znode sequence identity, appends a value znode name, is a monotonically increasing sequence number counter, maintained by the parent node
4, in a distributed system, the sequence number can be It is used for all events globally ordered, so that the client may infer the order of the sequence of events through a No.
zookeeper command line
run zkCli.sh -server <ip> into the command line tool

There are help command Operations Guide

Guess you like

Origin www.cnblogs.com/mapleleaf-xp/p/11262822.html