5

I am following this tutorial to create a Redis cluster:

http://redis.io/topics/cluster-tutorial

In this tutorial I need to run several redis-server instances on port 7000 through 7005. However after I run the first instance successfully and try to run the second instance the nodes.conf file seems to be locked and I get the following error message:

"Sorry, the cluster configuration file nodes.conf is already used by a different Redis Cluster node. Please make sure that different nodes use different cluster configuration files."

Do I need a separate nodes.conf for every server instance? Or do I need a separate redis-server executable in each instance directory and run it from there?

Milen Kovachev
  • 5,111
  • 6
  • 41
  • 58

1 Answers1

10

The tutorial suggests you to use separated folders for each instance configuration, so each instance will also generate the nodes.conf on its own folder.

Create a redis.conf file inside each of the directories, from 7000 to 7005.

You need to have the .conf files on separated folders for each instance, and the executable must be ran from that folders. Assuming you have the redis-server on /tmp/redis-cluster/, and the redis.conf on each /tmp/redis-cluster/700x folder:

cd /tmp/redis-cluster/7000
../redis-server ./redis.conf

This way the nodes.conf will be generated on the current folder 7000.

Note that you must first issue a cd to change the current directory, and from that folder execute the redis-server that is one folder up (../)

thepirat000
  • 12,362
  • 4
  • 46
  • 72
  • This is exactly what I do. The problem is that the redis-server is outside the 7000, etc. directories and the nodes.conf file which it uses for the cluster configuration is shared when the different servers are started. So I think the tutorial should be edited because the way it is described it does not work. – Milen Kovachev Feb 15 '16 at 14:02
  • I don't think this the problem is in the tutorial. Many of us has followed the tutorial without any problem. Can you share your folder structure and how do you *exactly* run the instances? – thepirat000 Feb 15 '16 at 16:54
  • I have the redis-server in a folder /tmp/redis-cluster. Then I have the different redis.conf files in these folders: /tmp/redis-cluster/7000, /tmp/redis-cluster/7001, /tmp/redis-cluster/7002, /tmp/redis-cluster/7003, /tmp/redis-cluster/7004, /tmp/redis-cluster/7005. Then I run each server with these commands /tmp/redis-cluster/redis-server ./7000/redis.conf, etc. Once the cluster is created, when I try to start the servers again they start complaining about a lock on the nodes.conf file, which is located in the /tmp/redis-cluster directory. – Milen Kovachev Feb 15 '16 at 17:07
  • 1
    You should run the instances like this: `cd /tmp/redis-cluster/7000` `../redis-server ./redis.conf`. I just edited my answer. – thepirat000 Feb 15 '16 at 17:12
  • 1
    This worked! I did not realize that the current directory will be one where the server will generate the nodes.conf. Thanks. – Milen Kovachev Feb 16 '16 at 07:44
  • Yes, actually is generated on the [Current Working Directory](http://unix.stackexchange.com/questions/74249/what-does-it-mean-each-process-has-a-current-directory) of the `redis-server` process. – thepirat000 Feb 16 '16 at 16:14