Rajesh
Rajesh

Reputation: 1

customizing the redis cache data directory

I have installed the redis in centos stream 8,

my requirement was to change default directory to custom directory default directory is "/var/lib/redis" i have changed it to "/root/data" and changed the directory owner/group to redis and permission to 755

changed the custom data directory path in "/etc/redis.conf" file and restarted the redis service..

it is getting failed and checked in the "/var/log/redis/redis.log" file the error is Can't chdir to '/root/data': Permission denied

Can anyone help me out on this issue.. Thanks in advance..

Upvotes: 0

Views: 1872

Answers (1)

jmcollantes
jmcollantes

Reputation: 96

This permission denied issue has nothing to do with file/dir perms as one should think, but rather with a safety measure that Redis implements at service level.

Steps to change the DB on Ubuntu 22

We will be changing the Db from the standard /var/lib/redis path to new /dirA/dirB path

  1. mkdir -p /dirA/dirB
  2. sudo systemctl stop redis.service
  3. sudo nano /etc/redis/redis.conf and edit the line reading: dir /var/lib/redis to read dir /dirA/dirB. Save file and exit
  4. sudo nano /etc/systemd/system/redis.service. Add a new line reading ReadWritePaths=-/dirA/dirB. Save file and exit
  5. sudo systemctl daemon-reload
  6. sudo systemctl start redis.service

Ready to go with a new DB!

WARNING

This, on my test machine, caused the stopjobs to stuck so reboots took a lot of time. To solve it you can set TimeoutStopSec to a number different from 0 on /etc/systemd/system/redis.service

5s or 10s are rather used values.

Upvotes: 0

Related Questions