Redis Deploy

You can use pigsty to deploy & monitoring database like redis

Pigsty is a PostgreSQL distribution and a general-purpose application runtime. It can manage, deploy, and monitor other applications and databases, such as Redis.

Similar to PostgreSQL, deploying Redis requires the same two steps.

  1. Declare/Define the Redis cluster
  2. Execute Playbook to create the Redis cluster

Define Redis Cluster

ER Model

The Redis entity concept model is almost identical to PostgreSQL and includes the Cluster and Instance. Note that Cluster here does not refer to the clusters in Redis’ native clusters.

The core difference is that Redis typically uses multiple singleton instances, with various Redis instances typically deployed on a single physical/VM to take advantage of multi-core CPUs.

In Pigsty-managed Redis, it is not yet possible to deploy two Redis instances from different clusters on a node, but this does not affect the deployment of multiple independent Redis instances on a node.

Identity Parameters

The identity parameters are the information that must be provided when defining a Redis cluster and include.

NameAttributeDescriptionExample
redis_clusterMUST, cluster levelCluster nameredis-test
redis_nodeMUST, node levelNode Number1,2
redis_instancesMUST, node levelInstance Definition{ 6001 : {} ,6002 : {}}
  • redis_cluster: Identifies the Redis cluster name, configured at the cluster level, as the top-level namespace for cluster resources.

  • redis_node: Identifies the number of the node in the cluster.

  • redis_instances: A JSON object with the Key as the instance port and the Value as a JSON object containing the instance-specific configuration.

Cluster Definition

A condensed definition of three Redis clusters is given below, including.

  • A 1-node, 3-instance Redis Sentinel cluster redis-sentinel.
  • A 2-node, 12-instance Redis Cluster redis-cluster.
  • A 1-node, one primary & two replicas Redis Standalone cluster redis-standalone.

It would help to assign a unique port to the Redis instance on the node.

Redis Sentinel Cluster Example

  1. #----------------------------------#
  2. # redis sentinel example #
  3. #----------------------------------#
  4. redis-meta:
  5. hosts:
  6. 10.10.10.10:
  7. redis_node: 1
  8. redis_instances: { 6001 : {} ,6002 : {} , 6003 : {} }
  9. vars:
  10. redis_cluster: redis-meta
  11. redis_mode: sentinel
  12. redis_max_memory: 128MB

Redis Native Cluster Example

  1. #----------------------------------#
  2. # redis native cluster example #
  3. #----------------------------------#
  4. redis-test:
  5. hosts:
  6. 10.10.10.11:
  7. redis_node: 1
  8. redis_instances: { 6501 : {} ,6502 : {} ,6503 : {} ,6504 : {} ,6505 : {} ,6506 : {} }
  9. 10.10.10.12:
  10. redis_node: 2
  11. redis_instances: { 6501 : {} ,6502 : {} ,6503 : {} ,6504 : {} ,6505 : {} ,6506 : {} }
  12. vars:
  13. redis_cluster: redis-test # name of this redis 'cluster'
  14. redis_mode: cluster # standalone,cluster,sentinel
  15. redis_max_memory: 64MB # max memory used by each redis instance
  16. redis_mem_policy: allkeys-lru # memory eviction policy

Redis Standalone Example

  1. #----------------------------------#
  2. # redis standalone example #
  3. #----------------------------------#
  4. redis-common:
  5. hosts:
  6. 10.10.10.13:
  7. redis_node: 1
  8. redis_instances:
  9. 6501: {}
  10. 6502: { replica_of: '10.10.10.13 6501' }
  11. 6503: { replica_of: '10.10.10.13 6501' }
  12. vars:
  13. redis_cluster: redis-common # name of this redis 'cluster'
  14. redis_mode: standalone # standalone,cluster,sentinel
  15. redis_max_memory: 64MB # max memory used by each redis instance

Create Redis Cluster

Playbook

Create a Redis instance/cluster using the playbook redis.yml.

  1. ./redis.yml -l redis-sentinel
  2. ./redis.yml -l redis-cluster
  3. ./redis.yml -l redis-standalone

Caveat

Although not recommended, it is still possible to deploy a mix of PostgreSQL and Redis to make the most of machine resources.

The redis.yml playbook will deploy the Redis Monitor Exporter on the machine, including redis_exporter and node_exporter (optional).

If the machine’s node_exporter exists during this process, it will be redeployed.

By default, Prometheus will use the “multi-target crawl” mode, using the Redis Exporter on port 9121 on the node to crawl all Redis instances on that node.

Checking Redis Monitor

Pigsty currently provides three Redis monitor dashboards as part of a standalone monitoring application REDIS.

  • Redis Overview: Provide a global overview of Redis in the entire environment.
  • Redis Cluster: Focus on monitoring information for a single Redis business cluster.
  • Redis Instance: Focus on detailed monitoring information for a single Redis instance.

You can use the included Redis-benchmark test.

Other Functions

Pigsty v1.4 only provides Redis cluster deployment and monitoring capabilities globally. In subsequent versions, such as capacity expansion, capacity reduction, and singleton instance management will be provided.

Last modified 2022-06-04: fii en docs batch 2 (61bf601)