Adding and Removing Instances from a Cluster
Let’s discuss how to add and remove nodes from a cluster.
In the previous lesson, we created a cluster with six nodes. There may be certain situations where we need to add or remove instances from the cluster. Let’s look at the commands used to add and remove nodes from a cluster.
Adding nodes to a cluster
When a new node is added to a cluster, it is considered a master. It does not have any hash slots assigned, so it cannot store any key. It is up to us to determine which hash slots we need to move to the newly added master. We can move the hash slot from one master to another and then migrate the keys stored on that hash slot. The step-by-step guide to adding a new node to the cluster is shown below.
Creating a new instance
In our cluster, we have six nodes running on ports 7001, 7002, 7003, 7004, 7005 and 7006. We will create a new instance that will be run on port 7007. The process of creating this instance is the same as the process shown in the previous lesson.