redis集群扩容

redis集群扩容

一:扩容须要考虑的问题node

1.迁移时槽的数据会不会迁过去redis

2.迁移过程集群读写受影响吗ide

3.须要限速吗设计

4.如何确保迁移后的完整性server

二:如何设计扩容确保迁移过程当中数据不会受影响?blog

1.迁移过程当中,一个窗口读数据,一个窗口写数据get

2.观察是否会中断hash

三:建立新的节点it

mkdir -p /opt/redis_{6390,6391}/{conf,logs,pid}class

mkdir -p /data/redis_{6390,6391}

cd /opt/

cp redis_6380/conf/redis_6380.conf  redis_6390/conf/redis_6390.conf

cp redis_6380/conf/redis_6380.conf redis_6391/conf/redis_6391.conf

sed -i 's#6380#6390#g' redis_6390/conf/redis_6390.conf

sed -i 's#6380#6391#g' redis_6391/conf/redis_6391.conf

redis-server /opt/redis_6390/conf/redis_6390.conf

redis-server /opt/redis_6391/conf/redis_6391.conf

ps -ef|grep redis

redis-cli -c -h 10.0.0.101 -p 6380 cluster meet 10.0.0.101 6390

redis-cli -c -h 10.0.0.101 -p 6380 cluster meet 10.0.0.101 6391

redis-cli -c -h 10.0.0.101 -p 6380 cluster nodes

四:扩容步骤

#从新分配槽位
redis-cli --cluster reshard 10.0.0.101:6380

#第一次交互:每一个节点最终分配多少个槽
How many slots do you want to move (from 1 to 16384)? 4096

#第二次交互:接受节点的ID
What is the receiving node ID? 6390的ID

#第三次交互:哪些节点须要导出
Please enter all the source node IDs.
Type 'all' to use all the nodes as source nodes for the hash slots.
Type 'done' once you entered all the source nodes IDs.
Source node #1:all

#第四次交互:确认信息
Do you want to proceed with the proposed reshard plan (yes/no)? yes

#验证迁移数据的过程当中数据是否会中断

写命令
for i in {1..1000};do redis-cli -c -h 10.0.0.101 -p 6380 set k_${i} v_${i} && echo ${i} is ok;sleep 0.5;done
读命令
for i in {1..1000};do redis-cli -c -h 10.0.0.101 -p 6380 get k_${i};sleep 0.5;done

 #检查扩容后集群状态

redis-cli --cluster info 10.0.0.101:6380

 

相关文章
相关标签/搜索