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