Module: REDIS

Deploy redis in standalone, cluster or sentinel mode.


Configuration

Redis Identity

Redis identity parameters are required parameters when defining a Redis cluster.

NameAttributeDescriptionExample
redis_clusterREQUIRED, cluster levelcluster nameredis-test
redis_nodeREQUIRED,node levelNode Sequence Number1,2
redis_instancesREQUIRED,node levelInstance Definition{ 6001 : {} ,6002 : {}}
  • redis_cluster: Redis cluster name, top-level namespace for cluster sources.
  • redis_node: Redis node identity, integer the number of the node in the cluster.
  • redis_instances: A Dict with the Key as redis port and the value as a instance level parameters.

Redis Mode

There are three redis_mode available in Pigsty:

  • standalone: setup redis as standalone (master-slave) mode
  • cluster: setup this redis cluster as a redis native cluster
  • sentinel: setup redis as sentinel for standalone redis HA

Redis Definition

Here are three examples:

  1. redis-ms: # redis classic primary & replica
  2. hosts: { 10.10.10.10: { redis_node: 1 , redis_instances: { 6501: { }, 6502: { replica_of: '10.10.10.10 6501' } } } }
  3. vars: { redis_cluster: redis-ms ,redis_max_memory: 64MB }
  4. redis-meta: # redis sentinel x 3
  5. hosts: { 10.10.10.11: { redis_node: 1 , redis_instances: { 6001: { } ,6002: { } , 6003: { } } } }
  6. vars: { redis_cluster: redis-meta, redis_mode: sentinel ,redis_max_memory: 16MB }
  7. redis-test: # redis native cluster: 3m x 3s
  8. hosts:
  9. 10.10.10.12: { redis_node: 1 ,redis_instances: { 6501: { } ,6502: { } ,6503: { } } }
  10. 10.10.10.13: { redis_node: 2 ,redis_instances: { 6501: { } ,6502: { } ,6503: { } } }
  11. vars: { redis_cluster: redis-test ,redis_mode: cluster, redis_max_memory: 32MB }

Limitation

  • A redis node can only belong to one redis cluster
  • You can not set different password for redis instances on same redis node (since redis_exporter only allows one password)

Playbook

There are two playbooks for redis:

You can also create & destroy redis cluster/node/instance with util scripts:

  1. bin/redis-add redis-ms # create redis cluster 'redis-ms'
  2. bin/redis-add 10.10.10.10 # create redis node '10.10.10.10'
  3. bin/redis-add 10.10.10.10 6501 # create redis instance '10.10.10.10:6501'
  4. bin/redis-rm redis-ms # remove redis cluster 'redis-ms'
  5. bin/redis-rm 10.10.10.10 # remove redis node '10.10.10.10'
  6. bin/redis-rm 10.10.10.10 6501 # remove redis instance '10.10.10.10:6501'

Administration

Init Cluster/Node/Instance

  1. # init all redis instances on group <cluster>
  2. ./redis.yml -l <cluster> # create redis cluster
  3. # init redis node (package,dir,exporter)
  4. ./redis.yml -l 10.10.10.10 # create redis cluster
  5. # init all redis instances specific node
  6. ./redis.yml -l 10.10.10.10 # create redis cluster
  7. # init one specific instance 10.10.10.11:6501
  8. ./redis.yml -l 10.10.10.11 -e redis_port=6501 -t redis

You can also use wrapper script:

  1. bin/redis-add redis-ms # create redis cluster 'redis-ms'
  2. bin/redis-add 10.10.10.10 # create redis node '10.10.10.10'
  3. bin/redis-add 10.10.10.10 6501 # create redis instance '10.10.10.10:6501'

Remove Cluster/Node/Instance

  1. # Remove cluster `redis-test`
  2. redis-rm.yml -l redis-test
  3. # Remove cluster `redis-test`, and uninstall packages
  4. redis-rm.yml -l redis-test -e redis_uninstall=true
  5. # Remove all instance on redis node 10.10.10.13
  6. redis-rm.yml -l 10.10.10.13
  7. # Remove one specific instance 10.10.10.13:6501
  8. redis-rm.yml -l 10.10.10.13 -e redis_port=6501

You can also use wrapper script:

  1. bin/redis-rm redis-ms # remove redis cluster 'redis-ms'
  2. bin/redis-rm 10.10.10.10 # remove redis node '10.10.10.10'
  3. bin/redis-rm 10.10.10.10 6501 # remove redis instance '10.10.10.10:6501'

Dashboards

There are three dashboards for REDIS module.

Redis Overview

Overview of all Redis Instances

Module: REDIS - 图1

Redis Cluster

Overview of a redis cluster

Module: REDIS - 图2

Redis Instance

Detail information about a single redis instance

Module: REDIS - 图3


Parameters

There are 3 sections, 20 parameters about REDIS module.

ParameterTypeLevelComment
redis_clusterstringCredis cluster name, required identity parameter
redis_instancesdictIredis instances definition on this redis node
redis_nodeintIredis node sequence number, node int id required
redis_fs_mainpathCredis main data mountpoint, /data by default
redis_exporter_enabledboolCinstall redis exporter on redis nodes?
redis_exporter_portportCredis exporter listen port, 9121 by default
redis_exporter_optionsstringC/Icli args and extra options for redis exporter
redis_safeguardboolCprevent purging running redis instance?
redis_cleanboolCpurging existing redis during init?
redis_rmdataboolAremove redis data when purging redis server?
redis_modeenumCredis mode: standalone,cluster,sentinel
redis_confstringCredis config template path, except sentinel
redis_bind_addressipCredis bind address, empty string will use host ip
redis_max_memorysizeC/Imax memory used by each redis instance
redis_mem_policyenumCredis memory eviction policy
redis_passwordpasswordCredis password, empty string will disable password
redis_rdb_savestring[]Credis rdb save directives, disable with empty list
redis_aof_enabledboolCenable redis append only file?
redis_rename_commandsdictCrename redis dangerous commands
redis_cluster_replicasintCreplica number for one master in redis cluster

Last modified 2023-02-27: add v2.0 images and docs (5b09f12)