13. Tools

Nikita Koksharov edited this page Aug 16, 2016 · 13 revisions

13.1. Redis deployment tool

Redisson allows to deploy Redis server via SSH using login/key or login/password for authentication. Each Redis instance would be deployed as linux service. Redis distribution zip is downloaded from official source. If redisVersion is omitted then latest version is used.

        DeployResult result = RedisDeploymentTool.create()
                .redisVersion("3.0.7")
                .node()
                    .sshUrl("89.12.4.9:22")
                    .sshLogin("deployment_user")
                    .sshKeyPath("C:\\my_keys\\id_rsa")
                    .redis()
                        .withConfig("C:\\redis-cluster.conf")
                        .port(1165)
                    .redis()
                        .withConfig("C:\\redis-cluster.conf")
                        .port(7000)
                .node()
                    .sshUrl("27.0.31.1:22")
                    .sshLogin("deployment_user")
                    .sshKeyPath("C:\\my_keys\\id_rsa")
                    .redis()
                        .port(1139)
                .node()
                    .sshUrl("7.0.20.1:22")
                    .sshLogin("deployment_user")
                    .sshPassword("mypass")
                    .redis()
                        .port(1134)
        .deploy();

      if (result.getStatus() == Status.SUCCESS) {
          // All Redis nodes were successful deployed
          ...
      } else if (result.getStatus() == Status.HAS_ERRORS) {
          // At least one Redis server deployment were successful
          // other Redis server deployments may have errors
          ...
      } else if (result.getStatus() == Status.FAILED) {
          // All Redis servers deployment were faile
          ...
      }

Example above does follow:
1. Deploys two Redis servers with custom config redis-cluster.conf to 89.12.4.9 server bounded to 1165 and 7000 ports respectively
2. Deploys one Redis server with standard config shipped in Redis distribution zip to 27.0.31.1 server bounded to 1139 port
3. Deploys one Redis server with standard config shipped in Redis distribution zip to 7.0.20.1 server bounded to 1134 port

This feature available only in Redisson PRO edition.

13.2. Cluster management tool

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

13.2.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:7003
127.0.0.1:7005 doesn't have slaves.

13.2.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.2.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.2.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.2.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.