CephNotes

Some notes about Ceph
Laurent Barbe @SIB

Samba shadow_copy and Ceph RBD

I add script to create snapshot on rbd for use with samba shadow_copy2. For more details go on https://github.com/ksperis/autosnap-rbd-shadow-copy

How to use :

Before you need to have ceph cluster running and samba installed.

Verify admin access to the ceph cluster : (should not return error)

$ rbd ls …

Test ceph persistant rbd device

Create persistant rbd device

Create block device and map it with /etc/ceph/rbdmap

$ rbd create rbd/myrbd --size=1024
$ echo "rbd/myrbd" >> /etc/ceph/rbdmap
$ service rbdmap reload
[ ok ] Starting RBD Mapping: rbd/myrbd.
[ ok ] Mounting all filesystems...done.

View rbd mapped :

$ rbd showmapped
id pool image snap device …

Don't forget unmap before remove rbd

$ rbd rm rbd/myrbd
Removing image: 99% complete...failed.2013-08-02 14:07:17.530470 7f3ba2692760 -1 librbd: error removing header: (16) Device or resource busy
rbd: error: image still has watchers
This means the image is still open or the client using it crashed. Try again after closing/unmapping it …

Convert RBD to format v2

Simple Import / Export

Don't forget to stop IO before sync and unmap rbd before rename.

$ rbd export rbd/myrbd - | rbd import --image-format 2 - rbd/myrbd_v2
$ rbd mv rbd/myrbd rbd/myrbd_old
$ rbd mv rbd/myrbd_v2 rbd/myrbd

Check :

$ rbd info rbd/myrbd
$ rbd image 'myrbd':
    size 102400 KB in …

Remove snapshot before rbd

$ rbd rm rbd/myrbd
2013-07-30 14:10:13.341184 7f9e11922760 -1 librbd: image has snapshots - not removing
Removing image: 0% complete...failed.
rbd: image has snapshots - these must be deleted with 'rbd snap purge' before the image can be removed.
$ rbd snap ls rbd/myrbd
SNAPID NAME       SIZE 
    10 …