*Creating and using a Redis Cluster
Note: to deploy a Redis Cluster manually is very important to learn certain operation aspects of it. However if you want to get a cluster up and running ASAP skip this section and the next one and go directly toCreating a Redis Cluster using the create-cluster script.
To create a cluster, the first thing we need is to have a few empty Redis instances running incluster mode. This basically means that clusters are not created using normal Redis instances, but a special mode needs to be configured so that the Redis instance will enable the Cluster specific features and commands.
The following is a minimal Redis cluster configuration file:
port 7000 cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 appendonly yes
As you can see what enables the cluster mode is simply the cluster-enabled directive. Every instance also contains the path of a file where the configuration for this node is stored, that by default isnodes.conf. This file is never touched by humans, it is simply generated at startup by the Redis Cluster instances, and updated every time it is needed.
Note that the minimal cluster that works as expected requires to contain at least three master nodes. For your first tests it is strongly suggested to start a six nodes cluster with three masters and three slaves.
To do so, enter a new directory, and create the following directories named after the port number of the instance we'll run inside any given directory.
Something like:
mkdir cluster-test cd cluster-test mkdir 7000 7001 7002 7003 7004 7005
Create a redis.conf file inside each of the directories, from 7000 to 7005. As a template for your configuration file just use the small example above, but make sure to replace the port number7000 with the right port number according to the directory name.
Now copy your redis-server executable, compiled from the latest sources in the unstable branch at GitHub, into thecluster-test directory, and finally open 6 terminal tabs in your favorite terminal application.
Start every instance like that, one every tab:
cd 7000 ../redis-server ./redis.conf
As you can see from the logs of every instance, since no nodes.conf file existed, every node assigns itself a new ID.
[82462] 26 Nov 11:56:55.329 * No cluster configuration found, I'm 97a3a64667477371c4479320d683e4c8db5858b1
This ID will be used forever by this specific instance in order for the instan