Zookeeper command and stand-alone deployment

Deployment mode
Distributed

A service is divided into several sub services and deployed on different servers (different servers run different codes for the same purpose), so as to solve the problem caused by high concurrency of websites

colony

The same service is deployed on multiple servers (different servers run the same code), and multiple servers deploy the same application to form a cluster to jointly provide services through load balancing devices

SOA

The business system is decomposed into multiple components, so that each component can independently provide discrete, autonomous and reusable service capabilities. Through the combination and arrangement of services, the business process of the upper layer can be realized, which simplifies maintenance, reduces the overall risk and is flexible

Microservices

Architecture design concept, isolation between services (distributed is also isolation), autonomy (distributed dependence, overall composition) and other features (single responsibility, boundary, asynchronous communication, independent deployment) are the evolution process from distributed concept to microservice architecture
Function: each service can be applied independently, and composite services can also be applied systematically

Zookeepr

ZooKeeper is a distributed, open-source distributed application coordination service. It is a software that provides consistency services for distributed applications. The functions provided include: configuration maintenance, domain name service, distributed synchronization, group service, etc.

Unauthorized access of zookeeper means that no authentication is required by default after installation and deployment, which leads to the remote utilization of zookeeper and the disclosure of a large number of service level information.

Default port

2181: providing services to clients
3888: election leader usage
2888: use of machine communication in the cluster (Leader listens to this port)

Zookeeper quadword command

conf: output the detailed information of related service configuration.
cons: lists the full connection / session details of all clients connected to the server. It includes the number of "accepted / sent" packets, session id, operation delay, last operation execution, etc.
dump: lists unprocessed sessions and temporary nodes.
envi: output detailed information about the service environment (different from the conf command).
reqs: List unprocessed requests
ruok: test whether the service is in the correct state. If this is the case, the service returns "imok". Otherwise, no corresponding action will be taken.
stat: outputs a list of performance and connected clients.
wchs: lists the details of the server watch.
wchc: lists the details of the server watch through the session, and its output is a list of sessions related to the watch.
wchp: lists the details of the server watch through the path. It outputs a path related to the session.

Zookeeper single machine deployment

Download Image
wget https://downloads.apache.org/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2-bin.tar.gz
decompression
tar -zxf zookeeper-3.4.5.tar.gz

Create two folders, data and logs

Copy file conf/zoo_sample.cfg to zoo cfg

Modify the configuration file and modify data and logs to the path just created
dataDir=/root/zookeeper-3.4.5/data
dataLogDir=/root/zookeeper-3.4.5/logs

View Zookeeper deployment method: standalone

Client test connection to zk service area

./zkCli.sh -server 127.0.0.1:2181

You can do some operations

[zk: 127.0.0.1:2181(CONNECTED) 1] ls /   #View the contents contained in the current Zookeeper
[zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 2] create /dudu hello!   #Create a new Znode node dudu
Created /dudu
[zk: 127.0.0.1:2181(CONNECTED) 3] get /dudu  #get confirms the data created in step 2
hello!
cZxid = 0x4
ctime = Fri Nov 06 17:37:39 CST 2020
mZxid = 0x4
mtime = Fri Nov 06 17:37:39 CST 2020
pZxid = 0x4
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 6
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 4] ls /                             
[zookeeper, dudu]
[zk: 127.0.0.1:2181(CONNECTED) 5] delete /dudu  #Delete the created Znode
[zk: 127.0.0.1:2181(CONNECTED) 6] ls /
[zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 7] 

ACL permission control

ZK nodes have five operation permissions: CREATE, READ, WRITE, DELETE and ADMIN, that is, add, DELETE, modify, query and management permissions. These five permissions are abbreviated as crwda (i.e. the abbreviation of the first character of each word).
Note: among the five permissions, delete refers to the permission to delete child nodes, and the other four permissions refer to the operation permission to their own nodes

There are four ways of identity authentication:

  • World: the default mode, which is equivalent to being accessible all over the world
  • auth: represents the authenticated user (in cli, you can add the authorized user in the current context through addauth digest user:pwd)
  • digest: user name: password authentication, which is also the most commonly used method in business systems
  • IP: use IP address authentication

Use [scheme:ID:permissions] to represent acl permissions

[zk: 127.0.0.1:2181(CONNECTED) 1] getAcl /zookeeper  #Get acl permission information of zookeeper node
'world,'anyone
: cdrwa
[zk: 127.0.0.1:2181(CONNECTED) 2] setAcl /zookeeper crwa  #Set acl permission, and deletion is not allowed
crwa does not have the form scheme:id:perm
Acl is not valid : /zookeeper
[zk: 127.0.0.1:2181(CONNECTED) 3] setAcl /zookeeper world:anyone:crwa
cZxid = 0x0
ctime = Thu Jan 01 08:00:00 CST 1970
mZxid = 0x0
mtime = Thu Jan 01 08:00:00 CST 1970
pZxid = 0x0
cversion = -1
dataVersion = 0
aclVersion = 1
ephemeralOwner = 0x0
dataLength = 0
numChildren = 1
[zk: 127.0.0.1:2181(CONNECTED) 4] getAcl /zookeeper
'world,'anyone
: crwa
[zk: 127.0.0.1:2181(CONNECTED) 5] 

Four word command

View profile

View environment variables

Tags: Zookeeper

Posted by jinwu on Sun, 08 May 2022 15:00:10 +0300