]> git.proxmox.com Git - pve-docs.git/blame - pveceph.adoc
attrs: update cephdocs template to quincy
[pve-docs.git] / pveceph.adoc
CommitLineData
80c0adcb 1[[chapter_pveceph]]
0840a663 2ifdef::manvolnum[]
b2f242ab
DM
3pveceph(1)
4==========
404a158e 5:pve-toplevel:
0840a663
DM
6
7NAME
8----
9
21394e70 10pveceph - Manage Ceph Services on Proxmox VE Nodes
0840a663 11
49a5e11c 12SYNOPSIS
0840a663
DM
13--------
14
15include::pveceph.1-synopsis.adoc[]
16
17DESCRIPTION
18-----------
19endif::manvolnum[]
0840a663 20ifndef::manvolnum[]
4bfe3e35
TL
21Deploy Hyper-Converged Ceph Cluster
22===================================
49d3ad91 23:pve-toplevel:
0840a663
DM
24endif::manvolnum[]
25
94d7a98c 26[thumbnail="screenshot/gui-ceph-status-dashboard.png"]
8997dd6e 27
40e6c806 28{pve} unifies your compute and storage systems, that is, you can use the same
a474ca1f
AA
29physical nodes within a cluster for both computing (processing VMs and
30containers) and replicated storage. The traditional silos of compute and
31storage resources can be wrapped up into a single hyper-converged appliance.
40e6c806 32Separate storage networks (SANs) and connections via network attached storage
a474ca1f
AA
33(NAS) disappear. With the integration of Ceph, an open source software-defined
34storage platform, {pve} has the ability to run and manage Ceph storage directly
35on the hypervisor nodes.
c994e4e5
DM
36
37Ceph is a distributed object store and file system designed to provide
1d54c3b4
AA
38excellent performance, reliability and scalability.
39
04ba9b24 40.Some advantages of Ceph on {pve} are:
40e6c806 41- Easy setup and management via CLI and GUI
a474ca1f 42- Thin provisioning
40e6c806 43- Snapshot support
a474ca1f 44- Self healing
a474ca1f
AA
45- Scalable to the exabyte level
46- Setup pools with different performance and redundancy characteristics
47- Data is replicated, making it fault tolerant
40e6c806 48- Runs on commodity hardware
a474ca1f 49- No need for hardware RAID controllers
a474ca1f
AA
50- Open source
51
40e6c806
DW
52For small to medium-sized deployments, it is possible to install a Ceph server for
53RADOS Block Devices (RBD) directly on your {pve} cluster nodes (see
54xref:ceph_rados_block_devices[Ceph RADOS Block Devices (RBD)]). Recent
55hardware has a lot of CPU power and RAM, so running storage services
c994e4e5 56and VMs on the same node is possible.
21394e70 57
40e6c806
DW
58To simplify management, we provide 'pveceph' - a tool for installing and
59managing {ceph} services on {pve} nodes.
21394e70 60
40e6c806 61.Ceph consists of multiple Daemons, for use as an RBD storage:
1d54c3b4
AA
62- Ceph Monitor (ceph-mon)
63- Ceph Manager (ceph-mgr)
64- Ceph OSD (ceph-osd; Object Storage Daemon)
65
d241b01b 66TIP: We highly recommend to get familiar with Ceph
b46a49ed 67footnote:[Ceph intro {cephdocs-url}/start/intro/],
d241b01b 68its architecture
b46a49ed 69footnote:[Ceph architecture {cephdocs-url}/architecture/]
477fbcfb 70and vocabulary
b46a49ed 71footnote:[Ceph glossary {cephdocs-url}/glossary].
1d54c3b4 72
21394e70
DM
73
74Precondition
75------------
76
40e6c806 77To build a hyper-converged Proxmox + Ceph Cluster, you must use at least
76f6eca4 78three (preferably) identical servers for the setup.
21394e70
DM
79
80Check also the recommendations from
b46a49ed 81{cephdocs-url}/start/hardware-recommendations/[Ceph's website].
21394e70 82
76f6eca4 83.CPU
40e6c806 84A high CPU core frequency reduces latency and should be preferred. As a simple
2f19a6b0
TL
85rule of thumb, you should assign a CPU core (or thread) to each Ceph service to
86provide enough resources for stable and durable Ceph performance.
76f6eca4
AA
87
88.Memory
89Especially in a hyper-converged setup, the memory consumption needs to be
40e6c806
DW
90carefully monitored. In addition to the predicted memory usage of virtual
91machines and containers, you must also account for having enough memory
92available for Ceph to provide excellent and stable performance.
5b502340
AA
93
94As a rule of thumb, for roughly **1 TiB of data, 1 GiB of memory** will be used
3a433e9b 95by an OSD. Especially during recovery, re-balancing or backfilling.
5b502340
AA
96
97The daemon itself will use additional memory. The Bluestore backend of the
98daemon requires by default **3-5 GiB of memory** (adjustable). In contrast, the
99legacy Filestore backend uses the OS page cache and the memory consumption is
100generally related to PGs of an OSD daemon.
76f6eca4
AA
101
102.Network
103We recommend a network bandwidth of at least 10 GbE or more, which is used
104exclusively for Ceph. A meshed network setup
105footnote:[Full Mesh Network for Ceph {webwiki-url}Full_Mesh_Network_for_Ceph_Server]
106is also an option if there are no 10 GbE switches available.
107
2f19a6b0
TL
108The volume of traffic, especially during recovery, will interfere with other
109services on the same network and may even break the {pve} cluster stack.
76f6eca4 110
40e6c806
DW
111Furthermore, you should estimate your bandwidth needs. While one HDD might not
112saturate a 1 Gb link, multiple HDD OSDs per node can, and modern NVMe SSDs will
113even saturate 10 Gbps of bandwidth quickly. Deploying a network capable of even
114more bandwidth will ensure that this isn't your bottleneck and won't be anytime
115soon. 25, 40 or even 100 Gbps are possible.
76f6eca4
AA
116
117.Disks
118When planning the size of your Ceph cluster, it is important to take the
40e6c806 119recovery time into consideration. Especially with small clusters, recovery
76f6eca4
AA
120might take long. It is recommended that you use SSDs instead of HDDs in small
121setups to reduce recovery time, minimizing the likelihood of a subsequent
122failure event during recovery.
123
3a433e9b 124In general, SSDs will provide more IOPS than spinning disks. With this in mind,
40e6c806
DW
125in addition to the higher cost, it may make sense to implement a
126xref:pve_ceph_device_classes[class based] separation of pools. Another way to
127speed up OSDs is to use a faster disk as a journal or
513e2f57
TL
128DB/**W**rite-**A**head-**L**og device, see
129xref:pve_ceph_osds[creating Ceph OSDs].
130If a faster disk is used for multiple OSDs, a proper balance between OSD
40e6c806
DW
131and WAL / DB (or journal) disk must be selected, otherwise the faster disk
132becomes the bottleneck for all linked OSDs.
133
134Aside from the disk type, Ceph performs best with an even sized and distributed
135amount of disks per node. For example, 4 x 500 GB disks within each node is
2f19a6b0
TL
136better than a mixed setup with a single 1 TB and three 250 GB disk.
137
40e6c806
DW
138You also need to balance OSD count and single OSD capacity. More capacity
139allows you to increase storage density, but it also means that a single OSD
140failure forces Ceph to recover more data at once.
76f6eca4 141
a474ca1f 142.Avoid RAID
86be506d 143As Ceph handles data object redundancy and multiple parallel writes to disks
c78756be 144(OSDs) on its own, using a RAID controller normally doesn’t improve
86be506d 145performance or availability. On the contrary, Ceph is designed to handle whole
40e6c806
DW
146disks on it's own, without any abstraction in between. RAID controllers are not
147designed for the Ceph workload and may complicate things and sometimes even
86be506d
TL
148reduce performance, as their write and caching algorithms may interfere with
149the ones from Ceph.
a474ca1f 150
40e6c806 151WARNING: Avoid RAID controllers. Use host bus adapter (HBA) instead.
a474ca1f 152
40e6c806
DW
153NOTE: The above recommendations should be seen as a rough guidance for choosing
154hardware. Therefore, it is still essential to adapt it to your specific needs.
155You should test your setup and monitor health and performance continuously.
76f6eca4 156
2394c306 157[[pve_ceph_install_wizard]]
40e6c806 158Initial Ceph Installation & Configuration
2394c306
TM
159-----------------------------------------
160
513e2f57
TL
161Using the Web-based Wizard
162~~~~~~~~~~~~~~~~~~~~~~~~~~
163
2394c306
TM
164[thumbnail="screenshot/gui-node-ceph-install.png"]
165
166With {pve} you have the benefit of an easy to use installation wizard
167for Ceph. Click on one of your cluster nodes and navigate to the Ceph
40e6c806
DW
168section in the menu tree. If Ceph is not already installed, you will see a
169prompt offering to do so.
2394c306 170
40e6c806 171The wizard is divided into multiple sections, where each needs to
513e2f57
TL
172finish successfully, in order to use Ceph.
173
174First you need to chose which Ceph version you want to install. Prefer the one
175from your other nodes, or the newest if this is the first node you install
176Ceph.
177
178After starting the installation, the wizard will download and install all the
179required packages from {pve}'s Ceph repository.
94d7a98c 180[thumbnail="screenshot/gui-node-ceph-install-wizard-step0.png"]
2394c306 181
513e2f57 182After finishing the installation step, you will need to create a configuration.
6a711e64
TL
183This step is only needed once per cluster, as this configuration is distributed
184automatically to all remaining cluster members through {pve}'s clustered
185xref:chapter_pmxcfs[configuration file system (pmxcfs)].
2394c306
TM
186
187The configuration step includes the following settings:
188
40e6c806
DW
189* *Public Network:* You can set up a dedicated network for Ceph. This
190setting is required. Separating your Ceph traffic is highly recommended.
191Otherwise, it could cause trouble with other latency dependent services,
192for example, cluster communication may decrease Ceph's performance.
2394c306
TM
193
194[thumbnail="screenshot/gui-node-ceph-install-wizard-step2.png"]
195
40e6c806 196* *Cluster Network:* As an optional step, you can go even further and
2394c306
TM
197separate the xref:pve_ceph_osds[OSD] replication & heartbeat traffic
198as well. This will relieve the public network and could lead to
40e6c806 199significant performance improvements, especially in large clusters.
2394c306
TM
200
201You have two more options which are considered advanced and therefore
40e6c806 202should only changed if you know what you are doing.
2394c306 203
40e6c806 204* *Number of replicas*: Defines how often an object is replicated
2394c306 205* *Minimum replicas*: Defines the minimum number of required replicas
40e6c806 206for I/O to be marked as complete.
2394c306 207
40e6c806 208Additionally, you need to choose your first monitor node. This step is required.
2394c306 209
40e6c806
DW
210That's it. You should now see a success page as the last step, with further
211instructions on how to proceed. Your system is now ready to start using Ceph.
212To get started, you will need to create some additional xref:pve_ceph_monitors[monitors],
213xref:pve_ceph_osds[OSDs] and at least one xref:pve_ceph_pools[pool].
2394c306 214
40e6c806
DW
215The rest of this chapter will guide you through getting the most out of
216your {pve} based Ceph setup. This includes the aforementioned tips and
217more, such as xref:pveceph_fs[CephFS], which is a helpful addition to your
2394c306 218new Ceph cluster.
21394e70 219
58f95dd7 220[[pve_ceph_install]]
513e2f57
TL
221CLI Installation of Ceph Packages
222~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223
224Alternatively to the the recommended {pve} Ceph installation wizard available
225in the web-interface, you can use the following CLI command on each node:
21394e70
DM
226
227[source,bash]
228----
19920184 229pveceph install
21394e70
DM
230----
231
232This sets up an `apt` package repository in
233`/etc/apt/sources.list.d/ceph.list` and installs the required software.
234
235
513e2f57
TL
236Initial Ceph configuration via CLI
237~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8997dd6e 238
2394c306
TM
239Use the {pve} Ceph installation wizard (recommended) or run the
240following command on one node:
21394e70
DM
241
242[source,bash]
243----
244pveceph init --network 10.10.10.0/24
245----
246
2394c306 247This creates an initial configuration at `/etc/pve/ceph.conf` with a
40e6c806
DW
248dedicated network for Ceph. This file is automatically distributed to
249all {pve} nodes, using xref:chapter_pmxcfs[pmxcfs]. The command also
250creates a symbolic link at `/etc/ceph/ceph.conf`, which points to that file.
251Thus, you can simply run Ceph commands without the need to specify a
2394c306 252configuration file.
21394e70
DM
253
254
d9a27ee1 255[[pve_ceph_monitors]]
b3338e29
AA
256Ceph Monitor
257-----------
513e2f57
TL
258
259[thumbnail="screenshot/gui-ceph-monitor.png"]
260
1d54c3b4 261The Ceph Monitor (MON)
b46a49ed 262footnote:[Ceph Monitor {cephdocs-url}/start/intro/]
40e6c806
DW
263maintains a master copy of the cluster map. For high availability, you need at
264least 3 monitors. One monitor will already be installed if you
265used the installation wizard. You won't need more than 3 monitors, as long
266as your cluster is small to medium-sized. Only really large clusters will
267require more than this.
1d54c3b4 268
c998bdf2 269[[pveceph_create_mon]]
b3338e29
AA
270Create Monitors
271~~~~~~~~~~~~~~~
272
1d54c3b4 273On each node where you want to place a monitor (three monitors are recommended),
40e6c806 274create one by using the 'Ceph -> Monitor' tab in the GUI or run:
21394e70
DM
275
276
277[source,bash]
278----
d1fdb121 279pveceph mon create
21394e70
DM
280----
281
c998bdf2 282[[pveceph_destroy_mon]]
b3338e29
AA
283Destroy Monitors
284~~~~~~~~~~~~~~~~
0e38a564 285
40e6c806 286To remove a Ceph Monitor via the GUI, first select a node in the tree view and
0e38a564
AA
287go to the **Ceph -> Monitor** panel. Select the MON and click the **Destroy**
288button.
289
40e6c806 290To remove a Ceph Monitor via the CLI, first connect to the node on which the MON
0e38a564
AA
291is running. Then execute the following command:
292[source,bash]
293----
294pveceph mon destroy
295----
296
297NOTE: At least three Monitors are needed for quorum.
298
299
1d54c3b4 300[[pve_ceph_manager]]
b3338e29
AA
301Ceph Manager
302------------
40e6c806 303
b3338e29 304The Manager daemon runs alongside the monitors. It provides an interface to
40e6c806 305monitor the cluster. Since the release of Ceph luminous, at least one ceph-mgr
b46a49ed 306footnote:[Ceph Manager {cephdocs-url}/mgr/] daemon is
b3338e29
AA
307required.
308
55d634e6 309[[pveceph_create_mgr]]
b3338e29
AA
310Create Manager
311~~~~~~~~~~~~~~
1d54c3b4 312
40e6c806
DW
313Multiple Managers can be installed, but only one Manager is active at any given
314time.
1d54c3b4 315
1d54c3b4
AA
316[source,bash]
317----
d1fdb121 318pveceph mgr create
1d54c3b4
AA
319----
320
c1f38fe3
AA
321NOTE: It is recommended to install the Ceph Manager on the monitor nodes. For
322high availability install more then one manager.
323
21394e70 324
c998bdf2 325[[pveceph_destroy_mgr]]
b3338e29
AA
326Destroy Manager
327~~~~~~~~~~~~~~~
549350fe 328
40e6c806 329To remove a Ceph Manager via the GUI, first select a node in the tree view and
549350fe
AA
330go to the **Ceph -> Monitor** panel. Select the Manager and click the
331**Destroy** button.
332
40e6c806 333To remove a Ceph Monitor via the CLI, first connect to the node on which the
549350fe
AA
334Manager is running. Then execute the following command:
335[source,bash]
336----
337pveceph mgr destroy
338----
339
40e6c806
DW
340NOTE: While a manager is not a hard-dependency, it is crucial for a Ceph cluster,
341as it handles important features like PG-autoscaling, device health monitoring,
342telemetry and more.
549350fe 343
d9a27ee1 344[[pve_ceph_osds]]
b3338e29
AA
345Ceph OSDs
346---------
513e2f57
TL
347
348[thumbnail="screenshot/gui-ceph-osd-status.png"]
349
40e6c806 350Ceph **O**bject **S**torage **D**aemons store objects for Ceph over the
b3338e29
AA
351network. It is recommended to use one OSD per physical disk.
352
081cb761 353[[pve_ceph_osd_create]]
b3338e29
AA
354Create OSDs
355~~~~~~~~~~~
21394e70 356
40e6c806 357You can create an OSD either via the {pve} web-interface or via the CLI using
e79e0b9d 358`pveceph`. For example:
21394e70
DM
359
360[source,bash]
361----
d1fdb121 362pveceph osd create /dev/sd[X]
21394e70
DM
363----
364
40e6c806 365TIP: We recommend a Ceph cluster with at least three nodes and at least 12
e79e0b9d 366OSDs, evenly distributed among the nodes.
1d54c3b4 367
40e6c806
DW
368If the disk was in use before (for example, for ZFS or as an OSD) you first need
369to zap all traces of that usage. To remove the partition table, boot sector and
370any other OSD leftover, you can use the following command:
a474ca1f
AA
371
372[source,bash]
373----
9bddef40 374ceph-volume lvm zap /dev/sd[X] --destroy
a474ca1f
AA
375----
376
e79e0b9d 377WARNING: The above command will destroy all data on the disk!
1d54c3b4 378
b3338e29 379.Ceph Bluestore
21394e70 380
1d54c3b4 381Starting with the Ceph Kraken release, a new Ceph OSD storage type was
40e6c806 382introduced called Bluestore
2798d126 383footnote:[Ceph Bluestore https://ceph.com/community/new-luminous-bluestore/].
9bddef40 384This is the default when creating OSDs since Ceph Luminous.
21394e70
DM
385
386[source,bash]
387----
d1fdb121 388pveceph osd create /dev/sd[X]
1d54c3b4
AA
389----
390
1e834cb2 391.Block.db and block.wal
1d54c3b4
AA
392
393If you want to use a separate DB/WAL device for your OSDs, you can specify it
b3338e29
AA
394through the '-db_dev' and '-wal_dev' options. The WAL is placed with the DB, if
395not specified separately.
1d54c3b4
AA
396
397[source,bash]
398----
d1fdb121 399pveceph osd create /dev/sd[X] -db_dev /dev/sd[Y] -wal_dev /dev/sd[Z]
1d54c3b4
AA
400----
401
40e6c806
DW
402You can directly choose the size of those with the '-db_size' and '-wal_size'
403parameters respectively. If they are not given, the following values (in order)
9bddef40
DC
404will be used:
405
40e6c806 406* bluestore_block_{db,wal}_size from Ceph configuration...
352c803f
TL
407** ... database, section 'osd'
408** ... database, section 'global'
409** ... file, section 'osd'
410** ... file, section 'global'
9bddef40
DC
411* 10% (DB)/1% (WAL) of OSD size
412
40e6c806 413NOTE: The DB stores BlueStore’s internal metadata, and the WAL is BlueStore’s
ee4a0e96 414internal journal or write-ahead log. It is recommended to use a fast SSD or
1d54c3b4
AA
415NVRAM for better performance.
416
b3338e29 417.Ceph Filestore
9bddef40 418
40e6c806 419Before Ceph Luminous, Filestore was used as the default storage type for Ceph OSDs.
9bddef40 420Starting with Ceph Nautilus, {pve} does not support creating such OSDs with
352c803f
TL
421'pveceph' anymore. If you still want to create filestore OSDs, use
422'ceph-volume' directly.
1d54c3b4
AA
423
424[source,bash]
425----
9bddef40 426ceph-volume lvm create --filestore --data /dev/sd[X] --journal /dev/sd[Y]
21394e70
DM
427----
428
081cb761 429[[pve_ceph_osd_destroy]]
b3338e29
AA
430Destroy OSDs
431~~~~~~~~~~~~
be2d137e 432
40e6c806
DW
433To remove an OSD via the GUI, first select a {PVE} node in the tree view and go
434to the **Ceph -> OSD** panel. Then select the OSD to destroy and click the **OUT**
435button. Once the OSD status has changed from `in` to `out`, click the **STOP**
436button. Finally, after the status has changed from `up` to `down`, select
437**Destroy** from the `More` drop-down menu.
be2d137e
AA
438
439To remove an OSD via the CLI run the following commands.
40e6c806 440
be2d137e
AA
441[source,bash]
442----
443ceph osd out <ID>
444systemctl stop ceph-osd@<ID>.service
445----
40e6c806 446
be2d137e
AA
447NOTE: The first command instructs Ceph not to include the OSD in the data
448distribution. The second command stops the OSD service. Until this time, no
449data is lost.
450
451The following command destroys the OSD. Specify the '-cleanup' option to
452additionally destroy the partition table.
40e6c806 453
be2d137e
AA
454[source,bash]
455----
456pveceph osd destroy <ID>
457----
40e6c806
DW
458
459WARNING: The above command will destroy all data on the disk!
be2d137e
AA
460
461
07fef357 462[[pve_ceph_pools]]
b3338e29
AA
463Ceph Pools
464----------
94d7a98c
TL
465
466[thumbnail="screenshot/gui-ceph-pools.png"]
467
40e6c806
DW
468A pool is a logical group for storing objects. It holds a collection of objects,
469known as **P**lacement **G**roups (`PG`, `pg_num`).
1d54c3b4 470
b3338e29 471
6004d86b 472Create and Edit Pools
5b9f923f 473~~~~~~~~~~~~~~~~~~~~~
b3338e29 474
513e2f57
TL
475You can create and edit pools from the command line or the web-interface of any
476{pve} host under **Ceph -> Pools**.
d56606c7 477
90682f35 478When no options are given, we set a default of **128 PGs**, a **size of 3
d56606c7
TL
479replicas** and a **min_size of 2 replicas**, to ensure no data loss occurs if
480any OSD fails.
1d54c3b4 481
ef3efe51 482WARNING: **Do not set a min_size of 1**. A replicated pool with min_size of 1
40e6c806 483allows I/O on an object when it has only 1 replica, which could lead to data
ef3efe51
AA
484loss, incomplete PGs or unfound objects.
485
513e2f57
TL
486It is advised that you either enable the PG-Autoscaler or calculate the PG
487number based on your setup. You can find the formula and the PG calculator
f8bfcb41 488footnote:[PG calculator https://web.archive.org/web/20210301111112/http://ceph.com/pgcalc/] online. From Ceph Nautilus
513e2f57
TL
489onward, you can change the number of PGs
490footnoteref:[placement_groups,Placement Groups
c446b6bb 491{cephdocs-url}/rados/operations/placement-groups/] after the setup.
1d54c3b4 492
513e2f57 493The PG autoscaler footnoteref:[autoscaler,Automated Scaling
c446b6bb 494{cephdocs-url}/rados/operations/placement-groups/#automated-scaling] can
513e2f57
TL
495automatically scale the PG count for a pool in the background. Setting the
496`Target Size` or `Target Ratio` advanced parameters helps the PG-Autoscaler to
497make better decisions.
1d54c3b4 498
d56606c7 499.Example for creating a pool over the CLI
1d54c3b4
AA
500[source,bash]
501----
41791cf8 502pveceph pool create <pool-name> --add_storages
1d54c3b4
AA
503----
504
40e6c806
DW
505TIP: If you would also like to automatically define a storage for your
506pool, keep the `Add as Storage' checkbox checked in the web-interface, or use the
d56606c7 507command line option '--add_storages' at pool creation.
21394e70 508
513e2f57
TL
509Pool Options
510^^^^^^^^^^^^
511
94d7a98c
TL
512[thumbnail="screenshot/gui-ceph-pool-create.png"]
513
513e2f57
TL
514The following options are available on pool creation, and partially also when
515editing a pool.
516
c446b6bb
DW
517Name:: The name of the pool. This must be unique and can't be changed afterwards.
518Size:: The number of replicas per object. Ceph always tries to have this many
519copies of an object. Default: `3`.
520PG Autoscale Mode:: The automatic PG scaling mode footnoteref:[autoscaler] of
521the pool. If set to `warn`, it produces a warning message when a pool
522has a non-optimal PG count. Default: `warn`.
523Add as Storage:: Configure a VM or container storage using the new pool.
5b9f923f 524Default: `true` (only visible on creation).
c446b6bb
DW
525
526.Advanced Options
527Min. Size:: The minimum number of replicas per object. Ceph will reject I/O on
528the pool if a PG has less than this many replicas. Default: `2`.
529Crush Rule:: The rule to use for mapping object placement in the cluster. These
530rules define how data is placed within the cluster. See
531xref:pve_ceph_device_classes[Ceph CRUSH & device classes] for information on
532device-based rules.
533# of PGs:: The number of placement groups footnoteref:[placement_groups] that
534the pool should have at the beginning. Default: `128`.
513e2f57 535Target Ratio:: The ratio of data that is expected in the pool. The PG
c446b6bb
DW
536autoscaler uses the ratio relative to other ratio sets. It takes precedence
537over the `target size` if both are set.
a0d289ff
DC
538Target Size:: The estimated amount of data expected in the pool. The PG
539autoscaler uses this size to estimate the optimal PG count.
c446b6bb
DW
540Min. # of PGs:: The minimum number of placement groups. This setting is used to
541fine-tune the lower bound of the PG count for that pool. The PG autoscaler
542will not merge PGs below this threshold.
543
1d54c3b4
AA
544Further information on Ceph pool handling can be found in the Ceph pool
545operation footnote:[Ceph pool operation
b46a49ed 546{cephdocs-url}/rados/operations/pools/]
1d54c3b4 547manual.
21394e70 548
166c91fe 549
cbb265a3 550[[pve_ceph_ec_pools]]
41791cf8
TL
551Erasure Coded Pools
552~~~~~~~~~~~~~~~~~~~
cbb265a3 553
41791cf8
TL
554Erasure coding (EC) is a form of `forward error correction' codes that allows
555to recover from a certain amount of data loss. Erasure coded pools can offer
556more usable space compared to replicated pools, but they do that for the price
557of performance.
558
42135e58 559For comparison: in classic, replicated pools, multiple replicas of the data
41791cf8
TL
560are stored (`size`) while in erasure coded pool, data is split into `k` data
561chunks with additional `m` coding (checking) chunks. Those coding chunks can be
562used to recreate data should data chunks be missing.
563
564The number of coding chunks, `m`, defines how many OSDs can be lost without
565losing any data. The total amount of objects stored is `k + m`.
566
567Creating EC Pools
568^^^^^^^^^^^^^^^^^
569
42135e58
AL
570Erasure coded (EC) pools can be created with the `pveceph` CLI tooling.
571Planning an EC pool needs to account for the fact, that they work differently
572than replicated pools.
cbb265a3 573
e9d331c5
TL
574The default `min_size` of an EC pool depends on the `m` parameter. If `m = 1`,
575the `min_size` of the EC pool will be `k`. The `min_size` will be `k + 1` if
576`m > 1`. The Ceph documentation recommends a conservative `min_size` of `k + 2`
cbb265a3
AL
577footnote:[Ceph Erasure Coded Pool Recovery
578{cephdocs-url}/rados/operations/erasure-code/#erasure-coded-pool-recovery].
579
e9d331c5 580If there are less than `min_size` OSDs available, any IO to the pool will be
cbb265a3
AL
581blocked until there are enough OSDs available again.
582
e9d331c5 583NOTE: When planning an erasure coded pool, keep an eye on the `min_size` as it
cbb265a3
AL
584defines how many OSDs need to be available. Otherwise, IO will be blocked.
585
e9d331c5
TL
586For example, an EC pool with `k = 2` and `m = 1` will have `size = 3`,
587`min_size = 2` and will stay operational if one OSD fails. If the pool is
588configured with `k = 2`, `m = 2`, it will have a `size = 4` and `min_size = 3`
cbb265a3
AL
589and stay operational if one OSD is lost.
590
591To create a new EC pool, run the following command:
592
593[source,bash]
594----
81de7382 595pveceph pool create <pool-name> --erasure-coding k=2,m=1
cbb265a3
AL
596----
597
e9d331c5 598Optional parameters are `failure-domain` and `device-class`. If you
cbb265a3
AL
599need to change any EC profile settings used by the pool, you will have to
600create a new pool with a new profile.
601
602This will create a new EC pool plus the needed replicated pool to store the RBD
e9d331c5
TL
603omap and other metadata. In the end, there will be a `<pool name>-data` and
604`<pool name>-metada` pool. The default behavior is to create a matching storage
cbb265a3 605configuration as well. If that behavior is not wanted, you can disable it by
e9d331c5
TL
606providing the `--add_storages 0` parameter. When configuring the storage
607configuration manually, keep in mind that the `data-pool` parameter needs to be
cbb265a3
AL
608set. Only then will the EC pool be used to store the data objects. For example:
609
e9d331c5 610NOTE: The optional parameters `--size`, `--min_size` and `--crush_rule` will be
12730071 611used for the replicated metadata pool, but not for the erasure coded data pool.
e9d331c5
TL
612If you need to change the `min_size` on the data pool, you can do it later.
613The `size` and `crush_rule` parameters cannot be changed on erasure coded
12730071
AL
614pools.
615
cbb265a3
AL
616If there is a need to further customize the EC profile, you can do so by
617creating it with the Ceph tools directly footnote:[Ceph Erasure Code Profile
618{cephdocs-url}/rados/operations/erasure-code/#erasure-code-profiles], and
e9d331c5 619specify the profile to use with the `profile` parameter.
cbb265a3
AL
620
621For example:
622[source,bash]
623----
81de7382 624pveceph pool create <pool-name> --erasure-coding profile=<profile-name>
41791cf8
TL
625----
626
627Adding EC Pools as Storage
628^^^^^^^^^^^^^^^^^^^^^^^^^^
629
42135e58
AL
630You can add an already existing EC pool as storage to {pve}. It works the same
631way as adding an `RBD` pool but requires the extra `data-pool` option.
41791cf8
TL
632
633[source,bash]
634----
635pvesm add rbd <storage-name> --pool <replicated-pool> --data-pool <ec-pool>
cbb265a3
AL
636----
637
41791cf8 638TIP: Do not forget to add the `keyring` and `monhost` option for any external
f226da0e 639Ceph clusters, not managed by the local {pve} cluster.
cbb265a3 640
b3338e29
AA
641Destroy Pools
642~~~~~~~~~~~~~
166c91fe 643
40e6c806 644To destroy a pool via the GUI, select a node in the tree view and go to the
166c91fe 645**Ceph -> Pools** panel. Select the pool to destroy and click the **Destroy**
40e6c806 646button. To confirm the destruction of the pool, you need to enter the pool name.
166c91fe
AA
647
648Run the following command to destroy a pool. Specify the '-remove_storages' to
649also remove the associated storage.
40e6c806 650
166c91fe
AA
651[source,bash]
652----
653pveceph pool destroy <name>
654----
655
40e6c806
DW
656NOTE: Pool deletion runs in the background and can take some time.
657You will notice the data usage in the cluster decreasing throughout this
658process.
166c91fe 659
47d62c84
DW
660
661PG Autoscaler
662~~~~~~~~~~~~~
663
664The PG autoscaler allows the cluster to consider the amount of (expected) data
665stored in each pool and to choose the appropriate pg_num values automatically.
513e2f57 666It is available since Ceph Nautilus.
47d62c84
DW
667
668You may need to activate the PG autoscaler module before adjustments can take
669effect.
40e6c806 670
47d62c84
DW
671[source,bash]
672----
673ceph mgr module enable pg_autoscaler
674----
675
676The autoscaler is configured on a per pool basis and has the following modes:
677
678[horizontal]
679warn:: A health warning is issued if the suggested `pg_num` value differs too
680much from the current value.
681on:: The `pg_num` is adjusted automatically with no need for any manual
682interaction.
683off:: No automatic `pg_num` adjustments are made, and no warning will be issued
40e6c806 684if the PG count is not optimal.
47d62c84 685
40e6c806 686The scaling factor can be adjusted to facilitate future data storage with the
47d62c84
DW
687`target_size`, `target_size_ratio` and the `pg_num_min` options.
688
689WARNING: By default, the autoscaler considers tuning the PG count of a pool if
690it is off by a factor of 3. This will lead to a considerable shift in data
691placement and might introduce a high load on the cluster.
692
693You can find a more in-depth introduction to the PG autoscaler on Ceph's Blog -
694https://ceph.io/rados/new-in-nautilus-pg-merging-and-autotuning/[New in
695Nautilus: PG merging and autotuning].
696
697
76f6eca4 698[[pve_ceph_device_classes]]
9fad507d
AA
699Ceph CRUSH & device classes
700---------------------------
513e2f57
TL
701
702[thumbnail="screenshot/gui-ceph-config.png"]
703
40e6c806
DW
704The footnote:[CRUSH
705https://ceph.com/wp-content/uploads/2016/08/weil-crush-sc06.pdf] (**C**ontrolled
706**R**eplication **U**nder **S**calable **H**ashing) algorithm is at the
707foundation of Ceph.
9fad507d 708
40e6c806
DW
709CRUSH calculates where to store and retrieve data from. This has the
710advantage that no central indexing service is needed. CRUSH works using a map of
9fad507d
AA
711OSDs, buckets (device locations) and rulesets (data replication) for pools.
712
713NOTE: Further information can be found in the Ceph documentation, under the
b46a49ed 714section CRUSH map footnote:[CRUSH map {cephdocs-url}/rados/operations/crush-map/].
9fad507d
AA
715
716This map can be altered to reflect different replication hierarchies. The object
3a433e9b 717replicas can be separated (e.g., failure domains), while maintaining the desired
9fad507d
AA
718distribution.
719
40e6c806
DW
720A common configuration is to use different classes of disks for different Ceph
721pools. For this reason, Ceph introduced device classes with luminous, to
9fad507d
AA
722accommodate the need for easy ruleset generation.
723
724The device classes can be seen in the 'ceph osd tree' output. These classes
725represent their own root bucket, which can be seen with the below command.
726
727[source, bash]
728----
729ceph osd crush tree --show-shadow
730----
731
732Example output form the above command:
733
734[source, bash]
735----
736ID CLASS WEIGHT TYPE NAME
737-16 nvme 2.18307 root default~nvme
738-13 nvme 0.72769 host sumi1~nvme
739 12 nvme 0.72769 osd.12
740-14 nvme 0.72769 host sumi2~nvme
741 13 nvme 0.72769 osd.13
742-15 nvme 0.72769 host sumi3~nvme
743 14 nvme 0.72769 osd.14
744 -1 7.70544 root default
745 -3 2.56848 host sumi1
746 12 nvme 0.72769 osd.12
747 -5 2.56848 host sumi2
748 13 nvme 0.72769 osd.13
749 -7 2.56848 host sumi3
750 14 nvme 0.72769 osd.14
751----
752
40e6c806
DW
753To instruct a pool to only distribute objects on a specific device class, you
754first need to create a ruleset for the device class:
9fad507d
AA
755
756[source, bash]
757----
758ceph osd crush rule create-replicated <rule-name> <root> <failure-domain> <class>
759----
760
761[frame="none",grid="none", align="left", cols="30%,70%"]
762|===
763|<rule-name>|name of the rule, to connect with a pool (seen in GUI & CLI)
f226da0e 764|<root>|which crush root it should belong to (default Ceph root "default")
9fad507d 765|<failure-domain>|at which failure-domain the objects should be distributed (usually host)
3a433e9b 766|<class>|what type of OSD backing store to use (e.g., nvme, ssd, hdd)
9fad507d
AA
767|===
768
769Once the rule is in the CRUSH map, you can tell a pool to use the ruleset.
770
771[source, bash]
772----
773ceph osd pool set <pool-name> crush_rule <rule-name>
774----
775
40e6c806
DW
776TIP: If the pool already contains objects, these must be moved accordingly.
777Depending on your setup, this may introduce a big performance impact on your
778cluster. As an alternative, you can create a new pool and move disks separately.
9fad507d
AA
779
780
21394e70
DM
781Ceph Client
782-----------
783
1ff5e4e8 784[thumbnail="screenshot/gui-ceph-log.png"]
8997dd6e 785
40e6c806
DW
786Following the setup from the previous sections, you can configure {pve} to use
787such pools to store VM and Container images. Simply use the GUI to add a new
513e2f57
TL
788`RBD` storage (see section
789xref:ceph_rados_block_devices[Ceph RADOS Block Devices (RBD)]).
21394e70 790
620d6725 791You also need to copy the keyring to a predefined location for an external Ceph
1d54c3b4
AA
792cluster. If Ceph is installed on the Proxmox nodes itself, then this will be
793done automatically.
21394e70 794
40e6c806
DW
795NOTE: The filename needs to be `<storage_id> + `.keyring`, where `<storage_id>` is
796the expression after 'rbd:' in `/etc/pve/storage.cfg`. In the following example,
797`my-ceph-storage` is the `<storage_id>`:
21394e70
DM
798
799[source,bash]
800----
801mkdir /etc/pve/priv/ceph
802cp /etc/ceph/ceph.client.admin.keyring /etc/pve/priv/ceph/my-ceph-storage.keyring
803----
0840a663 804
58f95dd7
TL
805[[pveceph_fs]]
806CephFS
807------
808
40e6c806
DW
809Ceph also provides a filesystem, which runs on top of the same object storage as
810RADOS block devices do. A **M**eta**d**ata **S**erver (`MDS`) is used to map the
811RADOS backed objects to files and directories, allowing Ceph to provide a
812POSIX-compliant, replicated filesystem. This allows you to easily configure a
813clustered, highly available, shared filesystem. Ceph's Metadata Servers
814guarantee that files are evenly distributed over the entire Ceph cluster. As a
815result, even cases of high load will not overwhelm a single host, which can be
816an issue with traditional shared filesystem approaches, for example `NFS`.
58f95dd7 817
1e834cb2
TL
818[thumbnail="screenshot/gui-node-ceph-cephfs-panel.png"]
819
40e6c806
DW
820{pve} supports both creating a hyper-converged CephFS and using an existing
821xref:storage_cephfs[CephFS as storage] to save backups, ISO files, and container
822templates.
58f95dd7
TL
823
824
825[[pveceph_fs_mds]]
826Metadata Server (MDS)
827~~~~~~~~~~~~~~~~~~~~~
828
40e6c806
DW
829CephFS needs at least one Metadata Server to be configured and running, in order
830to function. You can create an MDS through the {pve} web GUI's `Node
831-> CephFS` panel or from the command line with:
58f95dd7
TL
832
833----
834pveceph mds create
835----
836
40e6c806
DW
837Multiple metadata servers can be created in a cluster, but with the default
838settings, only one can be active at a time. If an MDS or its node becomes
58f95dd7 839unresponsive (or crashes), another `standby` MDS will get promoted to `active`.
40e6c806
DW
840You can speed up the handover between the active and standby MDS by using
841the 'hotstandby' parameter option on creation, or if you have already created it
58f95dd7
TL
842you may set/add:
843
844----
845mds standby replay = true
846----
847
40e6c806
DW
848in the respective MDS section of `/etc/pve/ceph.conf`. With this enabled, the
849specified MDS will remain in a `warm` state, polling the active one, so that it
850can take over faster in case of any issues.
851
852NOTE: This active polling will have an additional performance impact on your
853system and the active `MDS`.
58f95dd7 854
1e834cb2 855.Multiple Active MDS
58f95dd7 856
40e6c806
DW
857Since Luminous (12.2.x) you can have multiple active metadata servers
858running at once, but this is normally only useful if you have a high amount of
859clients running in parallel. Otherwise the `MDS` is rarely the bottleneck in a
860system. If you want to set this up, please refer to the Ceph documentation.
861footnote:[Configuring multiple active MDS daemons
862{cephdocs-url}/cephfs/multimds/]
58f95dd7
TL
863
864[[pveceph_fs_create]]
8a38333f
AA
865Create CephFS
866~~~~~~~~~~~~~
58f95dd7 867
40e6c806
DW
868With {pve}'s integration of CephFS, you can easily create a CephFS using the
869web interface, CLI or an external API interface. Some prerequisites are required
58f95dd7
TL
870for this to work:
871
872.Prerequisites for a successful CephFS setup:
40e6c806
DW
873- xref:pve_ceph_install[Install Ceph packages] - if this was already done some
874time ago, you may want to rerun it on an up-to-date system to
875ensure that all CephFS related packages get installed.
58f95dd7
TL
876- xref:pve_ceph_monitors[Setup Monitors]
877- xref:pve_ceph_monitors[Setup your OSDs]
878- xref:pveceph_fs_mds[Setup at least one MDS]
879
40e6c806 880After this is complete, you can simply create a CephFS through
58f95dd7 881either the Web GUI's `Node -> CephFS` panel or the command line tool `pveceph`,
40e6c806 882for example:
58f95dd7
TL
883
884----
885pveceph fs create --pg_num 128 --add-storage
886----
887
40e6c806
DW
888This creates a CephFS named 'cephfs', using a pool for its data named
889'cephfs_data' with '128' placement groups and a pool for its metadata named
890'cephfs_metadata' with one quarter of the data pool's placement groups (`32`).
58f95dd7 891Check the xref:pve_ceph_pools[{pve} managed Ceph pool chapter] or visit the
40e6c806 892Ceph documentation for more information regarding an appropriate placement group
c446b6bb 893number (`pg_num`) for your setup footnoteref:[placement_groups].
40e6c806 894Additionally, the '--add-storage' parameter will add the CephFS to the {pve}
c446b6bb 895storage configuration after it has been created successfully.
58f95dd7
TL
896
897Destroy CephFS
898~~~~~~~~~~~~~~
899
40e6c806 900WARNING: Destroying a CephFS will render all of its data unusable. This cannot be
58f95dd7
TL
901undone!
902
54f20853
TL
903To completely and gracefully remove a CephFS, the following steps are
904necessary:
58f95dd7 905
b631c35e
DC
906* Disconnect every non-{PVE} client (e.g. unmount the CephFS in guests).
907* Disable all related CephFS {PVE} storage entries (to prevent it from being
908 automatically mounted).
909* Remove all used resources from guests (e.g. ISOs) that are on the CephFS you
910 want to destroy.
911* Unmount the CephFS storages on all cluster nodes manually with
912+
58f95dd7 913----
b631c35e 914umount /mnt/pve/<STORAGE-NAME>
58f95dd7 915----
b631c35e
DC
916+
917Where `<STORAGE-NAME>` is the name of the CephFS storage in your {PVE}.
58f95dd7 918
b631c35e 919* Now make sure that no metadata server (`MDS`) is running for that CephFS,
54f20853
TL
920 either by stopping or destroying them. This can be done through the web
921 interface or via the command line interface, for the latter you would issue
922 the following command:
b631c35e
DC
923+
924----
925pveceph stop --service mds.NAME
58f95dd7 926----
b631c35e
DC
927+
928to stop them, or
929+
930----
931pveceph mds destroy NAME
58f95dd7 932----
b631c35e
DC
933+
934to destroy them.
935+
936Note that standby servers will automatically be promoted to active when an
937active `MDS` is stopped or removed, so it is best to first stop all standby
938servers.
58f95dd7 939
b631c35e
DC
940* Now you can destroy the CephFS with
941+
58f95dd7 942----
b631c35e 943pveceph fs destroy NAME --remove-storages --remove-pools
58f95dd7 944----
b631c35e 945+
f226da0e 946This will automatically destroy the underlying Ceph pools as well as remove
b631c35e 947the storages from pve config.
0840a663 948
b631c35e
DC
949After these steps, the CephFS should be completely removed and if you have
950other CephFS instances, the stopped metadata servers can be started again
951to act as standbys.
6ff32926 952
081cb761
AA
953Ceph maintenance
954----------------
af6f59f4 955
081cb761
AA
956Replace OSDs
957~~~~~~~~~~~~
af6f59f4 958
40e6c806
DW
959One of the most common maintenance tasks in Ceph is to replace the disk of an
960OSD. If a disk is already in a failed state, then you can go ahead and run
961through the steps in xref:pve_ceph_osd_destroy[Destroy OSDs]. Ceph will recreate
962those copies on the remaining OSDs if possible. This rebalancing will start as
963soon as an OSD failure is detected or an OSD was actively stopped.
af6f59f4
TL
964
965NOTE: With the default size/min_size (3/2) of a pool, recovery only starts when
966`size + 1` nodes are available. The reason for this is that the Ceph object
967balancer xref:pve_ceph_device_classes[CRUSH] defaults to a full node as
968`failure domain'.
081cb761 969
40e6c806 970To replace a functioning disk from the GUI, go through the steps in
081cb761
AA
971xref:pve_ceph_osd_destroy[Destroy OSDs]. The only addition is to wait until
972the cluster shows 'HEALTH_OK' before stopping the OSD to destroy it.
973
40e6c806
DW
974On the command line, use the following commands:
975
081cb761
AA
976----
977ceph osd out osd.<id>
978----
979
980You can check with the command below if the OSD can be safely removed.
40e6c806 981
081cb761
AA
982----
983ceph osd safe-to-destroy osd.<id>
984----
985
40e6c806
DW
986Once the above check tells you that it is safe to remove the OSD, you can
987continue with the following commands:
988
081cb761
AA
989----
990systemctl stop ceph-osd@<id>.service
991pveceph osd destroy <id>
992----
993
994Replace the old disk with the new one and use the same procedure as described
995in xref:pve_ceph_osd_create[Create OSDs].
996
835f322d
TL
997Trim/Discard
998~~~~~~~~~~~~
40e6c806
DW
999
1000It is good practice to run 'fstrim' (discard) regularly on VMs and containers.
081cb761 1001This releases data blocks that the filesystem isn’t using anymore. It reduces
c78cd2b6
AA
1002data usage and resource load. Most modern operating systems issue such discard
1003commands to their disks regularly. You only need to ensure that the Virtual
1004Machines enable the xref:qm_hard_disk_discard[disk discard option].
081cb761 1005
c998bdf2 1006[[pveceph_scrub]]
081cb761
AA
1007Scrub & Deep Scrub
1008~~~~~~~~~~~~~~~~~~
40e6c806 1009
081cb761
AA
1010Ceph ensures data integrity by 'scrubbing' placement groups. Ceph checks every
1011object in a PG for its health. There are two forms of Scrubbing, daily
b16f8c5f
TL
1012cheap metadata checks and weekly deep data checks. The weekly deep scrub reads
1013the objects and uses checksums to ensure data integrity. If a running scrub
1014interferes with business (performance) needs, you can adjust the time when
b46a49ed 1015scrubs footnote:[Ceph scrubbing {cephdocs-url}/rados/configuration/osd-config-ref/#scrubbing]
081cb761
AA
1016are executed.
1017
1018
40e6c806 1019Ceph Monitoring and Troubleshooting
10df14fb 1020-----------------------------------
40e6c806
DW
1021
1022It is important to continuously monitor the health of a Ceph deployment from the
1023beginning, either by using the Ceph tools or by accessing
10df14fb 1024the status through the {pve} link:api-viewer/index.html[API].
6ff32926 1025
40e6c806 1026The following Ceph commands can be used to see if the cluster is healthy
10df14fb 1027('HEALTH_OK'), if there are warnings ('HEALTH_WARN'), or even errors
40e6c806 1028('HEALTH_ERR'). If the cluster is in an unhealthy state, the status commands
620d6725 1029below will also give you an overview of the current events and actions to take.
6ff32926
AA
1030
1031----
10df14fb
TL
1032# single time output
1033pve# ceph -s
1034# continuously output status changes (press CTRL+C to stop)
1035pve# ceph -w
6ff32926
AA
1036----
1037
40e6c806
DW
1038To get a more detailed view, every Ceph service has a log file under
1039`/var/log/ceph/`. If more detail is required, the log level can be
b46a49ed 1040adjusted footnote:[Ceph log and debugging {cephdocs-url}/rados/troubleshooting/log-and-debug/].
6ff32926
AA
1041
1042You can find more information about troubleshooting
b46a49ed 1043footnote:[Ceph troubleshooting {cephdocs-url}/rados/troubleshooting/]
620d6725 1044a Ceph cluster on the official website.
6ff32926
AA
1045
1046
0840a663
DM
1047ifdef::manvolnum[]
1048include::pve-copyright.adoc[]
1049endif::manvolnum[]