Red Hat Training

A Red Hat training course is available for Red Hat Ceph Storage

Chapter 4. Pools

Ceph clients store data in pools. When you create pools, you are creating an I/O interface for clients to store data. From the perspective of a Ceph client (i.e., block device, gateway, etc.), interacting with the Ceph storage cluster is remarkably simple: create a cluster handle and connect to the cluster; then, create an I/O context for reading and writing objects and their extended attributes.

Create a Cluster Handle and Connect to the Cluster

To connect to the Ceph storage cluster, the Ceph client needs the cluster name (usually ceph by default) and an initial monitor address. Ceph clients usually retrieve these parameters using the default path for the Ceph configuration file and then read it from the file, but a user may also specify the parameters on the command line too. The Ceph client also provides a user name and secret key (authentication is on by default). Then, the client contacts the Ceph monitor cluster and retrieves a recent copy of the cluster map, including its monitors, OSDs and pools.

diag 1f6f4d658a62cdcac60fbbe5725912d1

Create a Pool I/O Context

To read and write data, the Ceph client creates an i/o context to a specific pool in the Ceph storage cluster. If the specified user has permissions for the pool, the Ceph client can read from and write to the specified pool.

diag 3738bb0269828f9885e5a79177836ec9

Ceph’s architecture enables the storage cluster to provide this remarkably simple interface to Ceph clients so that clients may select one of the sophisticated storage strategies you define simply by specifying a pool name and creating an I/O context. Storage strategies are invisible to the Ceph client in all but capacity and performance. Similarly, the complexities of Ceph clients (mapping objects into a block device representation, providing an S3/Swift RESTful service) are invisible to the Ceph storage cluster.

A pool provides you with:

  • Resilience: You can set how many OSD are allowed to fail without losing data. For replicated pools, it is the desired number of copies/replicas of an object. A typical configuration stores an object and one additional copy (i.e., size = 2), but you can determine the number of copies/replicas. For erasure coded pools, it is the number of coding chunks (i.e. m=2 in the erasure code profile)
  • Placement Groups: You can set the number of placement groups for the pool. A typical configuration uses approximately 50-100 placement groups per OSD to provide optimal balancing without using up too many computing resources. When setting up multiple pools, be careful to ensure you set a reasonable number of placement groups for both the pool and the cluster as a whole.
  • CRUSH Rules: When you store data in a pool, a CRUSH ruleset mapped to the pool enables CRUSH to identify a rule for the placement of each object and its replicas (or chunks for erasure coded pools) in your cluster. You can create a custom CRUSH rule for your pool.
  • Snapshots: When you create snapshots with ceph osd pool mksnap, you effectively take a snapshot of a particular pool.
  • Quotas: When you set quotas on a pool with ceph osd pool set-quota you may limit the maximum number of objects or the maximum number of bytes stored in the specified pool.

4.1. Pools and Storage Strategies

To manage pools, you can list, create, and remove pools. You can also view the utilization statistics for each pool.

4.2. List Pools

To list your cluster’s pools, execute:

ceph osd lspools

4.3. Create a Pool

Before creating pools, see the Pool, PG and CRUSH Configuration Reference chapter in the Red Hat Ceph Storage 2 Configuration Guide.

It is better to adjust the default value for the number of placement groups in the Ceph configuration file, as the default value does not have to suit your needs. For example:

osd pool default pg num = 100
osd pool default pgp num = 100

To create a replicated pool, execute:

ceph osd pool create <pool-name> <pg-num> <pgp-num> [replicated] \
         [crush-ruleset-name] [expected-num-objects]

To create an erasure-coded pool, execute:

ceph osd pool create <pool-name> <pg-num> <pgp-num> erasure \
         [erasure-code-profile] [crush-ruleset-name] [expected-num-objects]

Where:

pool-name
Description
The name of the pool. It must be unique.
Type
String
Required
Yes. If not specified, it is set to the value listed in the Ceph configuration file or to the default value.
Default
ceph
pg-num
Description
The total number of placement groups for the pool. See the Placement Groups section and the Ceph Placement Groups (PGs) per Pool Calculator for details on calculating a suitable number. The default value 8 is not suitable for most systems.
Type
Integer
Required
Yes
Default
8
pgp-num
Description
The total number of placement groups for placement purposes. This value must be equal to the total number of placement groups, except for placement group splitting scenarios.
Type
Integer
Required
Yes. If not specified it is set to the value listed in the Ceph configuration file or to the default value.
Default
8
replicated or erasure
Description
The pool type which can be either replicated to recover from lost OSDs by keeping multiple copies of the objects or erasure to get a kind of generalized RAID5 capability. The replicated pools require more raw storage but implement all Ceph operations. The erasure-coded pools require less raw storage but only implement a subset of the available operations.
Type
String
Required
No
Default
replicated
crush-ruleset-name
Description
The name of the crush ruleset for the pool. If specified ruleset does not exist, the creation of the replicated pool fails with the ENOENT error. But the replicated pool will create a new erasure ruleset with the specified name.
Type
String
Required
No
Default
erasure-code for the erasure-coded pool. For the replicated pool, the value of the osd_pool_default_crush_replicated_ruleset variable is used from the Ceph configuration file.
expected-num-objects
Description
The expected number of objects for the pool. By setting this value together with a negative filestore merge threshold variable, the placement group directory is split at the pool creation time to avoid the latency impact to do a runtime directory splitting.
Type
Integer
Required
No
Default
0, no splitting at the pool creation time
erasure-code-profile
Description
For erasure-coded pools only. Use the erasure code profile. It must be an existing profile as defined by the osd erasure-code-profile set variable in the Ceph configuration file. For further information, see the Erasure Code Profiles section.
Type
String
Required
No

