]> git.proxmox.com Git - pve-docs.git/blob - pveceph.adoc
ceph: troubleshooting: followup reword and small expansion
[pve-docs.git] / pveceph.adoc
1 [[chapter_pveceph]]
2 ifdef::manvolnum[]
3 pveceph(1)
4 ==========
5 :pve-toplevel:
6
7 NAME
8 ----
9
10 pveceph - Manage Ceph Services on Proxmox VE Nodes
11
12 SYNOPSIS
13 --------
14
15 include::pveceph.1-synopsis.adoc[]
16
17 DESCRIPTION
18 -----------
19 endif::manvolnum[]
20 ifndef::manvolnum[]
21 Manage Ceph Services on Proxmox VE Nodes
22 ========================================
23 :pve-toplevel:
24 endif::manvolnum[]
25
26 [thumbnail="screenshot/gui-ceph-status.png"]
27
28 {pve} unifies your compute and storage systems, i.e. you can use the same
29 physical nodes within a cluster for both computing (processing VMs and
30 containers) and replicated storage. The traditional silos of compute and
31 storage resources can be wrapped up into a single hyper-converged appliance.
32 Separate storage networks (SANs) and connections via network attached storages
33 (NAS) disappear. With the integration of Ceph, an open source software-defined
34 storage platform, {pve} has the ability to run and manage Ceph storage directly
35 on the hypervisor nodes.
36
37 Ceph is a distributed object store and file system designed to provide
38 excellent performance, reliability and scalability.
39
40 .Some advantages of Ceph on {pve} are:
41 - Easy setup and management with CLI and GUI support
42 - Thin provisioning
43 - Snapshots support
44 - Self healing
45 - Scalable to the exabyte level
46 - Setup pools with different performance and redundancy characteristics
47 - Data is replicated, making it fault tolerant
48 - Runs on economical commodity hardware
49 - No need for hardware RAID controllers
50 - Open source
51
52 For small to mid sized deployments, it is possible to install a Ceph server for
53 RADOS Block Devices (RBD) directly on your {pve} cluster nodes, see
54 xref:ceph_rados_block_devices[Ceph RADOS Block Devices (RBD)]. Recent
55 hardware has plenty of CPU power and RAM, so running storage services
56 and VMs on the same node is possible.
57
58 To simplify management, we provide 'pveceph' - a tool to install and
59 manage {ceph} services on {pve} nodes.
60
61 .Ceph consists of a couple of Daemons footnote:[Ceph intro http://docs.ceph.com/docs/luminous/start/intro/], for use as a RBD storage:
62 - Ceph Monitor (ceph-mon)
63 - Ceph Manager (ceph-mgr)
64 - Ceph OSD (ceph-osd; Object Storage Daemon)
65
66 TIP: We highly recommend to get familiar with Ceph's architecture
67 footnote:[Ceph architecture http://docs.ceph.com/docs/luminous/architecture/]
68 and vocabulary
69 footnote:[Ceph glossary http://docs.ceph.com/docs/luminous/glossary].
70
71
72 Precondition
73 ------------
74
75 To build a Proxmox Ceph Cluster there should be at least three (preferably)
76 identical servers for the setup.
77
78 A 10Gb network, exclusively used for Ceph, is recommended. A meshed network
79 setup is also an option if there are no 10Gb switches available, see our wiki
80 article footnote:[Full Mesh Network for Ceph {webwiki-url}Full_Mesh_Network_for_Ceph_Server] .
81
82 Check also the recommendations from
83 http://docs.ceph.com/docs/luminous/start/hardware-recommendations/[Ceph's website].
84
85 .Avoid RAID
86 As Ceph handles data object redundancy and multiple parallel writes to disks
87 (OSDs) on its own, using a RAID controller normally doesn’t improve
88 performance or availability. On the contrary, Ceph is designed to handle whole
89 disks on it's own, without any abstraction in between. RAID controller are not
90 designed for the Ceph use case and may complicate things and sometimes even
91 reduce performance, as their write and caching algorithms may interfere with
92 the ones from Ceph.
93
94 WARNING: Avoid RAID controller, use host bus adapter (HBA) instead.
95
96
97 [[pve_ceph_install]]
98 Installation of Ceph Packages
99 -----------------------------
100
101 On each node run the installation script as follows:
102
103 [source,bash]
104 ----
105 pveceph install
106 ----
107
108 This sets up an `apt` package repository in
109 `/etc/apt/sources.list.d/ceph.list` and installs the required software.
110
111
112 Creating initial Ceph configuration
113 -----------------------------------
114
115 [thumbnail="screenshot/gui-ceph-config.png"]
116
117 After installation of packages, you need to create an initial Ceph
118 configuration on just one node, based on your network (`10.10.10.0/24`
119 in the following example) dedicated for Ceph:
120
121 [source,bash]
122 ----
123 pveceph init --network 10.10.10.0/24
124 ----
125
126 This creates an initial configuration at `/etc/pve/ceph.conf`. That file is
127 automatically distributed to all {pve} nodes by using
128 xref:chapter_pmxcfs[pmxcfs]. The command also creates a symbolic link
129 from `/etc/ceph/ceph.conf` pointing to that file. So you can simply run
130 Ceph commands without the need to specify a configuration file.
131
132
133 [[pve_ceph_monitors]]
134 Creating Ceph Monitors
135 ----------------------
136
137 [thumbnail="screenshot/gui-ceph-monitor.png"]
138
139 The Ceph Monitor (MON)
140 footnote:[Ceph Monitor http://docs.ceph.com/docs/luminous/start/intro/]
141 maintains a master copy of the cluster map. For high availability you need to
142 have at least 3 monitors.
143
144 On each node where you want to place a monitor (three monitors are recommended),
145 create it by using the 'Ceph -> Monitor' tab in the GUI or run.
146
147
148 [source,bash]
149 ----
150 pveceph createmon
151 ----
152
153 This will also install the needed Ceph Manager ('ceph-mgr') by default. If you
154 do not want to install a manager, specify the '-exclude-manager' option.
155
156
157 [[pve_ceph_manager]]
158 Creating Ceph Manager
159 ----------------------
160
161 The Manager daemon runs alongside the monitors, providing an interface for
162 monitoring the cluster. Since the Ceph luminous release the
163 ceph-mgr footnote:[Ceph Manager http://docs.ceph.com/docs/luminous/mgr/] daemon
164 is required. During monitor installation the ceph manager will be installed as
165 well.
166
167 NOTE: It is recommended to install the Ceph Manager on the monitor nodes. For
168 high availability install more then one manager.
169
170 [source,bash]
171 ----
172 pveceph createmgr
173 ----
174
175
176 [[pve_ceph_osds]]
177 Creating Ceph OSDs
178 ------------------
179
180 [thumbnail="screenshot/gui-ceph-osd-status.png"]
181
182 via GUI or via CLI as follows:
183
184 [source,bash]
185 ----
186 pveceph createosd /dev/sd[X]
187 ----
188
189 TIP: We recommend a Ceph cluster size, starting with 12 OSDs, distributed evenly
190 among your, at least three nodes (4 OSDs on each node).
191
192 If the disk was used before (eg. ZFS/RAID/OSD), to remove partition table, boot
193 sector and any OSD leftover the following commands should be sufficient.
194
195 [source,bash]
196 ----
197 dd if=/dev/zero of=/dev/sd[X] bs=1M count=200
198 ceph-disk zap /dev/sd[X]
199 ----
200
201 WARNING: The above commands will destroy data on the disk!
202
203 Ceph Bluestore
204 ~~~~~~~~~~~~~~
205
206 Starting with the Ceph Kraken release, a new Ceph OSD storage type was
207 introduced, the so called Bluestore
208 footnote:[Ceph Bluestore http://ceph.com/community/new-luminous-bluestore/].
209 This is the default when creating OSDs in Ceph luminous.
210
211 [source,bash]
212 ----
213 pveceph createosd /dev/sd[X]
214 ----
215
216 NOTE: In order to select a disk in the GUI, to be more fail-safe, the disk needs
217 to have a GPT footnoteref:[GPT, GPT partition table
218 https://en.wikipedia.org/wiki/GUID_Partition_Table] partition table. You can
219 create this with `gdisk /dev/sd(x)`. If there is no GPT, you cannot select the
220 disk as DB/WAL.
221
222 If you want to use a separate DB/WAL device for your OSDs, you can specify it
223 through the '-journal_dev' option. The WAL is placed with the DB, if not
224 specified separately.
225
226 [source,bash]
227 ----
228 pveceph createosd /dev/sd[X] -journal_dev /dev/sd[Y]
229 ----
230
231 NOTE: The DB stores BlueStore’s internal metadata and the WAL is BlueStore’s
232 internal journal or write-ahead log. It is recommended to use a fast SSD or
233 NVRAM for better performance.
234
235
236 Ceph Filestore
237 ~~~~~~~~~~~~~
238 Till Ceph luminous, Filestore was used as storage type for Ceph OSDs. It can
239 still be used and might give better performance in small setups, when backed by
240 an NVMe SSD or similar.
241
242 [source,bash]
243 ----
244 pveceph createosd /dev/sd[X] -bluestore 0
245 ----
246
247 NOTE: In order to select a disk in the GUI, the disk needs to have a
248 GPT footnoteref:[GPT] partition table. You can
249 create this with `gdisk /dev/sd(x)`. If there is no GPT, you cannot select the
250 disk as journal. Currently the journal size is fixed to 5 GB.
251
252 If you want to use a dedicated SSD journal disk:
253
254 [source,bash]
255 ----
256 pveceph createosd /dev/sd[X] -journal_dev /dev/sd[Y] -bluestore 0
257 ----
258
259 Example: Use /dev/sdf as data disk (4TB) and /dev/sdb is the dedicated SSD
260 journal disk.
261
262 [source,bash]
263 ----
264 pveceph createosd /dev/sdf -journal_dev /dev/sdb -bluestore 0
265 ----
266
267 This partitions the disk (data and journal partition), creates
268 filesystems and starts the OSD, afterwards it is running and fully
269 functional.
270
271 NOTE: This command refuses to initialize disk when it detects existing data. So
272 if you want to overwrite a disk you should remove existing data first. You can
273 do that using: 'ceph-disk zap /dev/sd[X]'
274
275 You can create OSDs containing both journal and data partitions or you
276 can place the journal on a dedicated SSD. Using a SSD journal disk is
277 highly recommended to achieve good performance.
278
279
280 [[pve_ceph_pools]]
281 Creating Ceph Pools
282 -------------------
283
284 [thumbnail="screenshot/gui-ceph-pools.png"]
285
286 A pool is a logical group for storing objects. It holds **P**lacement
287 **G**roups (`PG`, `pg_num`), a collection of objects.
288
289 When no options are given, we set a default of **128 PGs**, a **size of 3
290 replicas** and a **min_size of 2 replicas** for serving objects in a degraded
291 state.
292
293 NOTE: The default number of PGs works for 2-5 disks. Ceph throws a
294 'HEALTH_WARNING' if you have too few or too many PGs in your cluster.
295
296 It is advised to calculate the PG number depending on your setup, you can find
297 the formula and the PG calculator footnote:[PG calculator
298 http://ceph.com/pgcalc/] online. While PGs can be increased later on, they can
299 never be decreased.
300
301
302 You can create pools through command line or on the GUI on each PVE host under
303 **Ceph -> Pools**.
304
305 [source,bash]
306 ----
307 pveceph createpool <name>
308 ----
309
310 If you would like to automatically get also a storage definition for your pool,
311 active the checkbox "Add storages" on the GUI or use the command line option
312 '--add_storages' on pool creation.
313
314 Further information on Ceph pool handling can be found in the Ceph pool
315 operation footnote:[Ceph pool operation
316 http://docs.ceph.com/docs/luminous/rados/operations/pools/]
317 manual.
318
319 Ceph CRUSH & device classes
320 ---------------------------
321 The foundation of Ceph is its algorithm, **C**ontrolled **R**eplication
322 **U**nder **S**calable **H**ashing
323 (CRUSH footnote:[CRUSH https://ceph.com/wp-content/uploads/2016/08/weil-crush-sc06.pdf]).
324
325 CRUSH calculates where to store to and retrieve data from, this has the
326 advantage that no central index service is needed. CRUSH works with a map of
327 OSDs, buckets (device locations) and rulesets (data replication) for pools.
328
329 NOTE: Further information can be found in the Ceph documentation, under the
330 section CRUSH map footnote:[CRUSH map http://docs.ceph.com/docs/luminous/rados/operations/crush-map/].
331
332 This map can be altered to reflect different replication hierarchies. The object
333 replicas can be separated (eg. failure domains), while maintaining the desired
334 distribution.
335
336 A common use case is to use different classes of disks for different Ceph pools.
337 For this reason, Ceph introduced the device classes with luminous, to
338 accommodate the need for easy ruleset generation.
339
340 The device classes can be seen in the 'ceph osd tree' output. These classes
341 represent their own root bucket, which can be seen with the below command.
342
343 [source, bash]
344 ----
345 ceph osd crush tree --show-shadow
346 ----
347
348 Example output form the above command:
349
350 [source, bash]
351 ----
352 ID CLASS WEIGHT TYPE NAME
353 -16 nvme 2.18307 root default~nvme
354 -13 nvme 0.72769 host sumi1~nvme
355 12 nvme 0.72769 osd.12
356 -14 nvme 0.72769 host sumi2~nvme
357 13 nvme 0.72769 osd.13
358 -15 nvme 0.72769 host sumi3~nvme
359 14 nvme 0.72769 osd.14
360 -1 7.70544 root default
361 -3 2.56848 host sumi1
362 12 nvme 0.72769 osd.12
363 -5 2.56848 host sumi2
364 13 nvme 0.72769 osd.13
365 -7 2.56848 host sumi3
366 14 nvme 0.72769 osd.14
367 ----
368
369 To let a pool distribute its objects only on a specific device class, you need
370 to create a ruleset with the specific class first.
371
372 [source, bash]
373 ----
374 ceph osd crush rule create-replicated <rule-name> <root> <failure-domain> <class>
375 ----
376
377 [frame="none",grid="none", align="left", cols="30%,70%"]
378 |===
379 |<rule-name>|name of the rule, to connect with a pool (seen in GUI & CLI)
380 |<root>|which crush root it should belong to (default ceph root "default")
381 |<failure-domain>|at which failure-domain the objects should be distributed (usually host)
382 |<class>|what type of OSD backing store to use (eg. nvme, ssd, hdd)
383 |===
384
385 Once the rule is in the CRUSH map, you can tell a pool to use the ruleset.
386
387 [source, bash]
388 ----
389 ceph osd pool set <pool-name> crush_rule <rule-name>
390 ----
391
392 TIP: If the pool already contains objects, all of these have to be moved
393 accordingly. Depending on your setup this may introduce a big performance hit on
394 your cluster. As an alternative, you can create a new pool and move disks
395 separately.
396
397
398 Ceph Client
399 -----------
400
401 [thumbnail="screenshot/gui-ceph-log.png"]
402
403 You can then configure {pve} to use such pools to store VM or
404 Container images. Simply use the GUI too add a new `RBD` storage (see
405 section xref:ceph_rados_block_devices[Ceph RADOS Block Devices (RBD)]).
406
407 You also need to copy the keyring to a predefined location for a external Ceph
408 cluster. If Ceph is installed on the Proxmox nodes itself, then this will be
409 done automatically.
410
411 NOTE: The file name needs to be `<storage_id> + `.keyring` - `<storage_id>` is
412 the expression after 'rbd:' in `/etc/pve/storage.cfg` which is
413 `my-ceph-storage` in the following example:
414
415 [source,bash]
416 ----
417 mkdir /etc/pve/priv/ceph
418 cp /etc/ceph/ceph.client.admin.keyring /etc/pve/priv/ceph/my-ceph-storage.keyring
419 ----
420
421 [[pveceph_fs]]
422 CephFS
423 ------
424
425 Ceph provides also a filesystem running on top of the same object storage as
426 RADOS block devices do. A **M**eta**d**ata **S**erver (`MDS`) is used to map
427 the RADOS backed objects to files and directories, allowing to provide a
428 POSIX-compliant replicated filesystem. This allows one to have a clustered
429 highly available shared filesystem in an easy way if ceph is already used. Its
430 Metadata Servers guarantee that files get balanced out over the whole Ceph
431 cluster, this way even high load will not overload a single host, which can be
432 an issue with traditional shared filesystem approaches, like `NFS`, for
433 example.
434
435 {pve} supports both, using an existing xref:storage_cephfs[CephFS as storage])
436 to save backups, ISO files or container templates and creating a
437 hyper-converged CephFS itself.
438
439
440 [[pveceph_fs_mds]]
441 Metadata Server (MDS)
442 ~~~~~~~~~~~~~~~~~~~~~
443
444 CephFS needs at least one Metadata Server to be configured and running to be
445 able to work. One can simply create one through the {pve} web GUI's `Node ->
446 CephFS` panel or on the command line with:
447
448 ----
449 pveceph mds create
450 ----
451
452 Multiple metadata servers can be created in a cluster. But with the default
453 settings only one can be active at any time. If an MDS, or its node, becomes
454 unresponsive (or crashes), another `standby` MDS will get promoted to `active`.
455 One can speed up the hand-over between the active and a standby MDS up by using
456 the 'hotstandby' parameter option on create, or if you have already created it
457 you may set/add:
458
459 ----
460 mds standby replay = true
461 ----
462
463 in the ceph.conf respective MDS section. With this enabled, this specific MDS
464 will always poll the active one, so that it can take over faster as it is in a
465 `warm` state. But naturally, the active polling will cause some additional
466 performance impact on your system and active `MDS`.
467
468 Multiple Active MDS
469 ^^^^^^^^^^^^^^^^^^^
470
471 Since Luminous (12.2.x) you can also have multiple active metadata servers
472 running, but this is normally only useful for a high count on parallel clients,
473 as else the `MDS` seldom is the bottleneck. If you want to set this up please
474 refer to the ceph documentation. footnote:[Configuring multiple active MDS
475 daemons http://docs.ceph.com/docs/luminous/cephfs/multimds/]
476
477 [[pveceph_fs_create]]
478 Create a CephFS
479 ~~~~~~~~~~~~~~~
480
481 With {pve}'s CephFS integration into you can create a CephFS easily over the
482 Web GUI, the CLI or an external API interface. Some prerequisites are required
483 for this to work:
484
485 .Prerequisites for a successful CephFS setup:
486 - xref:pve_ceph_install[Install Ceph packages], if this was already done some
487 time ago you might want to rerun it on an up to date system to ensure that
488 also all CephFS related packages get installed.
489 - xref:pve_ceph_monitors[Setup Monitors]
490 - xref:pve_ceph_monitors[Setup your OSDs]
491 - xref:pveceph_fs_mds[Setup at least one MDS]
492
493 After this got all checked and done you can simply create a CephFS through
494 either the Web GUI's `Node -> CephFS` panel or the command line tool `pveceph`,
495 for example with:
496
497 ----
498 pveceph fs create --pg_num 128 --add-storage
499 ----
500
501 This creates a CephFS named `'cephfs'' using a pool for its data named
502 `'cephfs_data'' with `128` placement groups and a pool for its metadata named
503 `'cephfs_metadata'' with one quarter of the data pools placement groups (`32`).
504 Check the xref:pve_ceph_pools[{pve} managed Ceph pool chapter] or visit the
505 Ceph documentation for more information regarding a fitting placement group
506 number (`pg_num`) for your setup footnote:[Ceph Placement Groups
507 http://docs.ceph.com/docs/luminous/rados/operations/placement-groups/].
508 Additionally, the `'--add-storage'' parameter will add the CephFS to the {pve}
509 storage configuration after it was created successfully.
510
511 Destroy CephFS
512 ~~~~~~~~~~~~~~
513
514 WARNING: Destroying a CephFS will render all its data unusable, this cannot be
515 undone!
516
517 If you really want to destroy an existing CephFS you first need to stop, or
518 destroy, all metadata server (`M̀DS`). You can destroy them either over the Web
519 GUI or the command line interface, with:
520
521 ----
522 pveceph mds destroy NAME
523 ----
524 on each {pve} node hosting a MDS daemon.
525
526 Then, you can remove (destroy) CephFS by issuing a:
527
528 ----
529 ceph fs rm NAME --yes-i-really-mean-it
530 ----
531 on a single node hosting Ceph. After this you may want to remove the created
532 data and metadata pools, this can be done either over the Web GUI or the CLI
533 with:
534
535 ----
536 pveceph pool destroy NAME
537 ----
538
539
540 Ceph monitoring and troubleshooting
541 -----------------------------------
542 A good start is to continuosly monitor the ceph health from the start of
543 initial deployment. Either through the ceph tools itself, but also by accessing
544 the status through the {pve} link:api-viewer/index.html[API].
545
546 The following ceph commands below can be used to see if the cluster is healthy
547 ('HEALTH_OK'), if there are warnings ('HEALTH_WARN'), or even errors
548 ('HEALTH_ERR'). If the cluster is in an unhealthy state the status commands
549 below will also give you an overview on the current events and actions take.
550
551 ----
552 # single time output
553 pve# ceph -s
554 # continuously output status changes (press CTRL+C to stop)
555 pve# ceph -w
556 ----
557
558 To get a more detailed view, every ceph service has a log file under
559 `/var/log/ceph/` and if there is not enough detail, the log level can be
560 adjusted footnote:[Ceph log and debugging http://docs.ceph.com/docs/luminous/rados/troubleshooting/log-and-debug/].
561
562 You can find more information about troubleshooting
563 footnote:[Ceph troubleshooting http://docs.ceph.com/docs/luminous/rados/troubleshooting/]
564 a Ceph cluster on its website.
565
566
567 ifdef::manvolnum[]
568 include::pve-copyright.adoc[]
569 endif::manvolnum[]