How to perform more operation using rados in Redhat Ceph cluster ?

In this article I am going to show the various operations which can be performed on objects using ceph rados command line.

–> How to copy the content of the pool ?

I have created new pool named pool2
[root@ceph-m3 ~]# ceph osd pool create pool2 16 16
pool ‘pool2’ created
[root@ceph-m3 ~]# rados -p pool2 ls

After creating the new pool I copied the content of pool1 to new pool pool2.

[root@ceph-m3 ~]# rados cppool pool1 pool2
pool1:object1 => pool2:object1
successfully copied pool pool1

Verify the content of new pool, we will find the same object in new pool pool2.
[root@ceph-m3 ~]# rados -p pool2 ls
object1

–> How to see the contents of object ?

I have created new object (object2) in pool1 with content of file as “Hello World”

If we want to see the content of object2 we can use the below command.

[root@ceph-m3 ~]# rados -p pool1 get object2 /tmp/output1.txt

[root@ceph-m3 ~]# cat /tmp/output1.txt
Hello World

–> How to copy the objects in pool with in same pool ?

[root@ceph-m3 ~]# rados -p pool1 cp object2 object3
[root@ceph-m3 ~]# rados -p pool1 get object3 /tmp/output1.txt
[root@ceph-m3 ~]# cat /tmp/output1.txt
Hello World

–> How to get the statistics of object ?

[root@ceph-m3 ~]# rados -p pool1 stat object1
pool1/object1 mtime 1429702481, size 10485760
[root@ceph-m3 ~]# rados -p pool1 stat object2
pool1/object2 mtime 1429702876, size 12

–> How to create snapshot of pool ?

[root@ceph-m3 ~]# rados -p pool1 ls
object3
object2
object1

Created snapshot with name snap1 of pool1.

[root@ceph-m3 ~]# rados -p pool1 mksnap snap1
created pool pool1 snap snap1

We can list the snapshot created for pool using below command.

[root@ceph-m3 ~]# rados -p pool1 lssnap
1       snap1   2015.04.22 07:46:19
1 snaps

I have created one more object in pool1 after creating the snapshot.

[root@ceph-m3 ~]# rados -p pool1 ls
object3
object2
object4
object1

Now, If I am using rollback option we are again back to original state.

[root@ceph-m3 ~]# rados -p pool1 rollback object4 snap1
rolled back pool pool1 to snapshot snap1

[root@ceph-m3 ~]# rados -p pool1 ls
object3
object2
object1

–> How to see the locks present on object ?

Currently I am not having any lock on object.

[root@ceph-m3 ~]# rados -p pool1 lock list object4
{“objname”:”object4″,”locks”:[]}

I am taking lock on object.

[root@ceph-m3 ~]# rados -p pool1 lock get object4 lock1

Again we can issue the same command to see the locks.

[root@ceph-m3 ~]# rados -p pool1 lock list object4
{“objname”:”object4″,”locks”:[{“name”:”lock1″}]}

To know more about the lock which node has obtained lock issue below command.

[root@ceph-m3 ~]# rados -p pool1 lock info object4 lock1
{“name”:”lock1″,”type”:”exclusive”,”tag”:””,”lockers”:[{“name”:”client.9707″,”cookie”:””,”description”:””,”expiration”:”0.000000″,”addr”:”192.168.111.143:0\/1006353″}]}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s