Let's run through some example uses for the ceph-objectstore-tool:
- Find incomplete PGs on your Ceph cluster. Using this command, you can get the PG ID and its acting set:
# ceph health detail | grep incomplete
- Using the acting set, you can locate the OSD host:
# ceph osd find <osd_number>
- Log in to the OSD node and stop the OSD that you intend to work on:
# systemctl stop ceph-osd@<id>
The following sections describe the OSD and placement group functions that you can use with the ceph-objectstore-tool:
- To identify the objects within an OSD, execute the following. The tool will output all objects, irrespective of their placement groups:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --op list
- To identify the objects within a placement group, execute the following:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --pgid <pgid> --op list
- To list the placement groups stored on an OSD, execute the following:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --op list-pgs
- If you know the object ID that you are looking for, specify it to find the PG ID:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --op list <object-id>
- Retrieve information about a particular placement group:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --pgid <pg-id> --op info
- Retrieve a log of operations on a placement group:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --pgid <pg-id> --op log
Removing a placement group is a risky operation and may cause data loss; use this feature with caution. If you have a corrupt placement group on an OSD that prevents the peering or starting of the OSD service, before removing the placement group, ensure that you have a valid copy of the placement group on another OSD. As a precaution, before removing the PG, you can also take a backup of the PG by exporting it to a file:
- To remove a placement group, execute the following command:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --pgid <pg-id> --op remove
- To export a placement group to a file, execute the following:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --pgid <pg-id>
--file /path/to/file --op export
- To import a placement group from a file, execute the following:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --file </path/to/file>
--op import
- An OSD may have objects marked as lost. To list the lost or unfound objects, execute the following:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --op list-lost
- To find objects marked as lost for a single placement group, specify pgid:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --pgid <pgid> --op list-lost
- The ceph-objectstore-tool is purposely used to fix the PG's lost objects. An OSD may have objects marked lost. To remove the lost setting for the lost objects of a placement group, execute the following:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --op fix-lost
- To fix lost objects for a particular placement group, specify pgid:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --pgid <pg-id> --op fix-lost
- If you know the identity of the lost object you want to fix, specify the object ID:
# ceph-objectstore-tool --data-path </path/to/osd>
--journal-path </path/to/journal> --op fix-lost <object-id>