Configuration
Concept
The entity model of Redis is almost the same as that of PostgreSQL, which also includes the concepts of Cluster and Instance. Note that 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. Of course, there are some limitations; for example, in this case, you cannot specify different passwords for different instances on the same node.
Choose the server implementation with redis_type: redis by default, or valkey. Set it consistently at cluster level. The role switches packages and the *-server / *-cli binaries while retaining /etc/redis, /data/redis, instance systemd unit names, and the redis monitoring namespace. Validate data compatibility and rollback independently before changing an existing cluster’s engine.
Identity Parameters
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, serves as the top-level namespace for cluster resources.redis_node: Redis node number, an integer unique within the cluster to distinguish different nodes.redis_instances: JSON object where keys are instance port numbers and values are JSON objects containing other instance configurations.
Redis Mode
There are three different working modes for Redis, specified by the redis_mode parameter:
standalone: Default standalone master-slave modecluster: Redis native distributed cluster modesentinel: Sentinel mode, providing high availability for standalone master-slave Redis
Here are three examples of Redis cluster definitions:
- 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
These examples omit redis_type and therefore use the default Redis engine. To deploy Valkey, add redis_type: valkey to the corresponding cluster’s vars; do not mix engines within one logical cluster.
Limitations
- 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 each 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 have different passwords (because redis_exporter only allows one password).
- Redis Cluster has built-in HA, while standalone master-slave HA requires additional manual configuration in Sentinel since we don’t know if you have deployed Sentinel.
- Fortunately, configuring HA for standalone Redis is straightforward through Sentinel. For details, see Administration - Configure HA with Sentinel.
Typical Configuration Examples
Here are some common Redis configuration examples for different scenarios:
Cache Cluster (Pure In-Memory)
For pure caching scenarios with no data persistence requirements:
Session Store Cluster
For web application session storage with some persistence needs:
Message Queue Cluster
For simple message queue scenarios requiring higher data reliability:
High Availability Master-Slave Cluster
Master-slave cluster with Sentinel automatic failover:
Large-Scale Native Cluster
For high-volume, high-throughput scenarios using native distributed cluster:
Security Hardening Configuration
Recommended security configuration for production environments: