zookeeper primary

First, what is the zookeeper (summed up)?


    Zookeeper is an open source distributed coordination services shall stand, mainly used to solve the consistency problem of distributed application systems in the cluster;
    is a distributed file storage system on small ZooKeeper nature, similar to a file system-based directory tree way data storage,
    and can be effective management of nodes in the tree, which is used to maintain and monitor the status of data you store changes,
    by monitoring changes in the state of the data, which can achieve based cluster management data,
    such as: uniform naming services, distributed configuration management, load balancing, distributed lock, distributed coordination function.

Two, zookeeper features?


    Zookeeper: a cluster leader (Leader), more followers (Follower) consisting of
    a cluster node alive as long as more than half, Zookeeper cluster will be able to properly service
    the global data consistency: Each Server retain an identical copy of the data, Client regardless of which is connected to the server, the data are consistent
    reliability: if one of the servers message is accepted, the server will be all received
    sequence of: sequentially update request, updates from the same Client transmits its request in the order of execution
    data update atomicity: either a data update success (more than half of the node successfully), or fail, there is no intermediate state
    real-time: Zookeeper ensure client server and then obtain the updated information within a certain interval range of events, or the server fails information

Third, how zookeeper distributed environment to build, step?


    Cluster Planning: Zookeeper deployed on hadoop node
    -extracting package to install Zookeeper / under opt / module / directory
    rename zoo_sample.cfg under /opt/module/zookeeper-3.4.10/conf this directory zoo.cfg
    open zoo.cfg file, modify the data storage path configuration (dataDir), increase the allocation server.1 = hadoop01: 2888: 3888 ...
    created under this directory zkData /opt/module/zookeeper-3.4.10/
    create a myid in / zkData directory file, add the server corresponding number in the file
    distribution configured zookeeper to the other machine, and modify the contents of the file myid

    
Four, ZooKeeper common commands (add, delete, change, the observer, other commands)


    All the operations commands: help
    use the ls command to view the contents contained in the current znode: ls path [watch]
    Check the current node data and data such as the number of updates can be seen: ls2 path [watch]
    Common create: create
    contains the sequence: - s
    temporary (reboot or a timeout disappear): - e
    obtain the value of the node: get path [watch]
    set the node specific values: set
    View node status: stat
    delete a node: delete
    recursively delete a node: rmr
    view the command history: history
    re-execute the specified number of command history command: redo

Fifth, the role and the role of zookeeper cluster, observer of usage scenarios and how to configure?

https://zhuanlan.zhihu.com/p/42067231


    Leader: The only dispatcher and processors core, the transaction request Zookeeper cluster work (write), to ensure that the order of cluster transactions; dispatcher within the cluster each server
    Follower: processing client non-transactional (read) request, forwarding the transaction request to the Leader; participating in the cluster Leader elections
    observer :( access to a greater amount of clusters, can add an observer role)
            observer role, to observe the latest state of the cluster and these changes Zookeeper state synchronization over, for non-transactional request It can be processed independently, for the transaction request will be forwarded to the server for processing Leader
            voting will not participate in any form of providing only non-transactional services, generally used for non-transactional capabilities to enhance the cluster without affecting cluster transaction processing capabilities
            
    
six, zookeeper node types are there?


    Persistent (Persistent): After the client and the server is disconnected, the node is created does not delete
    temporary (Ephemeral): After the client and the server is disconnected, delete nodes created their own
    persistence directory node: client and Zookeeper off after opening the connection, the node still exists
    a persistent sequence number directory nodes: the client and Zookeeper disconnected, the node is still there, just Zookeeper numbered sequentially to the node name of
    the client and Zookeeper disconnect: temporary directory node the node is deleted
    temporary directory sequentially numbered nodes: the client and Zookeeper disconnected, the node is removed, but Zookeeper numbered sequentially to the node name
    

Seven, Stat structure parameters?


    czxid- create nodes transaction zxid
    ctime - The number of milliseconds znode be created (starting in 1970)
    mzxid - znode last updated transaction zxid
    mtime - The number of milliseconds znode last modified (starting in 1970)
    pZxid-znode last updated son node zxid
    cversion - znode child node number change, modify znode child node number
    dataversion - znode data change number (plus one will be modified once)
    ephemeralOwner- If the node is temporary, this is znode owner's session id. If the node is not a temporary 0
    dataLength- znode data length
    numChildren - Number of child nodes znode

Eight, please briefly election mechanism ZooKeeper of?


    Half mechanism: More than half of the cluster machines to survive, the cluster is available. Zookeeper suitable for installation so odd servers
    
Nine, please briefly zookeeper monitor what principle?


    First of all have a main () thread is
    created in the main thread Zookeeper client, then it will create two threads, one for LAN communication (connet), one for listening (listener)
    by registered listeners connect thread will send event Zookeeper to
    listen for events registered in the list of registered listeners are added to the list Zookeeper
    Zookeeper listens to the data or path changes, it will send the message to the listener thread
    inside the listener thread calls the process () method
    

Ten, please briefly zookeeper data write process?


    Client write data to the ZooKeeper on Server1, send a written request
    if Server1 is not the Leader, then Server1 will receive further requests forwarded to the Leader, because each of ZooKeeper Server there is a Leader. The Leader will be broadcast to each write request Server
    information when Leader received more than half (majority) Server data write successful, indicating that the data write success
    Server1 further notice Client data write is successful, then you write that the whole operation success

 

Published 16 original articles · won praise 9 · views 289

Guess you like

Origin blog.csdn.net/XIAOMO__/article/details/103811582