Redis config file explaination and reference

homepage-banner

==Complete Explanation of Configuration File===

==Basic Configuration
daemonize no Whether to start as a background process
databases 16 Number of databases to create (database 0 is selected by default)

save 900 1 #Refresh snapshot to disk, which will be triggered only if both requirements are met, i.e., at least one keyword has changed after 900 seconds.
save 300 10 #At least 10 keywords have changed after 300 seconds.
save 60 10000 #At least 10000 keywords have changed after 60 seconds.
stop-writes-on-bgsave-error yes #Stop writing on background storage error.
rdbcompression yes #Use LZF to compress rdb files.
rdbchecksum yes #Verify when storing and loading rdb files.
dbfilename dump.rdb #Set the rdb file name.
dir ./ #Set the working directory where rdb files will be written.

==Master-Slave Configuration
slaveof <masterip> <masterport> Set as the slave of a certain machine
masterauth <master-password> Password for connecting to the master server
slave-serve-stale-data yes #Whether the slave server should respond when the main and slave servers are disconnected or in the process of replication
slave-read-only yes #Slave server is read-only
repl-ping-slave-period 10 #Time interval for the slave to ping the main server, in seconds
repl-timeout 60 #Timeout period for the main and slave servers (considered offline if timeout is greater than period)
slave-priority 100 #If the master server cannot function normally, the slave server with the lowest priority value among multiple slaves will be promoted to the master server. A priority value of 0 indicates that it cannot be promoted to the master server.

repl-disable-tcp-nodelay no #Whether the main end merges data and sends it to the slave server in large blocks
slave-priority 100 The priority of the slave server. When the main server is down, the slave server with the smallest priority value will be automatically selected as the main server.

===Security
requirepass foobared #Password required
rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 #Rename some sensitive commands such as config in a public environment.

===Limitations
maxclients 10000 #Maximum number of connections
maxmemory <bytes> #Maximum memory usage

maxmemory-policy volatile-lru #Handling after memory usage is exceeded
volatile-lru -> Use LRU algorithm to delete expired key
allkeys-lru -> Use LRU algorithm to delete key (regardless of expiration)
volatile-random -> Randomly delete expired key
allkeys-random -> Randomly delete key (regardless of expiration)
volatile-ttl -> Delete key that is about to expire quickly
noeviction -> Do not delete and return an error message

# Explanation LRU and ttl are approximate algorithms. You can select N and then compare to find the most suitable T to kick out the data.

maxmemory-samples 3

====Log Mode
appendonly no #Whether only to log
appendfsync no #System buffer, unified write, fast
appendfsync always #System does not buffer, write directly, slow, less data loss
appendfsync everysec #Compromise, write once per second

no-appendfsync-on-rewrite no #If yes, data from other threads is stored in memory and merged for writing (faster, but more easily lost)
auto-AOF-rewrite-percentage 100 Rewriting when the current aof file is larger than N% of the last rewrite
auto-AOF-rewrite-min-size 64mb Aof rewriting must reach at least this size.

====Slow Query
slowlog-log-slower-than 10000 #Record slow queries with response time greater than 10000 microseconds
slowlog-max-len 128 #Maximum number of records

====Server Commands
time Return timestamp + microseconds
dbsize Return the number of keys
bgrewriteaof Rewrite aof
bgsave Subprocess dump data in the background
save Block process and dump data
lastsave

slaveof host port Set as the slave server of host and port (data is cleared and the new content is replicated)
slaveof no one Become the main server (original data is not lost, usually used after the main server fails)

flushdb Clear all data in the current database
flushall Clear all data in all databases (what if misused?)

shutdown [save/nosave] Close the server, save data, and modify AOF (if set)

slowlog get Get slow query log
slowlog len Get the number of slow queries
slowlog reset Clear the slow query log

info []

config get Option (support * wildcard)
config set Option value
config rewrite Write the value to the configuration file
config restart Update the information of the info command

debug object key #Debug option to view the situation of a key
debug segfault #Simulate a segmentation fault to crash the server
object key (refcount|encoding|idletime)
monitor #Open the console to observe commands (for debugging purposes)
client list #List all connections
client kill #Kill a certain connection CLIENT KILL 127.0.0.1:43501
client getname #Get the name of the connection, default nil
client setname "name" #Set the name of the connection for debugging purposes

====Connection Commands===
auth password #Password login (if there is a password)
ping #Test if the server is available
echo "some content" #Test if the server is interacting normally
select 0/1/2... #Select the database
quit #Exit the connection
Leave a message