mkdir redis-cluster-playground
cd redis-cluster-playground
mkdir 7000 7001 7002 7003 7004 7005
分别在 7000 、7001 、7002 、7003 、 7004 和 7005 的文件夹下创建 redis.conf
:
port 7000
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes
将 port
修改为对应的文件夹名,启动多个 terminal ,执行 redis-server ./redis.conf
。
需要通过 Redis CLI 初始化集群信息,首先安装脚本:
gem install redis
然后初始化 Redis 集群:
redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 \
127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 \
--cluster-replicas 1
是否应用集群配置,填入 yes
:
Can I set the above configuration? (type 'yes' to accept): yes
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
网友评论