Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save madalinignisca/0ea79e46342c28a47e6e to your computer and use it in GitHub Desktop.
Save madalinignisca/0ea79e46342c28a47e6e to your computer and use it in GitHub Desktop.

#FOR MULTIPLE REDIS INSTANCE INSTALLATION ON RHEL7+ USE THE FOLLOWING PATHS AND SETUP PROCESS:

  • 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/redis.pid
pidfile /var/run/redis/redis-xxx.pid

...
#modify port
#port 6379
port 6380

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

...
#modify db file name
#dbfilename dump.rdb
dbfilename dump-6380.rdb

* THERE IS NO init.d files RHEL uses systemctl instead so:
* copy existing service over to your new service

```Bash
$ cp /usr/lib/systemd/system/redis.service /etc/systemd/system/redis-xxx.service
  • modify your new service script to the following: (just change the redis-xxx path)
...

#[Unit]
Description=Redis persistent key-value database
After=network.target

#[Service]
ExecStart=/usr/bin/redis-server /etc/redis-xxx.conf --daemonize no
ExecStop=/usr/bin/redis-shutdown
User=redis
Group=redis

#[Install]
WantedBy=multi-user.target
...
  • if you have sentinel enabled on your system you will need to: (otherwise skip this step)
# Copy values from cat /usr/lib/systemd/system/redis.service to /usr/lib/systemd/system/redis-xxx.service
$ cp /usr/lib/systemd/system/redis.service /usr/lib/systemd/system/redis-xxx.service
  • then edit the contents of /usr/lib/systemd/system/redis-xxx.service (just change the /etc/redis-xxx path again)

  • start the new services:

$ service redis-xxx start
  • check the new services status:
$ service redis-xxx status
  • stop the new services status:
$ service redis-xxx stop
  • restart the new services status:
$ service redis-xxx restart
  • if you get some problems with service not found:
  • you can do the following:
$ systemctl unmask packagekit.service
$ systemctl mask packagekit.service
  • then try to start the service again
@madalinignisca
Copy link
Author

edited for Centos 7.1+

@madalinignisca
Copy link
Author

Personally I just started using Docker to run Redis and Memcached instances on the same host much more easier and flexible. I suggest you do the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment