4

So I've had the need of running 2 instances of redis in the same server. My server is an Ubuntu 14.04 box.

So I followed this guide, but not in a strict way. I mean, instead of modifying redis init scripts (that come from Ubuntu packages) I decided to create new scripts for the 2nd instance, and leave the original ones untouched for the first instance.

So then, what I did is:

1) Create new script for new instance (it will run in the 6380 port, instead of the default 6379 one):

sudo cp /etc/init.d/redis-server /etc/init.d/redis-server6380

2) Modify /etc/init.d/redis-server6380 to be a bit different. Instead of:

DAEMON=/usr/bin/redis-server
DAEMON_ARGS=/etc/redis/redis.conf
NAME=redis-server
DESC=redis-server

RUNDIR=/var/run/redis
PIDFILE=$RUNDIR/redis-server.pid

It would have:

NAME=`basename ${0}`
DAEMON=/usr/bin/redis-server
DAEMON_ARGS=/etc/redis/${NAME}.conf
DESC=${NAME}

RUNDIR=/var/run/redis
PIDFILE=$RUNDIR/${NAME}.pid

3) Then copy the configuration:

cp /etc/redis/redis-server.conf /etc/redis/redis-server6380.conf

Edit the new redis-server6380.conf file to be from:

pidfile /var/run/redis/redis-server.pid
port 6379
logfile /var/log/redis/redis-server.log
dir /var/lib/redis

To:

pidfile /var/run/redis/redis-server6380.pid
port 6380
logfile /var/log/redis/redis-server6380.log
dir /var/lib/redis6380

4) Then create the working directory:

sudo mkdir /var/lib/redis6380 && sudo chown redis.redis /var/lib/redis6380

The slight problem I have now, is that it's kind of difficult to check if the instances are runnning.

Before, I guess I could just run:

service redis-server status

And know whether redis is running.

Now, if I do that, I get:

$ service redis-server status
redis-server is not running

Even when the first instance is running! And for the 2nd instance I get:

$ service redis-server6380 status
redis-server6380 is start-stop-daemon: warning: this system is not able to track process
names longer than 15 characters, please use --exec instead of --name.
not running

BUT WHY? I don't understand...

Same thing happens if I use /etc/init.d/redis-server* instead of service. The hacky way I now know to check if they are really running is this:

$ ps aux | grep redis
andrew     365  0.0  0.1  10468  2236 pts/0    S+   07:17   0:00 grep --color=auto redis
redis    22521  0.0  1.3  50860 23132 ?        Ssl  Feb19   4:38 /usr/bin/redis-server 0.0.0.0:6379
redis    52953  0.0  0.5  38572  8860 ?        Ssl  Feb25   0:23 /usr/bin/redis-server 0.0.0.0:6380

But I would like to not need to resort to this :(

user1623521
  • 348
  • 1
  • 3
  • 13

0 Answers0