When you create a pool, set the number of placement groups to a reasonable value (for example to 100). Consider the total number of placement groups per OSD too. Placement groups are computationally expensive, so performance will degrade when you have many pools with many placement groups, for example, 50 pools with 100 placement groups each. The point of diminishing returns depends upon the power of the OSD host.

See the Placement Groups section and Ceph Placement Groups (PGs) per Pool Calculator for details on calculating an appropriate number of placement groups for your pool.

4.4. Set Pool Quotas

You can set pool quotas for the maximum number of bytes or the maximum number of objects per pool or for both.

ceph osd pool set-quota <pool-name> [max_objects <obj-count>] [max_bytes <bytes>]

For example:

ceph osd pool set-quota data max_objects 10000

To remove a quota, set its value to 0.

Note

In-flight write operations may overrun pool quotas for a short time until Ceph propagates the pool usage across the cluster. This is normal behavior. Enforcing pool quotas on in-flight write operations would impose significant performance penalties.

4.5. Delete a Pool

To delete a pool, execute:

ceph osd pool delete <pool-name> [<pool-name> --yes-i-really-really-mean-it]

If you created your own rulesets and rules for a pool you created, you should consider removing them when you no longer need your pool. If you created users with permissions strictly for a pool that no longer exists, you should consider deleting those users too.

4.6. Rename a Pool

To rename a pool, execute:

ceph osd pool rename <current-pool-name> <new-pool-name>

If you rename a pool and you have per-pool capabilities for an authenticated user, you must update the user’s capabilities (i.e., caps) with the new pool name.

4.7. Show Pool Statistics

To show a pool’s utilization statistics, execute:

rados df

4.8. Make a Snapshot of a Pool

To make a snapshot of a pool, execute:

ceph osd pool mksnap <pool-name> <snap-name>
Warning

If you create a pool snapshot, you will never be able to take RBD image snapshots within the pool and it will be irreversible.

4.9. Remove a Snapshot of a Pool

To remove a snapshot of a pool, execute:

ceph osd pool rmsnap <pool-name> <snap-name>

4.10. Set Pool Values

To set a value to a pool, execute the following command:

ceph osd pool set <pool-name> <key> <value>

The Pool Values section lists all key-values pairs that you can set.

4.11. Get Pool Values

To get a value from a pool, execute the following command:

ceph osd pool get <pool-name> <key>

The Pool Values section lists all key-values pairs that you can get.

4.12. Set the Number of Object Replicas

To set the number of object replicas on a replicated pool, execute the following command:

ceph osd pool set <poolname> size <num-replicas>
Important

The <num-replicas> parameter includes the object itself. If you want to include the object and two copies of the object for a total of three instances of the object, specify 3.

For example:

ceph osd pool set data size 3

You can execute this command for each pool.

Note

An object might accept I/O operations in degraded mode with fewer replicas than specified by the pool size setting. To set a minimum number of required replicas for I/O, use the min_size setting. For example:

ceph osd pool set data min_size 2

This ensures that no object in the data pool will receive I/O with fewer replicas than specified by the min_size setting.

4.13. Get the Number of Object Replicas

To get the number of object replicas, execute the following command:

ceph osd dump | grep 'replicated size'

Ceph will list the pools, with the replicated size attribute highlighted. By default, Ceph creates two replicas of an object, that is a total of three copies, or a size of 3.

4.14. Pool Values

The following list contains key-values pairs that you can set or get. For further information, see the Set Pool Values and Get Pool Values sections.

size
Description
Specifies the number of replicas for objects in the pool. See the Set the Number of Object Replicas section for further details. Applicable for the replicated pools only.
Type
Integer
min_size
Description
Specifies the minimum number of replicas required for I/O. See the Set the Number of Object Replicas section for further details. Applicable for the replicated pools only.
Type
Integer
pg_num
Description
The effective number of placement groups to use when calculating data placement.
Type
Integer
Valid Range
Superior to pg_num current value.
pgp_num
Description
The effective number of placement groups to use when calculating data placement.
Type
Integer
Valid Range
Equal to or less than what specified by the pg_num variable.
crush_ruleset
Description
The ruleset to use for mapping object placement in the cluster.
Type
Integer
hashpspool
Description
Enable or disable the HASHPSPOOL flag on a given pool. With this option enabled, pool hashing and placement group mapping are changed to improve the way pools and placement groups overlap.
Type
Integer
Valid Range
1 enables the flag, 0 disables the flag.
Important

