Redis configuration for standalone mode

Running redis-server without any options is good for test, but not enough for production environment. To customize it, you need to build configuration file.

The following options are from version 4.x. And you can refer full documentation here.

Basic options for standalone mode

  • bind some_ip  # If you do not set bind ip, then Redis listens for all interfaces
  • protected-mode no # In protected mode, only clients in the same host can connect
  • port 6379 # Default port is 6379
  • daemonize yes # If set yes, Redis runs in background mode. Default is no
  • pidfile /some/path/to/pidfile
  • logfile/some/path/to/logfile”  # If value is “”, log is sent to standard out. The value must be set as absolute path

Memory options

  • maxmemory <bytes> # If this option is not set, Redis can overflow server memory
  • maxmemory-policy allkeys-lru # If maxmemory is set, this policy is applied when max memory is reached. Default is “noeviction”, which means “Don’t evict anything, just return an error on write operations” I prefer “allkeys-lru” for use case for cache

Persistency options

Redis supports persistence with 2 options – 1) RBB (snapshot) 2) AOF.

Both methods are not exclusive. You can check pros and cons for each option => Detailed explanation

  • save <seconds> <changes> # Option for RDB. If changes occur during seconds, snapshot is executed. If multiple save are declared, in any matching condition, snaphot is executed
  • dir some_path # Working directory for RDB and AOF
  • dbfilename dumpFile.rdb # RDB snapshot file name which is generated at working directory
  • appendonly yes # If set yes, AOF is enabled. Default is no
  • appendfilenameappendonly.aof” # AOF file name. It is generated at working directory

Security options

  • requirepass some_password # If password is set, clients must issue AUTH <password> command, or -a option for redis-cli. Redis recommends very long password

Running with config file

After generating config file, you can run Redis with it as follows.

# ./redis-server path/to/config/redis.conf

 

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.