Back to Redis

Migrate

content/operate/rs/references/rest-api/requests/shards/actions/migrate.md

latest5.8 KB
Original Source
MethodPathDescription
POST/v1/shards/actions/migrateMigrate multiple shards
POST/v1/shards/{uid}/actions/migrateMigrate a specific shard

Migrate multiple shards {#post-multi-shards}

POST /v1/shards/actions/migrate

Migrates the list of given shard UIDs to the node specified by target_node_uid. The shards can be from multiple databases. This request is asynchronous.

For more information about shard migration use cases and considerations, see [Migrate database shards]({{<relref "/operate/rs/databases/migrate-shards">}}).

Required permissions

Permission nameRoles
[migrate_shard]({{< relref "/operate/rs/references/rest-api/permissions#migrate_shard" >}})admin
cluster_member
db_member

Request {#post-multi-request}

Example HTTP request

POST /v1/shards/actions/migrate

Example JSON body

json
{
  "shard_uids": ["2","4","6"],
  "target_node_uid": 9,
  "override_rack_policy": false,
  "preserve_roles": false,
  "max_concurrent_bdb_migrations": 3
}

Request headers

KeyValueDescription
Hostcnm.cluster.fqdnDomain name
Acceptapplication/jsonAccepted media type

Request body {#post-multi-request-body}

The request body is a JSON object that can contain the following fields:

FieldTypeDescription
shard_uidsarray of stringsList of shard UIDs to migrate.
target_node_uidintegerUID of the node to where the shards should migrate.
override_rack_policybooleanIf true, overrides and ignores rack-aware policy violations.
dry_runbooleanDetermines whether the migration is actually done. If true, will just do a dry run. If the dry run succeeds, the request returns a 200 OK status code. Otherwise, it returns a JSON object with an error code and description.
preserve_rolesbooleanIf true, preserves the migrated shards' roles after migration.
max_concurrent_bdb_migrationsintegerThe number of concurrent databases that can migrate shards.

Response {#post-multi-response}

Returns a JSON object with an action_uid. You can track the action's progress with a [GET /v1/actions/<action_uid>]({{<relref "/operate/rs/references/rest-api/requests/actions#get-action">}}) request.

Example JSON body

json
{
    "action_uid": "e5e24ddf-a456-4a7e-ad53-4463cd44880e",
    "description": "Migrate was triggered"
}

Status codes {#post-multi-status-codes}

CodeDescription
200 OKNo error.
400 Bad RequestConflicting parameters.
404 Not FoundA list of shard UIDs is required and not given, a specified shard does not exist, or a node UID is required and not given.
500 Internal Server ErrorMigration failed.

Migrate shard {#post-shard}

POST /v1/shards/{int: uid}/actions/migrate

Migrates the shard with the given shard_uid to the node specified by target_node_uid. If the shard is already on the target node, nothing happens. This request is asynchronous.

For more information about shard migration use cases and considerations, see [Migrate database shards]({{<relref "/operate/rs/databases/migrate-shards">}}).

Required permissions

Permission nameRoles
[migrate_shard]({{< relref "/operate/rs/references/rest-api/permissions#migrate_shard" >}})admin
cluster_member
db_member

Request {#post-request}

Example HTTP request

POST /v1/shards/1/actions/migrate

Example JSON body

json
{
    "target_node_uid": 9,
    "override_rack_policy": false,
    "preserve_roles": false
}

Request headers

KeyValueDescription
Hostcnm.cluster.fqdnDomain name
Acceptapplication/jsonAccepted media type

URL parameters

FieldTypeDescription
uidintegerThe unique ID of the shard to migrate.

Request body {#post-request-body}

The request body is a JSON object that can contain the following fields:

FieldTypeDescription
target_node_uidintegerUID of the node to where the shard should migrate.
override_rack_policybooleanIf true, overrides and ignores rack-aware policy violations.
dry_runbooleanDetermines whether the migration is actually done. If true, will just do a dry run. If the dry run succeeds, the request returns a 200 OK status code. Otherwise, it returns a JSON object with an error code and description.
preserve_rolesbooleanIf true, preserves the migrated shards' roles after migration.

Response {#post-response}

Returns a JSON object with an action_uid. You can track the action's progress with a [GET /v1/actions/<action_uid>]({{<relref "/operate/rs/references/rest-api/requests/actions#get-action">}}) request.

Example JSON body

json
{
    "action_uid": "e5e24ddf-a456-4a7e-ad53-4463cd44880e",
    "description": "Migrate was triggered"
}

Status codes {#post-status-codes}

CodeDescription
200 OKNo error.
404 Not FoundShard does not exist, or node UID is required and not given.
409 ConflictDatabase is currently busy.