Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
run multiple redis instances on the same server for centos
  • create a new redis .conf file
$ cp /etc/redis.conf /etc/redis-xxx.conf
  • edit /etc/redis-xxx.conf, illustrated as below
#modify pidfile
#pidfile /var/run/redis/
pidfile /var/run/redis/

#dir /var/lib/redis/
dir /var/lib/redis-xxx/

#modify port
#port 6379
port 6380

#modify logfile
#logfile /var/log/redis/redis.log
logfile /var/log/redis/redis-xxx.log

#modify vm-swap-file
#vm-swap-file /tmp/redis.swap
vm-swap-file /tmp/redis-xxx.swap
  • make dir /var/lib/redis-xxx
$ mkdir -p /var/lib/redis-xxx
  • copy init script
$ cp /etc/init.d/redis /etc/init.d/redis-xxx
  • edit the new init script




  • query the status of this redis in
$ sudo service redis-xxx status
# server is stopped

# start service
$ sudo service redis-xxx start
  • make redis-xxx service auto start
$ sudo chkconfig --level 3 redis-xxx on

This comment has been minimized.

Copy link

gblazex commented Feb 27, 2015

You are missing a command after creating the folder:

chown redis /var/lib/redis-xxx

Otherwise you get Permission Denied errors on every save.


This comment has been minimized.

Copy link

kanet77 commented Jan 22, 2016

Thanks! This is exactly what I was looking for.

I don't see this line in my redis.conf

vm-swap-file /tmp/redis.swap

According to

Redis VM is now deprecated. Redis 2.4 will be the latest Redis version featuring Virtual Memory (but it also warns you that Virtual Memory usage is discouraged).

Maybe leave the line but add a comment # v2.4 and prior (See


This comment has been minimized.

Copy link

iiirxs commented Aug 31, 2018

You are also missing a command after creating the .conf file:
sudo chown redis /etc/redis-xxx.conf
or you will get a # Fatal error, can't open config file '/etc/redis-xxx.conf'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.