Redisシャーディング

 

https://changineer.info/server/nosql/nosql_redis_cluster.html
https://qiita.com/keitatata/items/44678ad472e61a4606c5

 

前提
OS : Rocky Linux 9.1
Redis version : 6.2.7

mmm191 : Redis master(Shard#1)
mmm192 : Redis master(Shard#2)
mmm193 : Redis master(Shard#3)


Note that the minimal cluster that works as expected must contain at least three master nodes.


-- 1. Redisインストール[mmm191,mmm192,mmm193で実施]

dnf install -y redis

redis-server --version


-- 2. Redisシャード設定[mmm191,mmm192,mmm193で実施]


vim /etc/redis/redis.conf


bind 127.0.0.1 -::1

bind 0.0.0.0


# cluster-enabled yes

cluster-enabled yes

# cluster-config-file nodes-6379.conf

cluster-config-file nodes-6379.conf

# cluster-node-timeout 15000

cluster-node-timeout 15000

appendonly no

appendonly yes

systemctl enable redis
systemctl restart redis
systemctl status redis

 

tail /var/log/redis/redis.log 


-- 3. Redisシャード構築[mmm191で実施]

redis-cli --cluster create \
192.168.137.191:6379 \
192.168.137.192:6379 \
192.168.137.193:6379 \
--cluster-replicas 0


redis-cli -c


cluster info
cluster nodes


-- 4. 動作確認[mmm191,mmm192,mmm193で実施]

redis-cli -c

set key1 val1
set key2 val2
set key3 val3

get key1
get key2
get key3