Redis, an in-memory data store allows us to change its configuration by editing the file command line.
As a part of our Server Management Services, we help our Customers to tweak Redis configuration.
Let us today discuss steps to change the Redis configurations on an Ubuntu server.
Change Redis’s Configuration
Redis command line interface allows commands to make changes to the Redis server’s configuration settings. Let us now discuss some commands using the redis-cli interface to alter the configuration.
The Redis configuration file is located at the location “/etc/redis/redis.conf” and can be opened with a normal text editor.
config set allows us to reconfigure Redis at runtime without having to restart the service.
It is important to note that the config set command should be run only if we are absolutely certain that we want to make changes to the configuration. This is because changing configuration can make the Redis server to behave in unexpected or undesirable ways.
The config set command uses the following syntax:
127.0.0.1:6379> config set parameter value
For instance, to change the name of the database dump file that Redis produces after a save command, use the format below:
127.0.0.1:6379> config set “dbfilename” “new_filename.rdb”
If the configuration change is valid, the command will return OK. Otherwise it will return an error.
Note that we cannot change some parameters in the redis.conf file like authentication password defined by the requirepass parameter with a config set operation.
Make Redis Configuration Change Permanent
The commands mentioned here will only alter the Redis server’s behavior for the duration of the current session
To edit redis.conf after running a config-set command and make the current session’s configuration permanent, run config rewrite:
127.0.0.1:6379> config rewrite
This command does its best to preserve the comments and overall structure of the original redis.conf file, with only minimal changes to match the settings currently used by the server.
Like config set, if the rewrite is successful config rewrite will return OK.
Check Redis’s Configuration
The config get command helps to read the current configuration parameters of a Redis server. This command takes a single argument, which can be either an exact match of a parameter used in redis.conf or a glob pattern.
For instance,
127.0.0.1:6379> config get repl*
Depending on the Redis configuration, this command might return all the parameters that are related to repl.
We can also return all of the configuration parameters supported by config set by running config get *.
[Need any further assistance to change Redis configuration? – We’re available 24*7]
Conclusion
In short, Redis, an in-memory data store allows us to change its configuration by editing the corresponding file command line. Today, we saw how our Support Engineers fix this error.
0 Comments