After discussing what GlusterFS snapshots are, what are their pre-requisites, and what goes behind creation of a snapshot, it's time we actually created one, and familiarize ourselves with it.
To begin with let's create a volume called test_vol.
# gluster volume create test_vol replica 3 VM1:/brick/brick-dirs/brick VM2:/brick/brick-dirs/brick VM3:/brick/brick-dirs/brick
volume create: test_vol: success: please start the volume to access data
#
# gluster volume start test_vol
volume start: test_vol: success
#
# gluster volume info test_vol
Volume Name: test_vol
Type: Replicate
Volume ID: 09e773c9-e846-4568-a12d-6efb1cecf8cf
Status: Started
Number of Bricks: 1 x 3 = 3
Transport-type: tcp
Bricks:
Brick1: VM1:/brick/brick-dirs/brick
Brick2: VM2:/brick/brick-dirs/brick
Brick3: VM3:/brick/brick-dirs/brick
Options Reconfigured:
transport.address-family: inet
performance.readdir-ahead: on
nfs.disable: on
#
As you can see, we created a 1x3 replica volume, and started it. We are now primed to take our snapshot of this volume. But before, we do so let's add some data to the volume.
# mount -t glusterfs VM1:/test_vol /mnt/test-vol-mnt/
#
# cd /mnt/test-vol-mnt
#
# ls -lrt
total 0
# touch file1
# ls -lrt
total 0
-rw-r--r-- 1 root root 0 Jun 24 13:39 file1
#
So we have successfully mounted our volume and created(touched) a file called file1. Now we will take a snapshot of 'test_vol' and we will call it 'snap1'.
# gluster snapshot create snap1 test_vol
snapshot create: success: Snap snap1_GMT-2016.06.24-08.12.42 created successfully
#
That's weird isn't it. I asked it to create a snapshot called snap1, and it created a snapshot called snap1_GMT-2016.06.24-08.12.42. What happened is it actually created a snapshot called snap1 and appended the snap's name with the timestamp of it's creation. This is the default naming convention of GlusterFS snapshots, and like everything else it it so for a couple of reasons.- This naming format is essential to support Volume Shadow Copy Service Support in GlusterFS volumes.
- The reason for keeping it as default naming convention is that it is more informative than just a name. Scrolling through a list of snapshots not only gives you the thoughtful name you have chosen for it, but also the time the snapshot was created, which makes it so much more relatable to you, and gives you more clarity to decide what to do with the said snapshot.
# gluster snapshot create snap1 test_vol no-timestamp
snapshot create: success: Snap snap1 created successfully
#
So there you go. Congratulation on creating your first GlusterFS snapshot. Now what do you do with it, or rather what all can you do with it. Let's ask for some help.
# gluster snapshot help
snapshot activate <snapname> [force] - Activate snapshot volume.
snapshot clone <clonename> <snapname> - Snapshot Clone.
snapshot config [volname] ([snap-max-hard-limit <count>] [snap-max-soft-limit <percent>]) | ([auto-delete <enable|disable>])| ([activate-on-create <enable|disable>]) - Snapshot Config.
snapshot create <snapname> <volname> [no-timestamp] [description <description>] [force] - Snapshot Create.
snapshot deactivate <snapname> - Deactivate snapshot volume.
snapshot delete (all | snapname | volume <volname>) - Snapshot Delete.
snapshot help - display help for snapshot commands
snapshot info [(snapname | volume <volname>)] - Snapshot Info.
snapshot list [volname] - Snapshot List.
snapshot restore <snapname> - Snapshot Restore.
snapshot status [(snapname | volume <volname>)] - Snapshot Status.
#
Quite the buffet isn't it. So let's first see what snapshots do we have here. gluster snapshot list will do the trick for us.The list command will display all the snapshots in the trusted pool. Adding a volume's name along with the list command will list all snapshots of that particular volume only. As we have only one volume now, it shows the same result for both. It helps provide more clarity when you have a couple of volumes, and each volume has a number of snapshots.# gluster snapshot list
snap1_GMT-2016.06.24-08.12.42
snap1
#
# gluster snapshot list test_vol
snap1_GMT-2016.06.24-08.12.42
snap1
#
We have previously discussed that a GlusterFS snapshot is like a GlusterFS volume. Just like a regular volume you can mount it, delete it, and even see it's status. So let's see the status of our snapshots.
# gluster snapshot status
Snap Name : snap1_GMT-2016.06.24-08.12.42
Snap UUID : 26d1455d-1d58-4c39-9efa-822d9397088a
Brick Path : VM1:/var/run/gluster/snaps/f4b2ae1fbf414c8383c3b198dd42e7d7/brick1/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 95.81
LV Size : 616.00m
Brick Path : VM2:/var/run/gluster/snaps/f4b2ae1fbf414c8383c3b198dd42e7d7/brick2/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 3.45
LV Size : 616.00m
Brick Path : VM3:/var/run/gluster/snaps/f4b2ae1fbf414c8383c3b198dd42e7d7/brick3/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 3.43
LV Size : 616.00m
Snap Name : snap1
Snap UUID : 73489d9b-c370-4687-8be9-fc094ee78d0a
Brick Path : VM1:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick1/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 95.81
LV Size : 616.00m
Brick Path : VM2:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick2/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 3.45
LV Size : 616.00m
Brick Path : VM3:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick3/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 3.43
LV Size : 616.00m
# gluster snapshot status snap1
Snap Name : snap1
Snap UUID : 73489d9b-c370-4687-8be9-fc094ee78d0a
Brick Path : VM1:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick1/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 95.81
LV Size : 616.00m
Brick Path : VM2:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick2/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 3.45
LV Size : 616.00m
Brick Path : VM2:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick3/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 3.43
LV Size : 616.00m
The status itself gives us a wealth of information about each snapshot brick like the volume group, the data percentage, the LV Size. It also tells us if the brick is running or not, and if it is what is the PID of the brick. Interestingly we see that none of the bricks are running. This is the default behaviour of GlusterFS snapshots, where a newly created snapshot is in deactivated state(analogous to the Created/Stopped state of a GlusterFS volume), where none of it's bricks are running. In order to start the snap brick process we will have to activate the snapshot.
# gluster snapshot activate snap1
Snapshot activate: snap1: Snap activated successfully
#
# gluster snapshot status snap1
Snap Name : snap1
Snap UUID : 73489d9b-c370-4687-8be9-fc094ee78d0a
Brick Path : VM1:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick1/brick
Volume Group : snap_lvgrp
Brick Running : Yes
Brick PID : 29250
Data Percentage : 95.81
LV Size : 616.00m
Brick Path : VM1:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick2/brick
Volume Group : snap_lvgrp
Brick Running : Yes
Brick PID : 12616
Data Percentage : 3.45
LV Size : 616.00m
Brick Path : VM1:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick3/brick
Volume Group : snap_lvgrp
Brick Running : Yes
Brick PID : 3058
Data Percentage : 3.43
LV Size : 616.00m
# gluster snapshot deactivate snap1
Deactivating snap will make its data inaccessible. Do you want to continue? (y/n) y
Snapshot deactivate: snap1: Snap deactivated successfully
#
# gluster snapshot status snap1
Snap Name : snap1
Snap UUID : 73489d9b-c370-4687-8be9-fc094ee78d0a
Brick Path : VM1:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick1/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 95.81
LV Size : 616.00m
Brick Path : VM2:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick2/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 3.45
LV Size : 616.00m
Brick Path : VM3:/var/run/gluster/snaps/d5171e51e1ef407292ee4e24677385cb/brick3/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 3.43
LV Size : 616.00m
Uptill now we have barely grazed the surface. There's delete, restore, config, and a whole lot more. We will be covering these in future posts.