Choose the appropriate Redis mode for your use case and express your requirements through the inventory
Concept
The Redis entity model is similar to the PostgreSQL model. It includes Cluster and Instance entities. Here, Cluster does not mean native Redis Cluster mode.
REDIS uses a single-node multi-instance deployment. PGSQL uses a 1:1 deployment. Multiple Redis instances typically share one physical or virtual node to use multiple CPU cores. Thus, the procedures to configure and administer Redis instances differ slightly from PGSQL.
In Pigsty, each Redis node belongs to one cluster. You cannot deploy instances from two different Redis clusters on the same node.
You can still deploy multiple independent Redis primary-replica instances on one node. Some restrictions apply. For example, instances on the same node cannot use different passwords.
Choose the server implementation with redis_type: redis by default, or valkey. Set it consistently at cluster level. The role changes packages and the *-server / *-cli binaries. It retains /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.
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 mode
cluster: Redis native distributed cluster mode
sentinel: 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
redis-ms:# redis classic primary & replicahosts:{10.10.10.10:{redis_node:1 , redis_instances:{6379:{}, 6380:{replica_of:'10.10.10.10 6379'}}}}vars:{redis_cluster:redis-ms ,redis_password:'redis.ms' ,redis_max_memory:64MB }redis-meta:# redis sentinel x 3hosts:{10.10.10.11:{redis_node:1 , redis_instances:{26379:{} ,26380:{} ,26381:{}}}}vars:redis_cluster:redis-metaredis_password:'redis.meta'redis_mode:sentinelredis_max_memory:16MBredis_sentinel_monitor:# primary list for redis sentinel, use cls as name, primary ip:port- {name:redis-ms, host:10.10.10.10, port:6379 ,password:redis.ms, quorum:2}redis-test:# redis native cluster: 3m x 3shosts:10.10.10.12:{redis_node:1 ,redis_instances:{6379:{} ,6380:{} ,6381:{}}}10.10.10.13:{redis_node:2 ,redis_instances:{6379:{} ,6380:{} ,6381:{}}}vars:{redis_cluster:redis-test ,redis_password:'redis.test' ,redis_mode:cluster, redis_max_memory:32MB }
These examples omit redis_type and therefore use the default Redis engine. To deploy Valkey, add redis_type: valkey to the cluster’s vars. Do not mix engines within one logical cluster.
Limitations
A Redis node can belong to only one Redis cluster. You cannot assign it to two clusters at the same time.
On each Redis node, you need to assign a unique port number to each Redis instance to avoid port conflicts.
A Redis cluster typically uses the same password for all instances. All instances on one node must share a password because redis_exporter supports only one.
Redis Cluster includes HA. For standalone master-slave HA, configure Sentinel manually. Pigsty does not know whether you have deployed Sentinel.
For web application session storage with some persistence needs:
redis-session:hosts:10.10.10.10:{redis_node:1 , redis_instances:{6379:{}, 6380:{replica_of:'10.10.10.10 6379'}}}vars:redis_cluster:redis-sessionredis_password:'session.password'redis_max_memory:1GBredis_mem_policy:volatile-lru # only evict keys with expire setredis_rdb_save:['300 1']# save every 5 minutes if at least 1 changeredis_aof_enabled:false
Message Queue Cluster
For simple message queue scenarios requiring higher data reliability:
redis-queue:hosts:10.10.10.10:{redis_node:1 , redis_instances:{6379:{}, 6380:{replica_of:'10.10.10.10 6379'}}}vars:redis_cluster:redis-queueredis_password:'queue.password'redis_max_memory:4GBredis_mem_policy:noeviction # reject writes when memory full, don't evictredis_rdb_save:['60 1']# save every minute if at least 1 changeredis_aof_enabled:true# enable AOF for better persistence
High Availability Master-Slave Cluster
Master-slave cluster with Sentinel automatic failover:
For high-volume, high-throughput scenarios using native distributed cluster:
redis-cluster:hosts:10.10.10.10:{redis_node:1 , redis_instances:{6379:{}, 6380:{}, 6381:{}}}10.10.10.11:{redis_node:2 , redis_instances:{6379:{}, 6380:{}, 6381:{}}}10.10.10.12:{redis_node:3 , redis_instances:{6379:{}, 6380:{}, 6381:{}}}10.10.10.13:{redis_node:4 , redis_instances:{6379:{}, 6380:{}, 6381:{}}}vars:redis_cluster:redis-clusterredis_password:'cluster.password'redis_mode:clusterredis_cluster_replicas:1# 1 replica per primary shardredis_max_memory:16GB # max memory per instanceredis_rdb_save:['900 1']redis_aof_enabled:false# This creates a 6-primary, 6-replica native cluster# Total capacity ~96GB (6 * 16GB)
Security Hardening Configuration
Recommended security configuration for production environments:
redis-secure:hosts:10.10.10.10:{redis_node:1 , redis_instances:{6379:{}}}vars:redis_cluster:redis-secureredis_password:'StrongP@ssw0rd!'# use strong passwordredis_bind_address:''# bind to internal IP instead of 0.0.0.0redis_max_memory:4GBredis_rename_commands:# rename dangerous commandsFLUSHDB:'DANGEROUS_FLUSHDB'FLUSHALL:'DANGEROUS_FLUSHALL'DEBUG:''# disable commandCONFIG:'ADMIN_CONFIG'