Redis Cluster는 master를 여러 개 두어 분산 저장(sharding)이 가능하며, Scale-out이 가능합니다.
최소 3개의 Master Node가 있어야 구성 가능하며, Sentinel 과 달리 모든 node가 서로 감시하며 failover를 조치합니다.
Helm installation
helm repo add bitnami <https://charts.bitnami.com/bitnami>
helm fetch bitnami/redis-cluster --untar
cd redis-cluster
ls
values.yaml 수정
vi values.yaml
---
global:
...
defaultStorageClass: nfs
storageClass: nfs
redis:
password: "[YOUR_REDIS_PASSWORD]"
persistence:
...
## @param persistence.storageClass Storage class of backing PVC
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
storageClass: nfs
## @param persistence.size Size of data volume
##
size: 50Gi
ConfigMap 수정
vi templates/configmap.yaml
---
maxmemory 8000M
maxmemory-policy volatile-lr
helm install redis-cluster . --namespace redis --create-namespace
kubectl logs -f -nredis redis-cluster-0
Connect Redis
kubectl exec -it -nredis redis-cluster-0 -- redis-cli
127.0.0.1:6379> auth [YOUR_REDIS_PASSWORD]
OK
> info
...
# Replication
role:master
connected_slaves:1
slave0:ip=10.10.171.119,port=6379,state=online,offset=36414,lag=0
master_failover_state:no-failover
master_replid:6f407dd3626f9963acd97e1c4e629a968d864409
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:36414
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:36414
...
# Cluster
cluster_enabled:1
Key 삽입
kubectl exec -it -nredis redis-cluster-0 -- redis-cli -c
127.0.0.1:6379> SET test 1
-> Redirected to slot [6918] located at 10.10.219.110:6379
OK
10.10.219.110:6379> KEYS *
1) "test"
'Redis' 카테고리의 다른 글
Redis의 LFU 정책 (0) | 2024.10.12 |
---|---|
Redis의 LRU 정책 (6) | 2024.10.12 |
Redis Value 최대 크기 (0) | 2024.10.12 |
음성 합성 모델(TTS) 서빙을 Redis를 활용해 효율적으로 서비스하기 (0) | 2024.10.12 |
Redis Insight Kubernetes 배포 (0) | 2024.08.18 |