Do not enable this option on production pools of a cluster with a large amount of OSDs and data. All placement groups in the pool would have to be remapped causing too much data movement.

nodelete
Description
Set/Unset NODELETE flag on a given pool.
Type
Integer
Valid Range
1 sets flag, 0 unsets flag.
nopgchange
Description
Set/Unset NOPGCHANGE flag on a given pool.
Type
Integer
Valid Range
1 sets flag, 0 unsets flag.
nosizechange
Description
Set/Unset NOSIZECHANGE flag on a given pool.
Type
Integer
Valid Range
1 sets flag, 0 unsets flag.
write_fadvise_dontneed
Description
Set/Unset WRITE_FADVISE_DONTNEED flag on a given pool.
Type
Integer
Valid Range
1 sets flag, 0 unsets flag.
noscrub
Description
Set/Unset NOSCRUB flag on a given pool.
Type
Integer
Valid Range
1 sets flag, 0 unsets flag.
nodeep_scrub
Description
Set/Unset NODEEP_SCRUB flag on a given pool.
Type
Integer
Valid Range
1 sets flag, 0 unsets flag.
hit_set_type
Description
Enables hit set tracking for cache pools.
Type
String
Valid Settings
bloom, explicit_hash, explicit_object
Default
bloom. Other values are for testing.
hit_set_count
Description
The number of hit sets to store for cache pools. The higher the number, the more RAM consumed by the ceph-osd daemon.
Type
Integer
Valid Range
1. Agent doesn’t handle > 1 yet.
hit_set_period
Description
The duration of a hit set period in seconds for cache pools. The higher the number, the more RAM consumed by the ceph-osd daemon.
Type
Integer
Example
3600 1hr
hit_set_fpp
Description
The false positive probability for the bloom hit set type.
Type
Double
Valid Range
0.0 - 1.0
Default
0.05
cache_target_dirty_ratio
Description
The percentage of the cache pool containing modified (dirty) objects before the cache tiering agent will flush them to the backing storage pool.
Type
Double
Default
.4
cache_target_dirty_high_ratio
Description
The percentage of the cache pool containing modified (dirty) objects before the cache tiering agent will flush them to the backing storage pool with a higher speed.
Type
Double
Default
.6
cache_target_full_ratio
Description
The percentage of the cache pool containing unmodified (clean) objects before the cache tiering agent will evict them from the cache pool.
Type
Double
Default
.8
target_max_bytes
Description
Ceph will begin flushing or evicting objects when the max_bytes threshold is triggered.
Type
Integer
Example
1000000000000 #1-TB
target_max_objects
Description
Ceph will begin flushing or evicting objects when the max_objects threshold is triggered.
Type
Integer
Example
1000000 #1M objects
hit_set_grade_decay_rate
Description
Temperature decay rate between two successive hit_sets.
Type
Integer
Valid Range
0 - 100
Default
20
hit_set_search_last_n
Description
Count at most N appearance in hit_sets for temperature calculation.
Type
Integer
Valid Range
0 - hit_set_count
Default
1
cache_min_flush_age
Description
The time (in seconds) before the cache tiering agent will flush an object from the cache pool to the storage pool.
Type
Integer
Example
600 10min
cache_min_evict_age
Description
The time (in seconds) before the cache tiering agent will evict an object from the cache pool.
Type
Integer
Example
1800 30min
fast_read
Description
On a pool that uses erasure coding, if this flag is enabled, the read request issues subsequent reads to all shards, and wait until it receives enough shards to decode to serve the client. In the case of the jerasure and isa erasure plug-ins, once the first K replies return, client’s request is served immediately using the data decoded from these replies. This helps to allocate some resources for better performance. Currently this flag is only supported for erasure coding pools.
Type
Boolean
Defaults
0
scrub_min_interval
Description
The minimum interval in seconds for pool scrubbing when load is low. If it is 0, Ceph uses the osd_scrub_min_interval setting from the Ceph configuration.
Type
Double
Default
0
scrub_max_interval
Description
The maximum interval in seconds for pool scrubbing irrespective of cluster load. If it is 0, Ceph uses the osd_scrub_max_interval setting from the Ceph configuration.
Type
Double
Default
0
deep_scrub_interval
Description
The interval in seconds for pool “deep” scrubbing. If it is 0, Ceph uses the osd_deep_scrub_interval setting from the Ceph configuration.
Type
Double
Default
0