
Continuing and delving into the administration of Redis, the task was to deploy the second cluster on a machine with an existing one. For example, for cross-replication, when on one physical server you have master1 and slave2, and on the other, master2 and slave1.
Or just for some logical distribution of information on one machine across multiple clusters.
There was no Russian-language information on the surface, English was found only for Linux.
Therefore, I would like to introduce you to a small helper on the creation of the Redis polycluster in FreeBSD.
The system is FreeBSD 8.4, Radish version 2.8.4 (which, however, is not that important).
To begin with, suppose we have 1 radish with ways:
')
/usr/local/etc/rc.d/redis - - /usr/local/etc/ - /data/redis/ - dump.rdb /logs/redis/ -
It works, it is not necessary to stop it, even if we want the second.
And this is how we do it:
First we need a new config.
Do
cp /usr/local/etc/redis.conf /usr/local/etc/redis_new.conf
In the new config we change:
port (on one port, alas, you can't hang two clusters)
pid file on
/var/run/redis/redis_new.pidunixsocket required
log file on
/logs/redis/redis_new.logand, of course, the datadir at
/ data / redis_new /As well as other settings that interest you.
Do not forget to create a datadir and give the folder rights
mkdir /data/redis_new chown -R redis:redis /data/redis_new
Next, I tried to run both clusters from one init script through a link, but something went wrong.
Therefore, we copy init script
cp /usr/local/etc/rc.d/redis /usr/local/etc/rc.d/redis_new
and in the new rule at the beginning of the parameter "name ="
name="redis_new"
We do not touch the rest.
So, there is a config, logs and a date to write where, an init script is. Run:
/usr/local/etc/rc.d/redis_new start
and see:
@free-bsd:~
Everything works and everything is good. The keys do not intersect, all right. When you call Redis-cli, do not forget to specify the port.
You can also add the third instance, and further, up to the number equal to half of the server cores.
I hope someone else come in handy.