A view (snapshot) are currently configured in each node in the cluster of the cluster, the information provided by the node to view all known nodes, each node comprising a connection status of each node flag (the flags), properties and has been assigned a hash slot and so on.
CLUSTER NODES
Provides information about the current connection node belongs to a cluster, the serialized format information and format used Redis clustered storage on disk exactly the same (at the end of the disk to store information is also stored some additional information).
In general, if you want to know the relationship hash slot for the node, you should use the CLUSTER SLOTS
command. CLUSTER NODES
Mainly used for administrative tasks, commissioning and configuration monitoring. redis-trib
We will also use this command to manage the cluster.
Serialization format
(The command) is output space separated CSV string, each row represents a node in the cluster. Here is an example:
07c37dfeb235213a872192d90877d0cd55635b91 127.0.0.1:30004 slave e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca 0 1426238317239 4 connected 67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1 127.0.0.1:30002 master - 0 1426238316232 2 connected 5461-10922 292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f 127.0.0.1:30003 master - 0 1426238318243 3 connected 10923-16383 6ec23923021cf3ffec47632106199cb7f496ce01 127.0.0.1:30005 slave 67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1 0 1426238316232 5 connected 824fe116063bc5fcf9f4ffd895bc17aee7731ac3 127.0.0.1:30006 slave 292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f 0 1426238317741 6 connected e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca 127.0.0.1:30001 myself,master - 0 0 1 connected 0-5460
The structure of each row of the composition as follows:
<id> <ip:port> <flags> <master> <ping-sent> <pong-recv> <config-epoch> <link-state> <slot> <slot> ... <slot>
Each of the following meanings:
id
: Node ID, is a 40-byte random string, this value is created when the node starts, and will never change (unless you use theCLUSTER RESET HARD
command).ip:port
: Communicating with a client node address used.flags
: Flag, possible values separated by commas are:myself
,master
,slave
,fail?
,fail
,handshake
,noaddr
,noflags
. The next section describes in detail these marks.master
: If the node is a slave, and it is known master node, the master node listed here ID, otherwise listed here "-."ping-sent
: The last time the ping is sent, this time is a millisecond timestamp unix, 0 not send representatives.pong-recv
: Last time received pong using unix timestamp indicates.config-epoch
: Epoch values of the nodes (or of the current master if the node is a slave). Whenever a node failover occurs, it will create a new, unique, incremental epoch. If multiple nodes compete with the hash when a slot, epoch value to snatch a higher node.link-state
: Node-to-node cluster bus links used by the state, we use this link with other nodes in the cluster can communicate value.connected
Anddisconnected
.slot
: Hash or a hash slot value range from the first groove 9 parameters, may be followed by up to 16,384 number (limit never reached). All hash slot value representing the current node can provide the service. If only one value, that is, only one slot will be used. If a range, expressed as the value起始槽-结束槽
, the node will handle all the hash slot includes a start and end slots, including slot.
The meanings of the flags (3 items mentioned above):
myself
: Node currently connected.master
: Node is a master.slave
: Node is a slave.fail?
: Node inPFAIL
state. The current node can not be contacted, but the logic is reachable (non-FAIL
state).fail
: Node is inFAIL
the state most of the nodes are unable to contact them will be changed by the node.PFAIL
Upgrading state toFAIL
state.handshake
: Not yet achieved node trust, currently working with its handshake.noaddr
: No node address (No address known for this node).noflags
: Not even a mark (No flags at all).
Description of the release of the config epochs
slave node in broadcasting, always use the config epochs value of their respective master node (master node is designed to allow it to determine whether it holds data has expired), so if you want to know the slave node itself the true value of config epochs (although there is no sense, because the slave node itself does not deal with the hash tank), you must be directly connected to the slave node, and then execute CLUSTER NODE
the command. Before addition node is connected, a print out epochs command value is a value only in the other node sends a heartbeat packet, this value is a value which belongs config epochs master node.
Special hash slot entry format
Typically each node hash form of a slot allocated as follows:
- Single hash slot, such as: 3894
- Range, such as: 3900-4000
However, there are two special state, it is restarted after a node, other nodes need to confirm the error message (when AOF / RDB file recovery from the found node hash keys and groove profile configuration does not match), or the current node Fragmentation is again required state, it is moved (Importing) and move (Migrating) .
The meaning of these two states in Redis cluster specification is also explained, and then explain in detail the following:
- Importing slot has not been assigned to the node, but is being moved to the current node. Only use the
ASK
command to query these are moved into the slot. - Migrating slots belong to the current node, but is being moved to other nodes. Only when all the key requests in the current node, the request will be responding correctly, otherwise it will use the ASK redirection forced to redirect the client to move into the node.
Importing state and migrating node receiving the CLUSTER NODES
command, the output is as follows:
- Immigrated node output:
[slot_number-<-importing_from_node_id]
- Emigrated node output:
[slot_number->-migrating_to_node_id]
The following is a simple example:
[93-<-292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f]
[1002-<-67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1]
[77->-e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca]
[16311->-292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f]
Note that the output string does not contain any spaces, so CLUSTER NODES
the output is just a space-separated CSV, even if the node is a special state also follow this rule. .
Remarks:
- Only node to
myself
node will only be emigration and immigration, hash slot node with respect, this is a local variable hash slot belongs to a local node (Migration and Importing at The slots are only added to the Node flagged ASmyself
. This information is local to a node, for its own slots). - If a node is moved out or moved to hash slot, the information is only in the additional information reflected. If the hash slot is assigned to a node, and is moved out of the state of hash slots with state migration did not occur, there would be no special message to the client.