Skip to content

13. Tools

Rui Gu edited this page Jan 31, 2019 · 17 revisions

13.1. Cluster management tool

Cluster management tool allows easily manage by Redis cluster nodes like redis-trib.rb script does.

13.1.1 Cluster management tool. Create Redis cluster

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.

13.1.2 Cluster management tool. Remove Redis node

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

13.1.3 Cluster management tool. Move slots between Redis nodes

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

13.1.4 Cluster management tool. Add slave Redis 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

13.1.5 Cluster management tool. Add master Redis node

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.