Remove objects from Ceph pool without deleting pool

I recently wanted to cleanup a few of the pools I have been using for rados benchmarking. I did not want to do delete the pools, just the objects inside the pool.

If you are trying to clear up ‘rados bench’ objects you can use something like this:

‘rados -p temp_pool cleanup --prefix benchmark’

If you are trying to remove all the objects from a pool that does not prefix the object names with:

****WARNING THIS WILL ERASE ALL OBJECTS IN YOUR POOL*****
‘for i in `rados -p temp_pool ls`; do echo $i; rados -p temp_pool rm $i; done’

One thought on “Remove objects from Ceph pool without deleting pool

  1. Donny D

    Awesome little script, this helps me cleanup after a failed openstack deployment.

    I changed it a little and added this

    for ii in $(ceph osd pool ls) ; do
    for i in $(rados -p $ii ls); do echo $i; rados -p $ii rm $i; done ;
    done

Leave a Reply

Your email address will not be published. Required fields are marked *