]> git.proxmox.com Git - ceph.git/blob - ceph/doc/rbd/rbd-mirroring.rst
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / doc / rbd / rbd-mirroring.rst
1 ===============
2 RBD Mirroring
3 ===============
4
5 .. index:: Ceph Block Device; mirroring
6
7 RBD images can be asynchronously mirrored between two Ceph clusters. This
8 capability uses the RBD journaling image feature to ensure crash-consistent
9 replication between clusters. Mirroring is configured on a per-pool basis
10 within peer clusters and can be configured to automatically mirror all
11 images within a pool or only a specific subset of images. Mirroring is
12 configured using the ``rbd`` command. The ``rbd-mirror`` daemon is responsible
13 for pulling image updates from the remote, peer cluster and applying them to
14 the image within the local cluster.
15
16 .. note:: RBD mirroring requires the Ceph Jewel release or later.
17
18 Depending on the desired needs for replication, RBD mirroring can be configured
19 for either one- or two-way replication:
20
21 * **One-way Replication**: When data is only mirrored from a primary cluster to
22 a secondary cluster, the ``rbd-mirror`` daemon runs only on the secondary
23 cluster.
24
25 * **Two-way Replication**: When data is mirrored from primary images on one
26 cluster to non-primary images on another cluster (and vice-versa), the
27 ``rbd-mirror`` daemon runs on both clusters.
28
29 .. important:: Each instance of the ``rbd-mirror`` daemon must be able to
30 connect to both the local and remote Ceph clusters simultaneously (i.e.
31 all monitor and OSD hosts). Additionally, the network must have sufficient
32 bandwidth between the two data centers to handle mirroring workload.
33
34 Pool Configuration
35 ==================
36
37 The following procedures demonstrate how to perform the basic administrative
38 tasks to configure mirroring using the ``rbd`` command. Mirroring is
39 configured on a per-pool basis within the Ceph clusters.
40
41 The pool configuration steps should be performed on both peer clusters. These
42 procedures assume two clusters, named "local" and "remote", are accessible from
43 a single host for clarity.
44
45 See the `rbd`_ manpage for additional details of how to connect to different
46 Ceph clusters.
47
48 .. note:: The cluster name in the following examples corresponds to a Ceph
49 configuration file of the same name (e.g. /etc/ceph/remote.conf). See the
50 `ceph-conf`_ documentation for how to configure multiple clusters.
51
52 Enable Mirroring
53 ----------------
54
55 To enable mirroring on a pool with ``rbd``, specify the ``mirror pool enable``
56 command, the pool name, and the mirroring mode::
57
58 rbd mirror pool enable {pool-name} {mode}
59
60 The mirroring mode can either be ``pool`` or ``image``:
61
62 * **pool**: When configured in ``pool`` mode, all images in the pool with the
63 journaling feature enabled are mirrored.
64 * **image**: When configured in ``image`` mode, mirroring needs to be
65 `explicitly enabled`_ on each image.
66
67 For example::
68
69 $ rbd --cluster local mirror pool enable image-pool pool
70 $ rbd --cluster remote mirror pool enable image-pool pool
71
72 Disable Mirroring
73 -----------------
74
75 To disable mirroring on a pool with ``rbd``, specify the ``mirror pool disable``
76 command and the pool name::
77
78 rbd mirror pool disable {pool-name}
79
80 When mirroring is disabled on a pool in this way, mirroring will also be
81 disabled on any images (within the pool) for which mirroring was enabled
82 explicitly.
83
84 For example::
85
86 $ rbd --cluster local mirror pool disable image-pool
87 $ rbd --cluster remote mirror pool disable image-pool
88
89 Add Cluster Peer
90 ----------------
91
92 In order for the ``rbd-mirror`` daemon to discover its peer cluster, the peer
93 needs to be registered to the pool. To add a mirroring peer Ceph cluster with
94 ``rbd``, specify the ``mirror pool peer add`` command, the pool name, and a
95 cluster specification::
96
97 rbd mirror pool peer add {pool-name} {client-name}@{cluster-name}
98
99 For example::
100
101 $ rbd --cluster local mirror pool peer add image-pool client.remote@remote
102 $ rbd --cluster remote mirror pool peer add image-pool client.local@local
103
104 By default, the ``rbd-mirror`` daemon needs to have access to a Ceph
105 configuration file located at ``/etc/ceph/{cluster-name}.conf`` that provides
106 the addresses of the peer cluster's monitors, in addition to a keyring for
107 ``{client-name}`` located in the default or configured keyring search paths
108 (e.g. ``/etc/ceph/{cluster-name}.{client-name}.keyring``).
109
110 Alternatively, the peer cluster's monitor and/or client key can be securely
111 stored within the local Ceph monitor ``config-key`` store. To specify the
112 peer cluster connection attributes when adding a mirroring peer, use the
113 ``--remote-mon-host`` and ``--remote-key-file`` optionals. For example::
114
115 $ rbd --cluster local mirror pool peer add image-pool client.remote@remote --remote-mon-host 192.168.1.1,192.168.1.2 --remote-key-file <(echo 'AQAeuZdbMMoBChAAcj++/XUxNOLFaWdtTREEsw==')
116 $ rbd --cluster local mirror pool info image-pool --all
117 Mode: pool
118 Peers:
119 UUID NAME CLIENT MON_HOST KEY
120 587b08db-3d33-4f32-8af8-421e77abb081 remote client.remote 192.168.1.1,192.168.1.2 AQAeuZdbMMoBChAAcj++/XUxNOLFaWdtTREEsw==
121
122 Remove Cluster Peer
123 -------------------
124
125 To remove a mirroring peer Ceph cluster with ``rbd``, specify the
126 ``mirror pool peer remove`` command, the pool name, and the peer UUID
127 (available from the ``rbd mirror pool info`` command)::
128
129 rbd mirror pool peer remove {pool-name} {peer-uuid}
130
131 For example::
132
133 $ rbd --cluster local mirror pool peer remove image-pool 55672766-c02b-4729-8567-f13a66893445
134 $ rbd --cluster remote mirror pool peer remove image-pool 60c0e299-b38f-4234-91f6-eed0a367be08
135
136 Data Pools
137 ----------
138
139 When creating images in the destination cluster, ``rbd-mirror`` selects a data
140 pool as follows:
141
142 #. If the destination cluster has a default data pool configured (with the
143 ``rbd_default_data_pool`` configuration option), it will be used.
144 #. Otherwise, if the source image uses a separate data pool, and a pool with the
145 same name exists on the destination cluster, that pool will be used.
146 #. If neither of the above is true, no data pool will be set.
147
148 Image Configuration
149 ===================
150
151 Unlike pool configuration, image configuration only needs to be performed against
152 a single mirroring peer Ceph cluster.
153
154 Mirrored RBD images are designated as either primary or non-primary. This is a
155 property of the image and not the pool. Images that are designated as
156 non-primary cannot be modified.
157
158 Images are automatically promoted to primary when mirroring is first enabled on
159 an image (either implicitly if the pool mirror mode was **pool** and the image
160 has the journaling image feature enabled, or `explicitly enabled`_ by the
161 ``rbd`` command).
162
163 Enable Image Journaling Support
164 -------------------------------
165
166 RBD mirroring uses the RBD journaling feature to ensure that the replicated
167 image always remains crash-consistent. Before an image can be mirrored to
168 a peer cluster, the journaling feature must be enabled. The feature can be
169 enabled at image creation time by providing the
170 ``--image-feature exclusive-lock,journaling`` option to the ``rbd`` command.
171
172 Alternatively, the journaling feature can be dynamically enabled on
173 pre-existing RBD images. To enable journaling with ``rbd``, specify
174 the ``feature enable`` command, the pool and image name, and the feature name::
175
176 rbd feature enable {pool-name}/{image-name} {feature-name}
177
178 For example::
179
180 $ rbd --cluster local feature enable image-pool/image-1 journaling
181
182 .. note:: The journaling feature is dependent on the exclusive-lock feature. If
183 the exclusive-lock feature is not already enabled, it should be enabled prior
184 to enabling the journaling feature.
185
186 .. tip:: You can enable journaling on all new images by default by adding
187 ``rbd default features = 125`` to your Ceph configuration file.
188
189 Enable Image Mirroring
190 ----------------------
191
192 If the mirroring is configured in ``image`` mode for the image's pool, then it
193 is necessary to explicitly enable mirroring for each image within the pool.
194 To enable mirroring for a specific image with ``rbd``, specify the
195 ``mirror image enable`` command along with the pool and image name::
196
197 rbd mirror image enable {pool-name}/{image-name}
198
199 For example::
200
201 $ rbd --cluster local mirror image enable image-pool/image-1
202
203 Disable Image Mirroring
204 -----------------------
205
206 To disable mirroring for a specific image with ``rbd``, specify the
207 ``mirror image disable`` command along with the pool and image name::
208
209 rbd mirror image disable {pool-name}/{image-name}
210
211 For example::
212
213 $ rbd --cluster local mirror image disable image-pool/image-1
214
215 Image Promotion and Demotion
216 ----------------------------
217
218 In a failover scenario where the primary designation needs to be moved to the
219 image in the peer Ceph cluster, access to the primary image should be stopped
220 (e.g. power down the VM or remove the associated drive from a VM), demote the
221 current primary image, promote the new primary image, and resume access to the
222 image on the alternate cluster.
223
224 .. note:: RBD only provides the necessary tools to facilitate an orderly
225 failover of an image. An external mechanism is required to coordinate the
226 full failover process (e.g. closing the image before demotion).
227
228 To demote a specific image to non-primary with ``rbd``, specify the
229 ``mirror image demote`` command along with the pool and image name::
230
231 rbd mirror image demote {pool-name}/{image-name}
232
233 For example::
234
235 $ rbd --cluster local mirror image demote image-pool/image-1
236
237 To demote all primary images within a pool to non-primary with ``rbd``, specify
238 the ``mirror pool demote`` command along with the pool name::
239
240 rbd mirror pool demote {pool-name}
241
242 For example::
243
244 $ rbd --cluster local mirror pool demote image-pool
245
246 To promote a specific image to primary with ``rbd``, specify the
247 ``mirror image promote`` command along with the pool and image name::
248
249 rbd mirror image promote [--force] {pool-name}/{image-name}
250
251 For example::
252
253 $ rbd --cluster remote mirror image promote image-pool/image-1
254
255 To promote all non-primary images within a pool to primary with ``rbd``, specify
256 the ``mirror pool promote`` command along with the pool name::
257
258 rbd mirror pool promote [--force] {pool-name}
259
260 For example::
261
262 $ rbd --cluster local mirror pool promote image-pool
263
264 .. tip:: Since the primary / non-primary status is per-image, it is possible to
265 have two clusters split the IO load and stage failover / failback.
266
267 .. note:: Promotion can be forced using the ``--force`` option. Forced
268 promotion is needed when the demotion cannot be propagated to the peer
269 Ceph cluster (e.g. Ceph cluster failure, communication outage). This will
270 result in a split-brain scenario between the two peers and the image will no
271 longer be in-sync until a `force resync command`_ is issued.
272
273 Force Image Resync
274 ------------------
275
276 If a split-brain event is detected by the ``rbd-mirror`` daemon, it will not
277 attempt to mirror the affected image until corrected. To resume mirroring for an
278 image, first `demote the image`_ determined to be out-of-date and then request a
279 resync to the primary image. To request an image resync with ``rbd``, specify the
280 ``mirror image resync`` command along with the pool and image name::
281
282 rbd mirror image resync {pool-name}/{image-name}
283
284 For example::
285
286 $ rbd mirror image resync image-pool/image-1
287
288 .. note:: The ``rbd`` command only flags the image as requiring a resync. The
289 local cluster's ``rbd-mirror`` daemon process is responsible for performing
290 the resync asynchronously.
291
292 Mirror Status
293 =============
294
295 The peer cluster replication status is stored for every primary mirrored image.
296 This status can be retrieved using the ``mirror image status`` and
297 ``mirror pool status`` commands.
298
299 To request the mirror image status with ``rbd``, specify the
300 ``mirror image status`` command along with the pool and image name::
301
302 rbd mirror image status {pool-name}/{image-name}
303
304 For example::
305
306 $ rbd mirror image status image-pool/image-1
307
308 To request the mirror pool summary status with ``rbd``, specify the
309 ``mirror pool status`` command along with the pool name::
310
311 rbd mirror pool status {pool-name}
312
313 For example::
314
315 $ rbd mirror pool status image-pool
316
317 .. note:: Adding ``--verbose`` option to the ``mirror pool status`` command will
318 additionally output status details for every mirroring image in the pool.
319
320 rbd-mirror Daemon
321 =================
322
323 The two ``rbd-mirror`` daemons are responsible for watching image journals on the
324 remote, peer cluster and replaying the journal events against the local
325 cluster. The RBD image journaling feature records all modifications to the
326 image in the order they occur. This ensures that a crash-consistent mirror of
327 the remote image is available locally.
328
329 The ``rbd-mirror`` daemon is available within the optional ``rbd-mirror``
330 distribution package.
331
332 .. important:: Each ``rbd-mirror`` daemon requires the ability to connect
333 to both clusters simultaneously.
334 .. warning:: Pre-Luminous releases: only run a single ``rbd-mirror`` daemon per
335 Ceph cluster.
336
337 Each ``rbd-mirror`` daemon should use a unique Ceph user ID. To
338 `create a Ceph user`_, with ``ceph`` specify the ``auth get-or-create``
339 command, user name, monitor caps, and OSD caps::
340
341 ceph auth get-or-create client.rbd-mirror.{unique id} mon 'profile rbd-mirror' osd 'profile rbd'
342
343 The ``rbd-mirror`` daemon can be managed by ``systemd`` by specifying the user
344 ID as the daemon instance::
345
346 systemctl enable ceph-rbd-mirror@rbd-mirror.{unique id}
347
348 The ``rbd-mirror`` can also be run in foreground by ``rbd-mirror`` command::
349
350 rbd-mirror -f --log-file={log_path}
351
352 .. _rbd: ../../man/8/rbd
353 .. _ceph-conf: ../../rados/configuration/ceph-conf/#running-multiple-clusters
354 .. _explicitly enabled: #enable-image-mirroring
355 .. _force resync command: #force-image-resync
356 .. _demote the image: #image-promotion-and-demotion
357 .. _create a Ceph user: ../../rados/operations/user-management#add-a-user
358