Image Live-Migration

RBD images can be live-migrated between different pools within the same clusteror between different image formats and layouts. When started, the source imagewill be deep-copied to the destination image, pulling all snapshot history andoptionally keeping any link to the source image’s parent to help preservesparseness.

This copy process can safely run in the background while the new target image isin-use. There is currently a requirement to temporarily stop using the sourceimage before preparing a migration. This helps to ensure that the client usingthe image is updated to point to the new target image.

Note

Image live-migration requires the Ceph Nautilus release or later. The krbdkernel module does not support live-migration at this time.

Live-Migration - 图1

The live-migration process is comprised of three steps:

  • Prepare Migration: The initial step creates the new target image andcross-links the source and target images. Similar to layered images,attempts to read uninitialized extents within the target image willinternally redirect the read to the source image, and writes touninitialized extents within the target will internally deep-copy theoverlapping source image block to the target image.

  • Execute Migration: This is a background operation that deep-copies allinitialized blocks from the source image to the target. This step can berun while clients are actively using the new target image.

  • Finish Migration: Once the background migration process has completed,the migration can be committed or aborted. Committing the migration willremove the cross-links between the source and target images, and willremove the source image. Aborting the migration will remove the cross-links,and will remove the target image.

Prepare Migration

The live-migration process is initiated by running the _rbd migration prepare_command, providing the source and target images:

  1. $ rbd migration prepare migration_source [migration_target]

The rbd migration prepare command accepts all the same layout optionals as therbd create command, which allows changes to the immutable image on-disklayout. The migration_target can be skipped if the goal is only to change theon-disk layout, keeping the original image name.

All clients using the source image must be stopped prior to preparing alive-migration. The prepare step will fail if it finds any running clients withthe image open in read/write mode. Once the prepare step is complete, theclients can be restarted using the new target image name. Attempting to restartthe clients using the source image name will result in failure.

The rbd status command will show the current state of the live-migration:

  1. $ rbd status migration_target
  2. Watchers: none
  3. Migration:
  4. source: rbd/migration_source (5e2cba2f62e)
  5. destination: rbd/migration_target (5e2ed95ed806)
  6. state: prepared

Note that the source image will be moved to the RBD trash to avoid mistakenusage during the migration process:

  1. $ rbd info migration_source
  2. rbd: error opening image migration_source: (2) No such file or directory
  3. $ rbd trash ls --all
  4. 5e2cba2f62e migration_source

Execute Migration

After preparing the live-migration, the image blocks from the source imagemust be copied to the target image. This is accomplished by running therbd migration execute command:

  1. $ rbd migration execute migration_target
  2. Image migration: 100% complete...done.

The rbd status command will also provide feedback on the progress of themigration block deep-copy process:

  1. $ rbd status migration_target
  2. Watchers:
  3. watcher=1.2.3.4:0/3695551461 client.123 cookie=123
  4. Migration:
  5. source: rbd/migration_source (5e2cba2f62e)
  6. destination: rbd/migration_target (5e2ed95ed806)
  7. state: executing (32% complete)

Commit Migration

Once the live-migration has completed deep-copying all data blocks from thesource image to the target, the migration can be committed:

  1. $ rbd status migration_target
  2. Watchers: none
  3. Migration:
  4. source: rbd/migration_source (5e2cba2f62e)
  5. destination: rbd/migration_target (5e2ed95ed806)
  6. state: executed
  7. $ rbd migration commit migration_target
  8. Commit image migration: 100% complete...done.

If the migration_source image is a parent of one or more clones, the _–force_option will need to be specified after ensuring all descendent clone images arenot in use.

Committing the live-migration will remove the cross-links between the sourceand target images, and will remove the source image:

  1. $ rbd trash list --all

Abort Migration

If you wish to revert the prepare or execute step, run the _rbd migration abort_command to revert the migration process:

  1. $ rbd migration abort migration_target
  2. Abort image migration: 100% complete...done.

Aborting the migration will result in the target image being deleted and accessto the original source image being restored:

  1. $ rbd ls
  2. migration_source