Redis

Redis is an open source, BSD licensed, advanced key-value cache and store. Redis is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, and bitmaps.

Install Redis

1. Download a version from Redis.io/downloads

2. Copy to /tmp

3. Unzip files (tar -xvf filename)

4. Enter into /tmp/redis-[version]

5. Type sudo make MALLOC=libc  (this compiles jemalloc as part of the make)

6. When that finishes (do not use make test as jemalloc breaks make test)

7. Create the install scripts:

sudo make install

8. enter utils:

cd utils

9. type sudo ./install_server.sh  (that will install binaries in /usr/local/bin and add startup scripts), accept defaults (this process starts redis, use defaults for all settings for redis port, redis config file, redis log file, and data directory)

Example defaults:

Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli

10. Confirm Redis is running: ps -ef | grep ‘redis-server’

11. quick test of redis:

a. type redis-cli

1.  prompt is 127.0.0.1:6379>

b. type ping

2. response is PONG

that should do it.

Install an Older Version of Redis

There are times when you need to install a previous version of Redis:


wget http://download.redis.io/releases/redis-2.8.21.tar.gz
tar xzf redis-2.8.21.tar.gz
cd redis-3.2.8
sudo make MALLOC=libc
sudo make install
util
./install_server.sh

Configure Redis

Retrieve Version

Run redis-cli to enter the Redis command-line utility, and type INFO to retrieve information on the running Redis server.

redis-server –version

Configuration File

/etc/redis/6379.conf

Change Default Port

  1. Locate your redis.conf file (it will probably be at /etc/redis/6379.conf).
  2. Copy the file or edit that one and change the port directive to any free port.
  3. Start Redis with the new config file (note that if you’ve copied the file in the previous step, you’ll need to change the service’s startup script to use that file).