From XennisWiki
Jump to: navigation, search

Redis is a software project that implements data structure servers. It is open-source, networked, in-memory, and stores keys with optional durability. (Wikipedia)


Arch Linux

Install the redis package.


Install redis-cli
apt-get install redis-tools
Install redis server
apt-get install redis-server

Use Docker container

Further information: Docker Hub Redis Container, redis-cli, the Redis command line interface

Pull the Redis container

docker pull redis

Run the container as some-redis and bind the exposed port 6379 to 6000 at localhost

docker run --name some-redis -d -p redis

Use redis-cli to ping the redis

redis-cli -p 6000 ping

Basic usage

Open a Redis command line (for instance with the argument port 6000)

redis-cli -p 6000> ping 
PONG> SET name "test" 
OK> GET name 
"test"> KEYS "*"
1) "name"> DEL name
(integer) 1

(1) Show information (statistic), (2) Output number of keys in server, (3) crash the server for debugging by executing an invalid memory access and (4) delete all keys



Start to monitor Redis

redis-cli -p 6000 monitor

Exemplary output of the monitor

1490176137.196157 [0] "ping"
1490176138.796191 [0] "SET" "name" "test"
1490176141.372171 [0] "GET" "name"
1490176143.564055 [0] "KEYS" "*"


Run a benchmark with 1000 number of parallel connections (clients), 600000 total number of requests and 5000 bytes payload. The benchmark tests in this case set and get operations.

redis-benchmark -c 1000 -n 600000 -r 600000 -d 5000 -t set,get

Number of clients

Further information: Redis Clients Handling

Redis sets the maximum of clients to 100000 b default. To increase the maximum start the server with the argument --maxclients 100000. Linux limits the number of open files. To output the limit execute ulimit -n. Increase the limit of open files by:

ulimit -n 50000

(To increase the number of file you maybe have to set sudo sysctl -w fs.file-max=65536 as well. Get the current value by cat /proc/sys/fs/file-max.)


Monitor without default messages

redis-cli monitor | grep --line-buffered -Ev "PING|PONG|INFO|sentinel"

Sentinal: Figure out master name

In the sentinel.conf is entry like

sentinel monitor my-master 6379 2

The format is

sentinel monitor <master-name> <master-ip> <master-port> <failover-quorum>

Problems and errors

Misconf RDB snapshots

Error message
(error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
$ redis-cli
> config set stop-writes-on-bgsave-error no

NOAUTH Authentication required

Error message
(error) NOAUTH Authentication required.
> auth <password>

External links