Sometimes when we login to a redis server, we can see the running redis on it, but we don't know where are the configuration files and the rdb backups files for the redis. In this post, we will see how to find out the location of various configuration files in redis.
The below are the important files in redis.
The below are the important files in redis.
- redis.conf => main configuration file in redis
- dump.rdb => backup file generated by background save in redis
- sentinel.conf => sentinel configuration file, required only while running sentinel
- nodes.conf => cluster configuration file, auto-generated by running redis in cluster mode.
Location of redis.conf
redis.conf is the major redis configuration file which has lots of very useful info and lots of highly configurable parameters.
Whether you are a developer who wants to dive more in redis or a redis admin, it is very important to read the file and try to understand the configuration params. See the sample here.
For finding out the location of redis.conf, we will use the INFO command.
info command gives a lot of very useful information about the redis server, one of which is the location of config file.
so, below command gives us the location of redis.conf file.
src/redis-cli -p 6379 info | grep 'config_file'
Location of sentinel.conf file
sentinel.conf file is only required if you are using a sentinel in redis. See the sample sentinel.conf file here. It is normally present in the same directory as redis.conf.
For finding out the sentinel.conf, we can execute the command on sentinel(note that sentinel by default runs on 26379 port while redis runs on 6379 port)
src/redis-cli -p 26379 info | grep 'config_file'
Location of dump.rdb file
dump.rdb file is the default file in which redis will save the data to disk if you enable rdb based persistence in the redis.conf file.
The location of dump.rdb can be obtained in either of the two ways
- reading the "dir" value in redis.conf file found from the location of redis.conf
cat redis.conf | grep "dir "
- getting it from redis config
Sometimes if we get the "dir " from the redis.conf file, it just shows the current directory( "./")
In this case, it is better to get it from the redis config by executing the command below.
src/redis-cli -p 6379 CONFIG GET dir
Note that #2 will only work if CONFIG command is not renamed/disabled in redis.
If it is you will have to find out the renamed command and then use the renamed command instead of CONFIG.
Location of nodes.conf file
In a redis cluster, each cluster node/instance automatically generates a nodes.conf file where the view of the cluster with respect to that node is stored.
It stores the cluster related information like
For all the nodes in the cluster, it stores
- the current node, and whether it is a master or a slave.
- no of clients connected to it.
- slot ranges for which it holds data(if it is a master)
- the epoch
the nodes.conf file is also stored in the same location as dump.rdb.
No comments:
Post a Comment