Cluster Management Tool redis-trib.rb has been abandoned, so do not need to install Ruby what, at that time the redis-trib.rb function, now has been integrated into redis-CLI, can pass. /redis-cli -- cluster help to view the usage.
Environment
# Creating a cluster #
./Redis-cli -- cluster create 192.168.1.172: 6379 192.168.1.172: 6380 192.168.1.172: 6381
Check that all slots have been evenly allocated.
# Check the cluster #
./Redis-cli -- cluster check 192.168.1.172: 6379
View all cluster operations
# View Cluster key, slot, and slave distribution information #
./Redis-cli -- cluster info 192.168.1.172: 6379
# Online migration slot #
./Redis-cli -- cluster reshard 192.168.1.172: 6379
Select the ID of a target node
Select All for The Source
# Balancing the number of slots on each node #
./Redis-cli -- cluster rebalance -- cluster-threshold 1 192.168.1.172: 6379
Balanced
# Deleting a cluster node #
./Redis-cli -- cluster del-node 192.168.1.172: 6379 b97cde23f3c1a1b13e42728562180355b985831a
It must be a node without a slot, so you must remove the slot first. Otherwise, the following error is reported:
The node is deleted successfully and disabled after the slot is migrated through reshard.
After the deleted node is restarted, you still remember the other nodes in the cluster. You need to execute cluster forget nodeid to forget other nodes.
# Add a cluster node #
./Redis-cli -- cluster add-node 192.168.1.172: 6379 192.168.1.172: 6380
Rebalance the number of slots on each node
# Import data from external redis instances of the cluster to the cluster #
./Redis-cli -- cluster import 192.168.1.172: 6379 -- cluster-from 192.168.1.172: 6382 -- cluster-copy
Cluster-from is followed by the external redis IP address and port
If you only use cluster-copy, the key in the cluster to be imported cannot be in; otherwise, the following is returned:
If the same key already exists in the cluster, you can use cluster-copy and cluster-replace to replace the key in the cluster.
5.0 redis-cli cluster management test