Redis installation at local is one of the easiest things to do. However, There are some gotchas involved when we are trying to use redis.
Running redis-server without config(Default Config File will be picked).
When we run redis-server without config, then it creates a dump.rb(A physical file to store all data related to redis) at the folder from which we are starting the redis. We normally, don't realize the impact of this issue as we start the redis server at the same project folder every-time. However, If we start the redis from the some other folder, then in that case redis will not use old dump.rb. So our data will not be accessible to app.
Config should have a path pointing a place outside of the project folder.
This is really necessary, So that we don't accidentally commit or delete the data of dump.rb, Also it helps great when we are deploying code to dedicated servers
- Never run a redis-server with a config file which actually does not exist.
This is an issue that I faced on one of our production server. In this case the redis-server doesn't picks up the default config at all. It also never creates the dump.rb, instead it actally keeps all the data in memory. So we wont be able to take backup at all using the dump.rb(As it doesn't exist). So we had to follow few steps here to generate the dump.rb first and then only we can take the backup(If we stop redis-server here without taking backup then all the data is gone)
redis-cli CONFIG GET dir SAVE
redis-cli : will connect to running redis-server instance
CONFIG GET dir : Will display path in which the redis is running. It can be a specified path at config file or default folder path from which the redis-server started as mentioned in point 1.
SAVE : Will save the dump.rb at the specified path, so that we can take backup.
- Backup and Restore, Production setup: Actually, I found some great links for this already.
[How to restore the Backup (Just Backup)]
[Great Link to setup redis for production and taking BACKUP (Great Link to setup redis for production and taking BACKUP)]
The Second link is a great link for setting redis at prod.
Hope you understood everything. :). Feel free to give your thoughts OR ask questions.