Version v2.7.0 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot. For up-to-date documentation, see the latest version.
Module: REDIS
Concept
The entity model of Redis is almost the same as that of PostgreSQL, which also includes the concepts of Cluster and Instance. The Cluster here does not refer to the native Redis Cluster mode.
The core difference between the REDIS module and the PGSQL module is that Redis uses a single-node multi-instance deployment rather than the 1:1 deployment: multiple Redis instances are typically deployed on a physical/virtual machine node to utilize multi-core CPUs fully. Therefore, the ways to configure and administer Redis instances are slightly different from PGSQL.
In Redis managed by Pigsty, nodes are entirely subordinate to the cluster, which means that currently, it is not allowed to deploy Redis instances of two different clusters on one node. However, this does not affect deploying multiple independent Redis primary replica instances on one node.
Configuration
Redis Identity
Redis identity parameters are required parameters when defining a Redis cluster.
| Name | Attribute | Description | Example |
|---|---|---|---|
redis_cluster |
REQUIRED, cluster level | cluster name | redis-test |
redis_node |
REQUIRED, node level | Node Sequence Number | 1,2 |
redis_instances |
REQUIRED, node level | Instance Definition | { 6001 : {} ,6002 : {}} |
redis_cluster: Redis cluster name, top-level namespace for cluster sources.redis_node: Redis node identity, integer, and node number in the cluster.redis_instances: A Dict with the Key as redis port and the value as an instance level parameter.
Redis Mode
There are three redis_mode available in Pigsty:
standalone: setup Redis in standalone (master-slave) modecluster: setup this Redis cluster as a Redis native clustersentinel: setup Redis as a sentinel for standalone Redis HA
Redis Definition
Here are three examples:
- A 1-node, one master & one slave Redis Standalone cluster:
redis-ms - A 1-node, 3-instance Redis Sentinel cluster:
redis-sentinel - A 2-node, 6-instance Redis Cluster:
redis-cluster
Limitation
- A Redis node can only belong to one Redis cluster, which means you cannot assign a node to two different Redis clusters simultaneously.
- On each Redis node, you need to assign a unique port number to the Redis instance to avoid port conflicts.
- Typically, the same Redis cluster will use the same password, but multiple Redis instances on a Redis node cannot set different passwords (because redis_exporter only allows one password).
- Redis Cluster has built-in HA, while standalone HA requires manually configured in Sentinel because we are unsure if you have any sentinels available. Fortunately, configuring standalone Redis HA is straightforward: Configure HA with sentinel.
Administration
Here are some common administration tasks for Redis. Check FAQ: Redis for more details.
Init Redis
Init Cluster/Node/Instance
You can also use wrapper script:
Remove Redis
Remove Cluster/Node/Instance
You can also use wrapper script:
Reconfigure Redis
You can partially run redis.yml tasks to re-configure redis.
Beware that redis can not be reload online, you have to restart redis to make config effective.
Use Redis Client Tools
Access redis instance with redis-cli:
Redis also has a redis-benchmark which can be used for benchmark and generate load on redis server:
Configure Redis Replica
https://redis.io/commands/replicaof/
Configure HA with Sentinel
You have to enable HA for redis standalone m-s cluster manually with your redis sentinel.
Take the 4-node sandbox as an example, a redis sentinel cluster redis-meta is used manage the redis-ms standalone cluster.
If you wish to remove a redis master from sentinel, use SENTINEL REMOVE <name>.
You can configure multiple redis master on sentinel cluster with redis_sentinel_monitor.
And refresh master list on sentinel cluster with:
Playbook
There are two playbooks for redis:
redis.yml: create redis cluster / node / instanceredis-rm.yml: remove redis cluster /node /instance
redis.yml
The playbook redis.yml will init redis cluster/node/instance:
redis-rm.yml
The playbook redis-rm.yml will remove redis cluster/node/instance:
Dashboard
There are three dashboards for REDIS module.
Redis Overview: Overview of all Redis Instances
Redis Cluster : Overview of one single redis cluster
Redis Instance : Overview of one single redis cluster
Parameter
There 20 parameters in the redis module.
| Parameter | Type | Level | Comment |
|---|---|---|---|
redis_cluster |
string | C | redis cluster name, required identity parameter |
redis_instances |
dict | I | redis instances definition on this redis node |
redis_node |
int | I | redis node sequence number, node int id required |
redis_fs_main |
path | C | redis main data mountpoint, /data by default |
redis_exporter_enabled |
bool | C | install redis exporter on redis nodes? |
redis_exporter_port |
port | C | redis exporter listen port, 9121 by default |
redis_exporter_options |
string | C/I | cli args and extra options for redis exporter |
redis_safeguard |
bool | G/C/A | prevent purging running redis instance? |
redis_clean |
bool | G/C/A | purging existing redis during init? |
redis_rmdata |
bool | G/C/A | remove redis data when purging redis server? |
redis_mode |
enum | C | redis mode: standalone,cluster,sentinel |
redis_conf |
string | C | redis config template path, except sentinel |
redis_bind_address |
ip | C | redis bind address, empty string will use host ip |
redis_max_memory |
size | C/I | max memory used by each redis instance |
redis_mem_policy |
enum | C | redis memory eviction policy |
redis_password |
password | C | redis password, empty string will disable password |
redis_rdb_save |
string[] | C | redis rdb save directives, disable with empty list |
redis_aof_enabled |
bool | C | enable redis append only file? |
redis_rename_commands |
dict | C | rename redis dangerous commands |
redis_cluster_replicas |
int | C | replica number for one master in redis cluster |
redis_sentinel_monitor |
master[] | C | sentinel master list, sentinel cluster only |


