You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

创建Redis集群后出现migrating与importing状态异常问题求助

Troubleshooting Redis Cluster Migrating/Importing State Issues

Hey there, let's work through this Redis cluster problem together. First, let's confirm your cluster node details as you provided:

M: dbaf0a596c4f5a2f4ac1d9de2ed5c117f201d26d localhost:9501 slots:5461-10922 (5462 slots) master 2 additional replica(s)
S: a375ec8221f9872f8f287bca8a67fcef701cef72 localhost:9000 slots: (0 slots) slave replicates dbaf0a596c4f5a2f4ac1d9de2ed5c117f201d26d
S: a319a75ac0ee58484e345d7996a6712335ebddf5 localhost:9001 slots: (0 slots) slave replicates dbaf0a596c4f5a2f4ac1d9de2ed5c117f201d26d
M: 05f7d7cc87b417ad4bdf61b3877a674d54c02ef7 localhost:9002 slots:10923-16383 (5461 slots)...

Now, let's dive into fixing those stuck migrating/importing slot states. Here's a step-by-step approach:

1. Verify Node Connectivity & Health

First, make sure all cluster nodes are online and can communicate with each other:

  • Test each node with redis-cli -p <port> ping – you should get a PONG response from every node.
  • Double-check that both the Redis service port (e.g., 9501, 9000) and the cluster bus port (service port + 10000, e.g., 19501, 19000) are open in firewalls/security groups. Network blocks are a common cause of stuck migrations.

2. Identify Stuck Slots

Run redis-cli -p <any-cluster-port> cluster nodes and look for entries marked with migrating or importing to note exactly which slots are in an abnormal state. You can also get more details with:

  • For a source node (migrating slot): redis-cli -p <source-port> cluster getkeysinslot <slot> 10 – this shows remaining keys in the slot that haven't migrated.
  • For a destination node (importing slot): redis-cli -p <dest-port> cluster countkeysinslot <slot> – this counts keys already imported to the target.

3. Clear Abnormal Slot States

If the migration was interrupted or isn't progressing, you can reset the slot to a stable state:

  • On the source node (where the slot is marked migrating):
    redis-cli -p <source-port> cluster setslot <slot-number> stable
    
  • On the destination node (where the slot is marked importing):
    redis-cli -p <dest-port> cluster setslot <slot-number> stable
    

After running these, recheck the cluster nodes output to confirm the slots are no longer in migrating/importing states.

4. Resolve Underlying Migration Issues

If you intended to migrate the slots (and the stuck state was accidental), address the root cause before retrying:

  • Check node logs (usually redis-server.log in your Redis config directory) for errors like connection timeouts, authentication failures, or key migration errors. Fix these first.
  • Ensure all nodes are running the same Redis version – version mismatches can cause unexpected migration failures.
  • If nodes are under heavy load, wait for traffic to drop before retrying migrations, as high CPU/memory usage can slow or halt slot transfers.

5. Retry Slot Migration (If Needed)

Once the cluster is stable and underlying issues are fixed, you can re-initiate the slot migration using:

redis-cli --cluster reshard <any-node-host>:<port>

Follow the interactive prompts to specify the target node, number of slots to move, and source nodes. Make sure to let the process complete without interrupting it.

6. Validate Cluster Health

Finally, confirm the cluster is fully healthy with:

redis-cli --cluster check <any-node-host>:<port>

This will verify all slots are assigned, no abnormal states exist, and replicas are synced correctly.


内容的提问来源于stack exchange,提问作者youngchw

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:40:29