#FOR MULTIPLE REDIS INSTANCE INSTALLATION ON CentOS 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
...
#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
...
# DEPRECATED #
#modify vm-swap-file
#vm-swap-file /tmp/redis.swap
vm-swap-file /tmp/redis-xxx.swap
...
- make dir /var/lib/redis-xxx
- chown redis:redis /var/lib/redis-xxx
- chmod 700 /var/lib/redis-xxx
- chown redis:root /etc/redis-xxx.conf
- chmod 600 /etc/redis-xxx.conf
$ mkdir -p /var/lib/redis-xxx
- THERE IS NO init.d files CentOS uses systemctl instead so:
- copy existing service over to your new service
$ cp /usr/lib/systemd/system/redis.service /usr/lib/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 redis-xxx
User=redis
Group=redis
#[Install]
WantedBy=multi-user.target
...
- 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
- enable the new services:
$ systemctl enable redis-xxx