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.
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).
There different ways to access a config file:
You should add/modify the following parameters to your redis.conf:
daemonize
to yespidfile /var/run/redis.pid
: location of the pid-file (for multiple instances make sure to choose distinct names)port
to the used portloglevel
: debug/verbose/notice/warninglogfile /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
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
.