clientPort=2181
dataDir=/data/znode1
server.1=192.168.1.246:2888:3888
server.2=192.168.1.246:2889:3889
server.3=192.168.1.246:2890:3890
#server.N=YYY:A:B
#where N represents the server number,
#YYY represents the IP address of the server,
#A is the LF communication port, indicating the port of the information exchanged between the server and the leader in the cluster.
#B is the election port, which indicates the port for communication between servers when a new leader is elected (when the leader hangs, the rest of the servers will communicate with each other and select a new leader).
Persistent Node (PERSISTENT)
The so-called persistent node means that after the node is created, it will always exist until there is a delete operation to actively clear the node - it will not disappear due to the invalidation of the client session that created the node.
Persistent Sequence Node (PERSISTENT_SEQUENTIAL)
The basic characteristics of this type of node are the same as the above node types. An additional feature is that in ZK, each parent node maintains a sequence for its first-level child nodes, recording the order in which each child node was created. Based on this feature, this property can be set when creating a child node, then during the node creation process, ZK will automatically add a numeric suffix to the given node name as a new node name. The range of this number suffix is the maximum value of the integer.
Ephemeral node (EPHEMERAL)
Unlike persistent nodes, the lifetime of ephemeral nodes is tied to the client session. That is, if the client session fails, the node will be automatically cleared. Note that this is referring to session invalidation, not disconnection. Also, no child nodes can be created under a temporary node.
Temporary Sequence Node (EPHEMERAL_SEQUENTIAL)
Can be used to implement distributed locks
ZooKeeper's Watch event type
session events
Watcher.Event.EventType.None
Trigger Event TypeAUTH_FAILED event | Watcher.Event.KeeperState.AuthFailed |
CONNECTED event | Watcher.Event.KeeperState.ConnectedReadOnly |
CONNECTED event | Watcher.Event.KeeperState.SyncConnected |
DISCONNECTED event | Watcher.Event.KeeperState.Disconnected |
SESSION_EXPIRED event | Watcher.Event.KeeperState.Expired |
SASL-authenticated event | Watcher.Event.KeeperState.SaslAuthenticated |
data events
Trigger Event Type WatchesZooKeeper.create | Watcher.Event.EventType.NodeCreated | ZooKeeper.exists ZooKeeper.getData |
ZooKeeper.setData | Watcher.Event.EventType.NodeDataChanged | ZooKeeper.getData |
ZooKeeper.delete | Watcher.Event.EventType.NodeDeleted | ZooKeeper.exists |
child events
Trigger Event Type WatchesZooKeeper.create | Watcher.Event.EventType.NodeChildrenChanged | ZooKeeper.getChildren |
ZooKeeper.delete | Watcher.Event.EventType.NodeChildrenChanged | ZooKeeper.exists ZooKeeper.getChildren |
Zookeeper, a distributed service framework -- manages data in a distributed environment