Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the data directory in Redis?

After writing some data to a redis server, I could read the data from a client. However, how can I find the data directory on the file system?

like image 738
bafla Avatar asked Aug 29 '15 09:08

bafla


People also ask

Does Redis store data to disk?

Within Redis, there are two different ways of persisting data to disk. One is a method called snapshotting that takes the data as it exists at one moment in time and writes it to disk. The other method is called AOF, or append—only file, and it works by copying incoming write commands to disk as they happen.

How do I access my Redis database?

To start Redis client, open the terminal and type the command redis-cli. This will connect to your local server and now you can run any command. In the above example, we connect to Redis server running on the local machine and execute a command PING, that checks whether the server is running or not.

How does Redis store data in-memory?

Redis is an In-Memory Database(IMDB) as it relies on main memory of computer for data storage while others use Disk Storage database mechanism. That is why Redis is faster than disk-optimized databases because disk access is slower than memory access.


2 Answers

Quickest method: use redis-cli.

redis-cli config get dir 

If you have authentication configured, you will need to pass that in using -a password Replacing "password" with your password.

like image 195
The Real Bill Avatar answered Sep 28 '22 09:09

The Real Bill


Find your Redis configuration directory, probably /etc/redis. Then look in the config file called redis.conf and find the line that starts dir.

It will look similar to this:

dir /etc/redis/database 

This will do the job slowly but surely if you can't be bothered to look :-)

sudo find / -name "redis.conf" -exec grep "^dir" {} \; 2> /dev/null dir /etc/redis 

or if you want the config filename as well:

sudo find / -name "redis.conf" -exec grep -H "^dir" {} \; 2> /dev/null /private/etc/redis/redis.conf:dir /etc/redis 

Other possibilities you can check are whether Redis was started with a custom config file as its first parameter like this:

redis-server /path/to.custom/config-file 

or with the dir option set on the commandline like this:

redis-server dir /path/to/data 

Use

ps -aef | grep redis 

to look for these options.

like image 33
Mark Setchell Avatar answered Sep 28 '22 08:09

Mark Setchell