In this article, we have discussed all about settings and checking configurations of Redis. We have finally discussed important Redis configurations, in detail.
Config file location**
How to use custom config file**
Here are the important Redis configuration and their detail-
This section contains all the configurations related to data backup or taking DB snapshots.
dir – working directory
Here is an example of “dir” configuration in the Redis config file.
This is the working directory of Redis. Data will be written in this directory.
Make sure to set a directory here (not a file).
dbfilename – db dump file name
Name of the dump file where the database data is saved. The Redis dump file name has the extension “.rdb“.
This file name is used while saving data for data persistency and also for database backup(when SAVE or BGSAVE command is used). The file name has “.rdb” extension.
This configuration is combined with the “dir” configuration for the full path of the database dump file.
The default database file name is “dump.rdb“.
save – save db to disk
Defines the rule for saving data to disk.
save <interval_in_seconds> <number_of_changes> [<interval_in_seconds> <number_of_changes> ...]
We can define the interval of saving data and the number of changes. Depending on this configuration Redis will check data after each interval of <interval_in_seconds> and if at least the <number_of_changes> are done, the data is saved to disk.
Multiple combinations of interval and number of changes can be defined. These multiple set changes are in “OR” condition with each other. If any of the condition is true, then changes are written to disk.
save 120 1 30 10
Here the changes are saved to disk if any of the following conditions are true-
- At least 1 change is made in 120 seconds. Redis will check every 120 seconds, if at least 1 change is done to the data or not.
- At least 10 changes are made in the last 30 seconds. Redis will check every 30 seconds, if 10 or more changes are made to data or not.
We can disable snapshotting by providing an empty string to save. like below-
Check the following configuration elements required for Redis security-
requirepass – default user password
Set the password for the default user-
This config sets the password for the default user. The name of the default user in Redis is – “default“
aclfile – external file path for ACL config
Use a separate file to define the ACL rule for users-
We can write the ACL permission information in the redis.conf file. But this configuration enables us to use a separate file just for the ACL permission for users.
As this is a standalone file, so the configuration will be separate and easier to maintain.
The file name does have to be user.acl. Name of the file can be anything as we want.
The format of writing configuration is the same as the format of writing ACL permissions in redis.conf–
user firstuser on >somepass ~* +@all &*
user seconduser on >someotherpass ~user* +get
We can use only of the ACL configuration process, either in the redis.conf or in the external file. If user ACL permission are define in redis.conf and also in the external ACL config file at path defined as “aclfile”, then the server will fail to start.