Setting up a redis server

 


Download and first Tests

First we need to download the redis software, either download it from the website or use the following console command:

# wget http://download.redis.io/redis-stable.tar.gz

Unpack the file however you want, eg.:

# tar -xzf redis-stable.tar.gz

Recompile the needed files:

# make

Optional: Check if everything went alright:

# make test

The redis server can now be started with redis-server and will use the default configuration. You can access it with redis-cli .

Using the default configuration is only advised for testing and development.

Installation

Copy the redis files to /usr/local/bin and the init-script from the utils-folder to /etc/init.d :

# cp utils/redis_init_script /etc/init.d/redis

Create folders to store your redis.conf and the data, eg.:

# mkdir /etc/redis
# mkdir /var/redis

Copy the redis.conf to /etc/redis .

If you use more then one redis instance, you might want to create a folder for each instance inside your /var/redis folder. Each instance also needs its own init- and conf-file. Make sure to use distinct names (eg. the used port as suffix).

Configuration

There different ways to access a config file:

  • Modifing the redis.conf which comes with the redis installation
  • Downloading and modifing the redis.conf which can be found on the redis website
  • Writing your own redis.conf

You should add/modify the following parameters to your redis.conf:

  • daemonize to yes
  • pidfile /var/run/redis.pid : location of the pid-file (for multiple instances make sure to choose distinct names)
  • port to the used port
  • loglevel : debug/verbose/notice/warning
  • logfile /var/log/redis.log : location of the log-file (for multiple instances make sure to choose distinct names)
  • dir /var/redis/<instance> : location of the data-files (for multiple instances make sure to choose distinct names)

Once you have modified the redis.conf to your liking, add the init-script to the default runlevels (as root):

# update-rc.d redis defaults

Start the redis-server with:

# /etc/init.d/redis start

Using redis-cli commands

You can lookup and/or change the configuration during runtime. This is done with the config get and config set .

To write any changes to the conf-file you can use config rewrite .