paragraph break

Redis configuration file

Redis has built-in default configuration makes it ready to go right after installation, to run Redis with default setting just simply type: redis-server.

However, this setup is only recommandedf for testing purposes, the proper way to configure Redis is by providing a configuration file redis.conf.

If you want to run it with custom settings:

redis-server </path/to/your_redis.conf>

And it is possible to alter the Redis configuration by passing parameters as options, for example:

redis-server --port 9999 --memory 8g
redis-server /path/to/redis.conf --loglevel debug

The redis.conf file contains a number of directives with very simple format:

keyword argument1 argument2 ... argumentN

# for example:
salveof 6380

Example redis.conf file:

protected-mode yes
port 6379
pidfile /var/run/

# using password 'foobar' to portect the server
requirepass foobar

# Specify the eviction policies
maxmemory-policy volatile-lru

# Specify the log file name.
logfile /var/log/redis_6379.log

# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0

# The working directory.
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
# The Append Only File will also be created inside this directory.
# Note that you must specify a directory here, not a file name.
dir /var/redis/6379

About logging

To enable logging to the system logger, just set ‘syslog-enabled’ to yes, and optionally update the other syslog parameters to suit your needs.

syslog-enabled yes

Setup loglevel:

loglevel notice
  • debug: To log rich information for debug purpose
  • verbose: Provide plenty of information in consicely way, less than debug mode
  • notice: The right amount of information is basically what you need in the production environment
  • warning: Only records important messages

Specify the syslog identity:

syslog-ident reeeeeedis

# specify the filename
logfile my_logfile.log

# or, print log to standard output
# Note: if Redis runs as a daemon service, this config will send log into /dev/null
logfile stdout


We can rename some dangerous command in order to pretect production environment:

rename-command FLUSHALL ""
rename-command FLUSHDB  ""
rename-command CONFIG   ""
rename-command KEYS     ""
  • FLUSHALL: Empty all records and database
  • FLUSHDB: Empty database
  • CONFIG: Client-side could modify the configs of server
  • KEYS: Client-side could see all the keys


⤧  Previous post Redis Notes - Cache modes and Memory management ⤧  Next post Redis Notes - Sentinel (for High Availability)