Tag Archives: How to Configurate Redis.conf File

Redis: How to Configurate Redis.conf File

The configuration file is case insensitive

Other configuration files can be included

###Network-related###
# bind 127.0.0.1 # Bind the listening NIC IP, comment out or configure to 0.0.0.0 to make any IP accessible

protected-mode yes # Turn off protected mode, use password access

port 6379 # Set the listening port, it is recommended that production environments use custom ports

timeout 30 # how long the client connection is idle before disconnecting, in seconds, 0 means disabled

###General configuration###
daemonize yes # default is no, run in the background as a daemon

pidfile /var/run/redis_6379.pid # If running in the background, specify the pid process file name

### log###
# Specify the server verbosity level.
# This can be one of:
# debug (a lot of information, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important/critical messages are logged)
loglevel notice

logfile "" # file name of the log

databases 16 # number of databases default is 16 databases

always-show-logo yes # Whether to show logs, default is no

### RDB persistence configuration ###
### redis is memory-based, no persistence, data disappears if power is lost
save 900 1 # bgsave for RDB persistence if at least one write operation in 900s
save 300 10
save 60 10000 

stop-writes-on-bgsave-error yes # Whether to continue working after persistence errors

rdbcompression yes # whether to compress the rdb file requires CPU consumption recommend setting to no, to exchange (disk) space for (CPU) time

rdbchecksum yes # whether to save the rdb file for checking

dbfilename dump.rdb # rdb file name

dir . / # rdb file save directory

###AOF configuration###
appendonly yes # The default value is no, which means do not use the AOF incremental persistence method, use the RDB full persistence method
appendfsync everysec # optional values always, everysec, no, suggest to set to everysec

### set password###
requirepass 123456 # Set a more complex password

###Clients###
maxclients 10000 # Maximum number of client connections

maxmemory <bytes> # redis sets the maximum memory capacity

maxmemory-policy noeviction # Policy for handling memory when it reaches the upper limit
1, volatile-lru: LRU only for keys with expiration time set (default)
2、allkeys-lru : remove the key of lru algorithm
3, volatile-random: randomly delete the key that is about to expire
4、allkeys-random:randomly delete
5、volatile-ttl : Delete the soon to expire
6、noeviction : Never expire, return error

###APPEND ONLY MODE aof configuration###
appendonly no # default does not enable aof mode, the default is to use rdb way persistent

appendfilename "appendonly.aof" # Persistent file name

# appendfsync always # sync every time you make a change, which consumes performance
appendfsync everysec # execute sync every second, but may lose this 1s data
# appendfsync no # no sync, OS syncs data itself, fastest

Ysec # executes sync once per second, but the 1s data may be lost

Appendfsync no # if you don’t execute sync, the operating system synchronizes data by itself, and the speed is the fastest