Skip to content

Instantly share code, notes, and snippets.

@ShahanMirza
Last active December 9, 2020 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShahanMirza/71dab97f1c72c2dbbb4c6cd7f0d63337 to your computer and use it in GitHub Desktop.
Save ShahanMirza/71dab97f1c72c2dbbb4c6cd7f0d63337 to your computer and use it in GitHub Desktop.
redis multiple configuration running on local single host
Create the directory for the new instance and dont use sudo if you are working on root user
$ sudo install -o redis -g redis -d /var/lib/redis2
Create a new configuration file
$ sudo cp -p /etc/redis/redis.conf /etc/redis/redis2.conf
Edit the new configuration file
$ sudo nano /etc/redis/redis2.conf
pidfile /var/run/redis/redis-server2.pid
logfile /var/log/redis/redis-server2.log
dir /var/lib/redis2
port 6380
Create new service file
$ sudo cp /lib/systemd/system/redis-server.service /lib/systemd/system/redis-server2.service
Edit the new service file
$ sudo vim /lib/systemd/system/redis-server2.service
ExecStart=/usr/bin/redis-server /etc/redis/redis2.conf
PIDFile=/var/run/redis/redis-server2.pid
ReadWriteDirectories=-/var/lib/redis2
Alias=redis2.service
Enable and start the service
$ sudo systemctl enable redis-server2.service
$ sudo systemctl start redis-server2.service
Check status
$ ps aux |grep redis
redis-cli -p 6380
127.0.0.1:6380> ping
PONG
127.0.0.1:6380> exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment