Monitoring OSDs and PGs

High availability and high reliability require a fault-tolerant approach tomanaging hardware and software issues. Ceph has no single point-of-failure, andcan service requests for data in a “degraded” mode. Ceph’s data placementintroduces a layer of indirection to ensure that data doesn’t bind directly toparticular OSD addresses. This means that tracking down system faults requiresfinding the placement group and the underlying OSDs at root of the problem.

Tip

A fault in one part of the cluster may prevent you from accessing aparticular object, but that doesn’t mean that you cannot access other objects.When you run into a fault, don’t panic. Just follow the steps for monitoringyour OSDs and placement groups. Then, begin troubleshooting.

Ceph is generally self-repairing. However, when problems persist, monitoringOSDs and placement groups will help you identify the problem.

Monitoring OSDs

An OSD’s status is either in the cluster (in) or out of the cluster(out); and, it is either up and running (up), or it is down and notrunning (down). If an OSD is up, it may be either in the cluster(you can read and write data) or it is out of the cluster. If it wasin the cluster and recently moved out of the cluster, Ceph will migrateplacement groups to other OSDs. If an OSD is out of the cluster, CRUSH willnot assign placement groups to the OSD. If an OSD is down, it should also beout.

Note

If an OSD is down and in, there is a problem and the clusterwill not be in a healthy state.

Monitoring OSDs and PGs - 图1

If you execute a command such as ceph health, ceph -s or ceph -w,you may notice that the cluster does not always echo back HEALTH OK. Don’tpanic. With respect to OSDs, you should expect that the cluster will NOTecho HEALTH OK in a few expected circumstances:

  • You haven’t started the cluster yet (it won’t respond).

  • You have just started or restarted the cluster and it’s not ready yet,because the placement groups are getting created and the OSDs are inthe process of peering.

  • You just added or removed an OSD.

  • You just have modified your cluster map.

An important aspect of monitoring OSDs is to ensure that when the clusteris up and running that all OSDs that are in the cluster are up andrunning, too. To see if all OSDs are running, execute:

  1. ceph osd stat

The result should tell you the total number of OSDs (x),how many are up (y), how many are in (z) and the map epoch (eNNNN).

  1. x osds: y up, z in; epoch: eNNNN

If the number of OSDs that are in the cluster is more than the number ofOSDs that are up, execute the following command to identify the ceph-osddaemons that are not running:

  1. ceph osd tree
  1. #ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
  2. -1 2.00000 pool openstack
  3. -3 2.00000 rack dell-2950-rack-A
  4. -2 2.00000 host dell-2950-A1
  5. 0 ssd 1.00000 osd.0 up 1.00000 1.00000
  6. 1 ssd 1.00000 osd.1 down 1.00000 1.00000

Tip

The ability to search through a well-designed CRUSH hierarchy may helpyou troubleshoot your cluster by identifying the physical locations faster.

If an OSD is down, start it:

  1. sudo systemctl start ceph-osd@1

See OSD Not Running for problems associated with OSDs that stopped, or won’trestart.

PG Sets

When CRUSH assigns placement groups to OSDs, it looks at the number of replicasfor the pool and assigns the placement group to OSDs such that each replica ofthe placement group gets assigned to a different OSD. For example, if the poolrequires three replicas of a placement group, CRUSH may assign them toosd.1, osd.2 and osd.3 respectively. CRUSH actually seeks apseudo-random placement that will take into account failure domains you set inyour CRUSH map, so you will rarely see placement groups assigned to nearestneighbor OSDs in a large cluster. We refer to the set of OSDs that shouldcontain the replicas of a particular placement group as the Acting Set. Insome cases, an OSD in the Acting Set is down or otherwise not able toservice requests for objects in the placement group. When these situationsarise, don’t panic. Common examples include:

  • You added or removed an OSD. Then, CRUSH reassigned the placement group toother OSDs–thereby changing the composition of the Acting Set and spawningthe migration of data with a “backfill” process.

  • An OSD was down, was restarted, and is now recovering.

  • An OSD in the Acting Set is down or unable to service requests,and another OSD has temporarily assumed its duties.

Ceph processes a client request using the Up Set, which is the set of OSDsthat will actually handle the requests. In most cases, the Up Set and the ActingSet are virtually identical. When they are not, it may indicate that Ceph ismigrating data, an OSD is recovering, or that there is a problem (i.e., Cephusually echoes a “HEALTH WARN” state with a “stuck stale” message in suchscenarios).

To retrieve a list of placement groups, execute:

  1. ceph pg dump

To view which OSDs are within the Acting Set or the Up Set for a given placementgroup, execute:

  1. ceph pg map {pg-num}

The result should tell you the osdmap epoch (eNNN), the placement group number({pg-num}), the OSDs in the Up Set (up[]), and the OSDs in the acting set(acting[]).

  1. osdmap eNNN pg {raw-pg-num} ({pg-num}) -> up [0,1,2] acting [0,1,2]

Note

If the Up Set and Acting Set do not match, this may be an indicatorthat the cluster rebalancing itself or of a potential problem withthe cluster.

Peering

Before you can write data to a placement group, it must be in an activestate, and it should be in a clean state. For Ceph to determine thecurrent state of a placement group, the primary OSD of the placement group(i.e., the first OSD in the acting set), peers with the secondary and tertiaryOSDs to establish agreement on the current state of the placement group(assuming a pool with 3 replicas of the PG).

Monitoring OSDs and PGs - 图2

The OSDs also report their status to the monitor. See Configuring Monitor/OSDInteraction for details. To troubleshoot peering issues, see PeeringFailure.

Monitoring Placement Group States

If you execute a command such as ceph health, ceph -s or ceph -w,you may notice that the cluster does not always echo back HEALTH OK. Afteryou check to see if the OSDs are running, you should also check placement groupstates. You should expect that the cluster will NOT echo HEALTH OK in anumber of placement group peering-related circumstances:

  • You have just created a pool and placement groups haven’t peered yet.

  • The placement groups are recovering.

  • You have just added an OSD to or removed an OSD from the cluster.

  • You have just modified your CRUSH map and your placement groups are migrating.

  • There is inconsistent data in different replicas of a placement group.

  • Ceph is scrubbing a placement group’s replicas.

  • Ceph doesn’t have enough storage capacity to complete backfilling operations.

If one of the foregoing circumstances causes Ceph to echo HEALTH WARN, don’tpanic. In many cases, the cluster will recover on its own. In some cases, youmay need to take action. An important aspect of monitoring placement groups isto ensure that when the cluster is up and running that all placement groups areactive, and preferably in the clean state. To see the status of allplacement groups, execute:

  1. ceph pg stat

The result should tell you the total number of placement groups (x), how manyplacement groups are in a particular state such as active+clean (y) and theamount of data stored (z).

  1. x pgs: y active+clean; z bytes data, aa MB used, bb GB / cc GB avail

Note

It is common for Ceph to report multiple states for placement groups.

In addition to the placement group states, Ceph will also echo back the amount ofstorage capacity used (aa), the amount of storage capacity remaining (bb), and the totalstorage capacity for the placement group. These numbers can be important in afew cases:

  • You are reaching your near full ratio or full ratio.

  • Your data is not getting distributed across the cluster due to anerror in your CRUSH configuration.

To retrieve a list of placement groups, execute the following:

  1. ceph pg dump

You can also format the output in JSON format and save it to a file:

  1. ceph pg dump -o {filename} --format=json

To query a particular placement group, execute the following:

  1. ceph pg {poolnum}.{pg-id} query

Ceph will output the query in JSON format.

The following subsections describe the common pg states in detail.

Creating

When you create a pool, it will create the number of placement groups youspecified. Ceph will echo creating when it is creating one or moreplacement groups. Once they are created, the OSDs that are part of a placementgroup’s Acting Set will peer. Once peering is complete, the placement groupstatus should be active+clean, which means a Ceph client can begin writingto the placement group.

Monitoring OSDs and PGs - 图3

Peering

When Ceph is Peering a placement group, Ceph is bringing the OSDs thatstore the replicas of the placement group into agreement about the stateof the objects and metadata in the placement group. When Ceph completes peering,this means that the OSDs that store the placement group agree about the currentstate of the placement group. However, completion of the peering process doesNOT mean that each replica has the latest contents.

Active

Once Ceph completes the peering process, a placement group may becomeactive. The active state means that the data in the placement group isgenerally available in the primary placement group and the replicas for readand write operations.

Clean

When a placement group is in the clean state, the primary OSD and thereplica OSDs have successfully peered and there are no stray replicas for theplacement group. Ceph replicated all objects in the placement group the correctnumber of times.

Degraded

When a client writes an object to the primary OSD, the primary OSD isresponsible for writing the replicas to the replica OSDs. After the primary OSDwrites the object to storage, the placement group will remain in a degradedstate until the primary OSD has received an acknowledgement from the replicaOSDs that Ceph created the replica objects successfully.

The reason a placement group can be active+degraded is that an OSD may beactive even though it doesn’t hold all of the objects yet. If an OSD goesdown, Ceph marks each placement group assigned to the OSD as degraded.The OSDs must peer again when the OSD comes back online. However, a client canstill write a new object to a degraded placement group if it is active.

If an OSD is down and the degraded condition persists, Ceph may mark thedown OSD as out of the cluster and remap the data from the down OSDto another OSD. The time between being marked down and being marked outis controlled by mon osd down out interval, which is set to 600 secondsby default.

A placement group can also be degraded, because Ceph cannot find one or moreobjects that Ceph thinks should be in the placement group. While you cannotread or write to unfound objects, you can still access all of the other objectsin the degraded placement group.

Recovering

Ceph was designed for fault-tolerance at a scale where hardware and softwareproblems are ongoing. When an OSD goes down, its contents may fall behindthe current state of other replicas in the placement groups. When the OSD isback up, the contents of the placement groups must be updated to reflect thecurrent state. During that time period, the OSD may reflect a recoveringstate.

Recovery is not always trivial, because a hardware failure might cause acascading failure of multiple OSDs. For example, a network switch for a rack orcabinet may fail, which can cause the OSDs of a number of host machines to fallbehind the current state of the cluster. Each one of the OSDs must recover oncethe fault is resolved.

Ceph provides a number of settings to balance the resource contention betweennew service requests and the need to recover data objects and restore theplacement groups to the current state. The osd recovery delay start settingallows an OSD to restart, re-peer and even process some replay requests beforestarting the recovery process. The osdrecovery thread timeout sets a thread timeout, because multiple OSDs may fail,restart and re-peer at staggered rates. The osd recovery max active settinglimits the number of recovery requests an OSD will entertain simultaneously toprevent the OSD from failing to serve . The osd recovery max chunk settinglimits the size of the recovered data chunks to prevent network congestion.

Back Filling

When a new OSD joins the cluster, CRUSH will reassign placement groups from OSDsin the cluster to the newly added OSD. Forcing the new OSD to accept thereassigned placement groups immediately can put excessive load on the new OSD.Back filling the OSD with the placement groups allows this process to begin inthe background. Once backfilling is complete, the new OSD will begin servingrequests when it is ready.

During the backfill operations, you may see one of several states:backfill_wait indicates that a backfill operation is pending, but is notunderway yet; backfilling indicates that a backfill operation is underway;and, backfill_toofull indicates that a backfill operation was requested,but couldn’t be completed due to insufficient storage capacity. When aplacement group cannot be backfilled, it may be considered incomplete.

The backfill_toofull state may be transient. It is possible that as PGsare moved around, space may become available. The backfill_toofull issimilar to backfill_wait in that as soon as conditions changebackfill can proceed.

Ceph provides a number of settings to manage the load spike associated withreassigning placement groups to an OSD (especially a new OSD). By default,osd_max_backfills sets the maximum number of concurrent backfills to and froman OSD to 1. The backfill full ratio enables an OSD to refuse abackfill request if the OSD is approaching its full ratio (90%, by default) andchange with ceph osd set-backfillfull-ratio command.If an OSD refuses a backfill request, the osd backfill retry intervalenables an OSD to retry the request (after 30 seconds, by default). OSDs canalso set osd backfill scan min and osd backfill scan max to manage scanintervals (64 and 512, by default).

Remapped

When the Acting Set that services a placement group changes, the data migratesfrom the old acting set to the new acting set. It may take some time for a newprimary OSD to service requests. So it may ask the old primary to continue toservice requests until the placement group migration is complete. Once datamigration completes, the mapping uses the primary OSD of the new acting set.

Stale

While Ceph uses heartbeats to ensure that hosts and daemons are running, theceph-osd daemons may also get into a stuck state where they are notreporting statistics in a timely manner (e.g., a temporary network fault). Bydefault, OSD daemons report their placement group, up through, boot and failurestatistics every half second (i.e., 0.5), which is more frequent than theheartbeat thresholds. If the Primary OSD of a placement group’s acting setfails to report to the monitor or if other OSDs have reported the primary OSDdown, the monitors will mark the placement group stale.

When you start your cluster, it is common to see the stale state untilthe peering process completes. After your cluster has been running for awhile,seeing placement groups in the stale state indicates that the primary OSDfor those placement groups is down or not reporting placement group statisticsto the monitor.

Identifying Troubled PGs

As previously noted, a placement group is not necessarily problematic justbecause its state is not active+clean. Generally, Ceph’s ability to selfrepair may not be working when placement groups get stuck. The stuck statesinclude:

  • Unclean: Placement groups contain objects that are not replicated thedesired number of times. They should be recovering.

  • Inactive: Placement groups cannot process reads or writes because theyare waiting for an OSD with the most up-to-date data to come back up.

  • Stale: Placement groups are in an unknown state, because the OSDs thathost them have not reported to the monitor cluster in a while (configuredby mon osd report timeout).

To identify stuck placement groups, execute the following:

  1. ceph pg dump_stuck [unclean|inactive|stale|undersized|degraded]

See Placement Group Subsystem for additional details. To troubleshootstuck placement groups, see Troubleshooting PG Errors.

Finding an Object Location

To store object data in the Ceph Object Store, a Ceph client must:

  • Set an object name

  • Specify a pool

The Ceph client retrieves the latest cluster map and the CRUSH algorithmcalculates how to map the object to a placement group, and then calculateshow to assign the placement group to an OSD dynamically. To find the objectlocation, all you need is the object name and the pool name. For example:

  1. ceph osd map {poolname} {object-name} [namespace]

As the cluster evolves, the object location may change dynamically. One benefitof Ceph’s dynamic rebalancing is that Ceph relieves you from having to performthe migration manually. See the Architecture section for details.