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