{
  "id": "migrate-shards",
  "title": "Migrate database shards",
  "url": "https://redis.io/docs/latest/operate/rs/7.8/databases/migrate-shards/",
  "summary": "How to migrate database shards to other nodes in a Redis Software cluster.",
  "content": "\nTo migrate database shards to other nodes in the cluster, you can use the [`rladmin migrate`]() command or [REST API requests]().\n\n## Use cases for shard migration\n\nMigrate database shards to a different node in the following scenarios:\n\n- Before node removal.\n\n- To balance the database manually in case of latency issues or uneven load distribution across nodes.\n\n- To manage node resources, such as memory usage.\n\n## Considerations for shard migration\n\nFor databases with replication:\n\n- Migrating a shard will not cause disruptions since a primary shard will still be available.\n\n- If you try to migrate a primary shard, it will be demoted to a replica shard and a replica shard will be promoted to primary before the migration. If you set `\"preserve_roles\": true` in the request, a second failover will occur after the migration finishes to change the migrated shard's role back to primary.\n\nFor databases without replication, the migrated shard will not be available until the migration is done.\n\nConnected clients shouldn't be disconnected in either case.\n\nIf too many primary shards are placed on the same node, it can impact database performance.\n\n## Migrate specific shard\n\nTo migrate a specific database shard, use one of the following methods:\n\n- [`rladmin migrate shard`]():\n\n    ```sh\n    rladmin migrate shard \u003cshard_id\u003e target_node \u003cnode_id\u003e\n    ```\n\n- [Migrate shard]() REST API request:\n\n    Specify the ID of the shard to migrate in the request path and the destination node's ID as the `target_node_uid` in the request body. See the [request reference]() for more options.\n\n    ```sh\n    POST /v1/shards/\u003cshard_id\u003e/actions/migrate\n    {\n        \"target_node_uid\": \u003cnode_id\u003e\n    }\n    ```\n\n    Example JSON response body:\n\n    ```json\n    {\n        \"action_uid\": \"\u003caction_id\u003e\",\n        \"description\": \"Migrate was triggered\"\n    }\n    ```\n\n    You can track the action's progress with a [`GET /v1/actions/\u003caction_uid\u003e`]() request.\n\n## Migrate multiple shards\n\nTo migrate multiple database shards, use one of the following methods:\n\n- [`rladmin migrate shard`]():\n\n    ```sh\n    rladmin migrate shard \u003cshard_id1\u003e \u003cshard_id2\u003e \u003cshard_id3\u003e target_node \u003cnode_id\u003e\n    ```\n\n- [Migrate multiple shards]() REST API request:\n\n    Specify the IDs of the shards to migrate in the `shard_uids` list and the destination node's ID as the `target_node_uid` in the request body. See the [request reference]() for more options.\n\n    ```sh\n    POST /v1/shards/actions/migrate\n    {\n        \"shard_uids\": [\"\u003cshard_id1\u003e\",\"\u003cshard_id2\u003e\",\"\u003cshard_id3\u003e\"],\n        \"target_node_uid\": \u003cnode_id\u003e\n    }\n    ```\n\n    Example JSON response body:\n\n    ```json\n    {\n        \"action_uid\": \"\u003caction_id\u003e\",\n        \"description\": \"Migrate was triggered\"\n    }\n    ```\n\n    You can track the action's progress with a [`GET /v1/actions/\u003caction_uid\u003e`]() request.\n\n## Migrate all shards from a node\n\nTo migrate all shards from a specific node to another node, run [`rladmin migrate all_shards`]():\n\n```sh\nrladmin migrate node \u003corigin_node_id\u003e all_shards target_node \u003cnode_id\u003e\n```\n\n## Migrate primary shards\n\nYou can use the [`rladmin migrate all_master_shards`]() command to migrate all primary shards for a specific database or node to another node in the cluster.\n\nTo migrate a specific database's primary shards:\n\n```sh\nrladmin migrate db db:\u003cid\u003e all_master_shards target_node \u003cnode_id\u003e\n```\n\nTo migrate all primary shards from a specific node:\n\n```sh\nrladmin migrate node \u003corigin_node_id\u003e all_master_shards target_node \u003cnode_id\u003e\n```\n\n## Migrate replica shards\n\nYou can use the [`rladmin migrate all_slave_shards`]() command to migrate all replica shards for a specific database or node to another node in the cluster.\n\nTo migrate a specific database's replica shards:\n\n```sh\nrladmin migrate db db:\u003cid\u003e all_slave_shards target_node \u003cnode_id\u003e\n```\n\nTo migrate all replica shards from a specific node:\n\n```sh\nrladmin migrate node \u003corigin_node_id\u003e all_slave_shards target_node \u003cnode_id\u003e\n```\n",
  "tags": ["docs","operate","rs"],
  "last_updated": "2026-04-01T08:10:08-05:00"
}

