-
Notifications
You must be signed in to change notification settings - Fork 5.4k
13. Tools
Cluster management tool allows easily manage by Redis cluster nodes like redis-trib.rb
script does.
Below is an example how to create cluster with 3 masters and 3 slaves.
ClusterNodes clusterNodes = ClusterNodes.create()
.master("127.0.0.1:7000").withSlaves("127.0.0.1:7001", "127.0.0.1:7002")
.master("127.0.0.1:7003").withSlaves("127.0.0.1:7004")
.master("127.0.0.1:7005");
ClusterManagementTool.createCluster(clusterNodes);
127.0.0.1:7000
has slaves 127.0.0.1:7001
, 127.0.0.1:7002
127.0.0.1:7003
has slaves 127.0.0.1:7004
127.0.0.1:7005
doesn't have slaves.
Below is an example how to remove node from cluster.
ClusterManagementTool.removeNode("127.0.0.1:7000", "127.0.0.1:7002");
// or
redisson.getClusterNodesGroup().removeNode("127.0.0.1:7002");
Removes 127.0.0.1:7002
from cluster where 127.0.0.1:7000
participate in
Below is an example how to move slots between cluster master nodes.
ClusterManagementTool.moveSlots("127.0.0.1:7000", "127.0.0.1:7002", 23, 419, 4712, 8490);
// or
redisson.getClusterNodesGroup().moveSlots("127.0.0.1:7000", "127.0.0.1:7002", 23, 419, 4712, 8490);
Moves slots 23
, 419
, 4712
, 8490
from 127.0.0.1:7002
to 127.0.0.1:7000
node
Below is an example how to move slots range between cluster master nodes.
ClusterManagementTool.moveSlotsRange("127.0.0.1:7000", "127.0.0.1:7002", 51, 9811);
// or
redisson.getClusterNodesGroup().moveSlotsRange("127.0.0.1:7000", "127.0.0.1:7002", 51, 9811);
Moves slots range [51, 9811] from 127.0.0.1:7002
to 127.0.0.1:7000
node
Below is an example how to add slave node to cluster.
ClusterManagementTool.addSlaveNode("127.0.0.1:7000", "127.0.0.1:7003");
// or
redisson.getClusterNodesGroup().addSlaveNode("127.0.0.1:7003");
Adds slave node 127.0.0.1:7003
to cluster where 127.0.0.1:7000
participate in
Below is an example how to add master node to cluster.
ClusterManagementTool.addMasterNode("127.0.0.1:7000", "127.0.0.1:7004");
// or
redisson.getClusterNodesGroup().addMasterNode("127.0.0.1:7004");
Adds master node 127.0.0.1:7004
to cluster where 127.0.0.1:7000
participate in
This feature available only in Redisson PRO edition.