Distributed service framework Zookeeper

Zookeeper distributed service framework is a sub-project of Apache Hadoop. It is mainly used to solve some data management problems often encountered in distributed applications, such as: unified naming service, state synchronization service, cluster management, distributed application configuration items management, etc. This article will introduce the meaning of each configuration item in the installation and configuration files of Zookeeper in detail from the user's point of view, and analyze the typical application scenarios of Zookeeper (configuration file management, cluster management, synchronization lock, leader election, queue management, etc.). Java implements them and gives sample code.

Principle: https://www.cnblogs.com/raphael5200/p/5285583.html

Distributed Coordination Service Architecture
Distributed : Multiple computers form a system to solve the same problem
Problem:
Node failure Creation and update of
configuration information: Change Database information
Distributed lock

zookeeper: Distributed coordination service
1. Configuration center
Load balancing, multiple nodes assign nodes
Unified naming service
Shared lock

2. Version number {cversion dataversion vclversion}
Stand-alone deployment steps:
1. Download zookeeper.tar.gz
tar -xzvf .tar.gz
2. Copy zoo_sample.cfg, rename zoo.cfg, modify zoo.cfg
zoo.cfg see its file:
tickTime=2000
dataDir=D:/devtools/zookeeper-3.2.2/build
clientPort=2181
3. Start bin/zkServer.sh star|stop|restart|status
  Start ZK service: bin/zkServer.sh start
  View ZK service status: bin/zkServer .sh status
  Stop the ZK service: bin/zkServer.sh stop
  Restart the ZK service: bin/zkServer.sh restart For
example: ./zkServer.sh start
If after startup, check the status error, stop it
first , use ./zkServer.sh start -foreground start, check the specific error log.
The jdk may not be installed or the folder may not have been created:
Install jdk with the following command:
yum install java-1.8.0-openjdk*
After the installation is complete, we can pass
java -version
ZooKeeper command line:
In the installation directory bin, execute zkcli.cmd or zkcli.sh. Then enter the command.
Common commands:
view data: ls /, ls2
get data: get /

4.bin/zkCli.sh [-timeout 0 -r]-server host:port

3. Cluster deployment:
leader election algorithm
paxos algorithm
Configure multiple server folders, and synchronize stand-alone operations in
1.zoo.cfg in each server , to ensure that each service port number is unique clientPort=2181
2.zoo.cfg, the dataDir file server path selects its own.
3.zoo.cfg:
#2888 is for communication between servers, 3888 is for application communication 

# Add the address and port information of the other two services at the same time 
#server.1 =101.200.129.112:2888:3888
#server.2 =101.200.129.112:2889:3889
#server.3 =101.200.129.112:2890:3890

leader follow
question: why two port numbers

4. Client operation command
1.create [-s][-e]path data acl
creation Nodes, generally create nodes and monitor them, so that other applications can monitor node changes.
-s is an ordered node
2.get path[watch]
3.set path data[version]
4.delete path[version]
5.setquota -n|-b val path

5. Configure
zookeeper-3.4.9\conf\zoo.cfg Configure the port and the maximum number of connections.

6. Permission
schema
digest
ip
word

7. Monitor
doWatcher

8. Use zookeeper under centos


http://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper/

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326800825&siteId=291194637