Knowledge
Ceph's three storage types: RBD, CephFS and RGW, and which to choose
- RBD gives block devices (virtual machines, databases), CephFS gives a directory shared by many machines, and RGW gives objects through the S3 or Swift protocols.
- All three sit on the same RADOS cluster and use their own pools; each pool must be tagged with a matching "application".
- Choose by how your application accesses data: blocks, files or HTTP objects.
Introduction
A Ceph cluster does not do just one thing. The same OSDs can serve disks to virtual machines, a shared directory to a group of machines, and an object store to web applications. The foundations (MON, OSD, CRUSH, pools, PGs) are covered in Ceph architecture: MON, OSD, MGR and how CRUSH places data; this article focuses on the three "doors" and how to choose between them.
Each door uses its own pools. According to the Ceph documentation, every pool must be associated with an application before use, with the command:
ceph osd pool application enable <pool-name> <application>
where the application is rbd, cephfs or rgw. CephFS and RGW pools are usually tagged automatically, while an RBD pool should be initialized with the rbd pool init command.
RBD: block devices
RBD (RADOS Block Device) provides "images", virtual disks of a fixed size that a server or virtual machine sees like an ordinary disk and then formats with a file system. An image's data is split into many objects spread over the OSDs, so one image is not limited by a single physical disk.
Use it for: virtual machine disks, container volumes, databases that need a private disk per machine.
Minimal hands-on
Run this on a machine with cluster admin rights (for example inside cephadm shell). The pool and image names below are only examples.
# create a pool (leave the PG count to the autoscaler) and initialize it for RBD
ceph osd pool create vm-disks
rbd pool init vm-disks
# create a 1024 MB image (the default unit is megabytes)
rbd create --size 1024 vm-disks/disk01
# list and inspect
rbd ls vm-disks
rbd info vm-disks/disk01
Remove an image with rbd rm vm-disks/disk01. This deletes the data permanently; if you want a way back, first use rbd trash mv vm-disks/disk01 to move it to the trash, and run rbd trash rm only when you are sure.
RGW: objects through S3 and Swift
RGW (RADOS Gateway) is an HTTP service named radosgw that sits between applications and the cluster. According to the documentation, it supports a large subset of the Amazon S3 API and of the OpenStack Swift API; the two APIs share one namespace, so data written through one can be read through the other. RGW has its own user management and does not use an MDS.
Create a user (example-user is just an illustrative name):
radosgw-admin user create --uid=example-user --display-name="Example User"
The output contains a keys array with an access_key and a secret_key for use with any S3-compatible client. Treat these two keys like passwords: do not paste them into documents, code repositories or chat channels.
The S3 protocol itself (request signing, presigned URLs, bucket policies) is the same as for any S3 service, so this article does not repeat it; see S3 request signing, presigned URLs and bucket access policies. To understand why objects differ from files, see Objects, buckets and keys in object storage: how they differ from files and folders.
Use it for: images, backups, files uploaded to a web application, or anything accessed over HTTP that does not need partial in-place edits.
Which one to choose?
| Question | Suggestion |
|---|---|
| Does the operating system need its own "disk"? | RBD |
| Do many machines read and write one directory tree? | CephFS |
| Does the application speak S3 or Swift over HTTP? | RGW |
A few practical rules:
- Do not force CephFS to act as an object store for a web application; RGW was made for that.
- Do not attach the same RBD image to two machines writing at once with an ordinary file system; ordinary file systems are not designed for several writers and the data will be corrupted.
- A pool using erasure coding as the data pool for RBD or CephFS needs
allow_ec_overwritesenabled; read the documentation carefully before taking that route.
Summary
RBD, CephFS and RGW are three ways of accessing the same RADOS store. Choose according to how your application reads and writes data, create a separate pool for each type, and remember to tag the pool with the right "application". Once the cluster is running, the next important job is monitoring; see the next article on cluster health monitoring and handling a failed OSD.
This article is only an explanation; specific commands may differ by Ceph release, so check the documentation for the release you use.