5 .. index:: Ceph Block Device; live-migration
7 RBD images can be live-migrated between different pools within the same cluster
8 or between different image formats and layouts. When started, the source image
9 will be deep-copied to the destination image, pulling all snapshot history and
10 optionally keeping any link to the source image's parent to help preserve
13 This copy process can safely run in the background while the new target image is
14 in-use. There is currently a requirement to temporarily stop using the source
15 image before preparing a migration. This helps to ensure that the client using
16 the image is updated to point to the new target image.
19 Image live-migration requires the Ceph Nautilus release or later. The krbd
20 kernel module does not support live-migration at this time.
25 +-------------+ +-------------+
27 | Live | Target refers | Live |
28 | migration |<-------------*| migration |
29 | source | to Source | target |
31 | (read only) | | (writable) |
32 +-------------+ +-------------+
36 The live-migration process is comprised of three steps:
38 #. **Prepare Migration:** The initial step creates the new target image and
39 cross-links the source and target images. Similar to `layered images`_,
40 attempts to read uninitialized extents within the target image will
41 internally redirect the read to the source image, and writes to
42 uninitialized extents within the target will internally deep-copy the
43 overlapping source image block to the target image.
46 #. **Execute Migration:** This is a background operation that deep-copies all
47 initialized blocks from the source image to the target. This step can be
48 run while clients are actively using the new target image.
51 #. **Finish Migration:** Once the background migration process has completed,
52 the migration can be committed or aborted. Committing the migration will
53 remove the cross-links between the source and target images, and will
54 remove the source image. Aborting the migration will remove the cross-links,
55 and will remove the target image.
60 The live-migration process is initiated by running the `rbd migration prepare`
61 command, providing the source and target images::
63 $ rbd migration prepare migration_source [migration_target]
65 The `rbd migration prepare` command accepts all the same layout optionals as the
66 `rbd create` command, which allows changes to the immutable image on-disk
67 layout. The `migration_target` can be skipped if the goal is only to change the
68 on-disk layout, keeping the original image name.
70 All clients using the source image must be stopped prior to preparing a
71 live-migration. The prepare step will fail if it finds any running clients with
72 the image open in read/write mode. Once the prepare step is complete, the
73 clients can be restarted using the new target image name. Attempting to restart
74 the clients using the source image name will result in failure.
76 The `rbd status` command will show the current state of the live-migration::
78 $ rbd status migration_target
81 source: rbd/migration_source (5e2cba2f62e)
82 destination: rbd/migration_target (5e2ed95ed806)
85 Note that the source image will be moved to the RBD trash to avoid mistaken
86 usage during the migration process::
88 $ rbd info migration_source
89 rbd: error opening image migration_source: (2) No such file or directory
91 5e2cba2f62e migration_source
97 After preparing the live-migration, the image blocks from the source image
98 must be copied to the target image. This is accomplished by running the
99 `rbd migration execute` command::
101 $ rbd migration execute migration_target
102 Image migration: 100% complete...done.
104 The `rbd status` command will also provide feedback on the progress of the
105 migration block deep-copy process::
107 $ rbd status migration_target
109 watcher=1.2.3.4:0/3695551461 client.123 cookie=123
111 source: rbd/migration_source (5e2cba2f62e)
112 destination: rbd/migration_target (5e2ed95ed806)
113 state: executing (32% complete)
119 Once the live-migration has completed deep-copying all data blocks from the
120 source image to the target, the migration can be committed::
122 $ rbd status migration_target
125 source: rbd/migration_source (5e2cba2f62e)
126 destination: rbd/migration_target (5e2ed95ed806)
128 $ rbd migration commit migration_target
129 Commit image migration: 100% complete...done.
131 If the `migration_source` image is a parent of one or more clones, the `--force`
132 option will need to be specified after ensuring all descendent clone images are
135 Committing the live-migration will remove the cross-links between the source
136 and target images, and will remove the source image::
138 $ rbd trash list --all
144 If you wish to revert the prepare or execute step, run the `rbd migration abort`
145 command to revert the migration process::
147 $ rbd migration abort migration_target
148 Abort image migration: 100% complete...done.
150 Aborting the migration will result in the target image being deleted and access
151 to the original source image being restored::
157 .. _layered images: ../rbd-snapshot/#layering