Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed description of redis cluster configuration file and cluster status

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Redis cluster command

Cluster (cluster)

Cluster info prints information about the cluster

Cluster nodes lists all the nodes (node) currently known to the cluster, as well as relevant information about these nodes

Node (node)

Cluster meet adds the nodes specified by ip and port to the cluster to make it part of the cluster

Cluster forget removes nodes specified by node_id from the cluster

Cluster replicate sets the current node as the slave node of the node specified by node_id

Cluster saveconfig saves the configuration file of the node to the hard disk

Cluster slaves lists the master nodes of the slave node

Cluster set-config-epoch force setting configEpoch

Slot (slot)

Cluster addslots [slot...] Assign one or more slots (slot) to the current node

Cluster delslots [slot...] Remove the assignment of one or more slots to the current node

Cluster flushslots removes all slots assigned to the current node, making the current node a node without any slots assigned

Cluster setslot node assigns the slot slot to the node specified by node_id. If the slot is already assigned to another node, let the other node delete the slot before assigning it.

Cluster setslot migrating migrates the slot slot of this node to the node specified by node_id

Cluster setslot importing imports slot slot from the node specified by node_id to this node

Cluster setslot stable cancels import (import) or migration (migrate) of slot slot

Key (key)

Cluster keyslot calculates which slot the key key should be placed on

Cluster countkeysinslot return slot number of key-value pairs currently contained in slot

Cluster getkeysinslot returns keys in count slot slots

Other

Cluster myid returns the ID of the node

Cluster slots returns the slot responsible for the node

Cluster reset resets the cluster, use with caution

Redis cluster configuration

Cluster-enabled yes

If you configure yes, the clustering feature is enabled, and this redis instance is used as a node in the cluster, otherwise, it is a normal single redis instance.

Cluster-config-file nodes-6379.conf

Although the name of this configuration is "Cluster configuration File", this configuration file cannot be edited manually. It is a file automatically maintained by cluster nodes. It is mainly used to record which nodes are in the cluster, their status and some persistence parameters, and so on. It is convenient to restore these states on restart. This file is usually updated after a request is received.

Cluster-node-timeout 15000

This is the maximum time that a node in the cluster can be lost, after which the node will be considered a failure. If the master node is still unreachable beyond this time, its slave node will initiate the failover and upgrade to the master node. Note that if any node is still not connected to most of the primary nodes within this time, the node will stop receiving any requests. It is generally set to 15 seconds.

Cluster-slave-validity-factor 10

If set to 0, the slave node attempts to upgrade to the master node no matter how long the slave node loses contact with the master node. If set to a positive number, the time obtained by multiplying cluster-node-timeout by cluster-slave-validity-factor is the longest time that the slave node data is valid after the slave node lost contact with the master node. After this time, the slave node will not start the failover. Assuming cluster-node-timeout=5,cluster-slave-validity-factor=10, if the slave node loses contact with the master node for more than 50 seconds, the slave node cannot become the master node. Note that if this parameter is set to non-0, the cluster may not work properly because a master node is lost but not on top of the slave node. In this case, the cluster will resume operation only when the original master node returns to the cluster.

Cluster-migration-barrier 1

The minimum number of slave nodes required by the master node, which will be migrated only when the master node fails. For more details, you can see the copy migration section later in this tutorial.

Cluster-require-full-coverage yes

If this parameter is set to "yes" (the default) when part of the key is not available, the entire cluster stops accepting operations; if this parameter is set to "no", the cluster still provides read operations for the key on the reachable node.

Redis cluster statu

127.0.0.1purl 8001 > cluster info

Cluster_state:ok

If the current redis finds that there is a slots for failed, the default is to change its cluster_state from ok to fail, the write command will fail. If cluster-require-full-coverage is set to no, there is no such restriction.

Cluster_slots_assigned:16384 # assigned slots

The state of the cluster_slots_ok:16384 # slot is the number of ok

The number of cluster_slots_pfail:0 # slots that may fail

Number of cluster_slots_fail:0 # slots that have failed

Number of nodes in cluster_known_nodes:6 # cluster

Number of shards set in cluster_size:3 # cluster

The currentEpoch in the cluster_current_epoch:15 # cluster is always the same. The higher the currentEpoch, the newer the configuration or operation of the node, the largest node epoch in the cluster.

Cluster_my_epoch:12 # the config epoch of the current node, each master node is different and incremented all the time, indicating the logical time when a node last became the master node or took ownership of the new slot.

Cluster_stats_messages_sent:270782059

Cluster_stats_messages_received:270732696

127.0.0.1purl 8001 > cluster nodes

25e8c9379c3db621da6ff8152684dc95dbe2e163 192.168.64.102 connected 8002 master-0 1490696025496 15 connected 5461-10922

D777a98ff16901dffca53e509b78b65dd1394ce2 192.168.64.156:8001 slave 0b1f3dd6e53ba76b8664294af2b7f492dbf914ec 0 1490696027498 12 connected

8e082ea9fe9d4c4fcca4fbe75ba3b77512b695ef 192.168.64.108 connected 8000 master-0 1490696025997 14 connected 0-5460

0b1f3dd6e53ba76b8664294af2b7f492dbf914ec 192.168.64.170 connected 8001 myself,master-00 12 connected 10923-16383

Eb8adb8c0c5715525997bdb3c2d5345e688d943f 192.168.64.101:8002 slave 25e8c9379c3db621da6ff8152684dc95dbe2e163 0 1490696027498 15 connected

4000155a787ddab1e7f12584dabeab48a617fc46 192.168.67.54:8000 slave 8e082ea9fe9d4c4fcca4fbe75ba3b77512b695ef 0 1490696026497 14 connected

# description

Node ID: for example, 25e8c9379c3db621da6ff8152684dc95dbe2e163

Ip:port: the ip address and port number of the node, for example, 192.168.64.102VR 8002

Flags: the role (master,slave,myself) and status (pfail,fail) of the node

If the node is a slave node, then the node ID of the master node will follow the flags. For example, the ID of 192.168.64.156 ID 8001 master node is 0b1f3dd6e53ba76b8664294af2b7f492dbf914ec.

How long has it taken since the cluster last sent a ping command to the node?

The time when the node last returned a pong reply

Configuration era of the node (config epoch)

The network connection of this node

The node currently contains slots, such as 192.168.64.102Ru 8002, which currently contains slots 5461-10922.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report