Now that we know how to create GlusterFS snapshots, it will be handy to know, how to delete them as well. Right now I have a cluster with two volumes at my disposal. As can be seen below, each volume has 1 brick.
# gluster volume info
Volume Name: test_vol
Type: Distribute
Volume ID: 74e21265-7060-48c5-9f32-faadaf986d85
Status: Started
Number of Bricks: 1
Transport-type: tcp
Bricks:
Brick1: VM1:/brick/brick-dirs1/brick
Options Reconfigured:
transport.address-family: inet
performance.readdir-ahead: on
nfs.disable: on
Volume Name: test_vol1
Type: Distribute
Volume ID: b6698e0f-748f-4667-8956-ec66dd91bd84
Status: Started
Number of Bricks: 1
Transport-type: tcp
Bricks:
Brick1: VM2:/brick/brick-dirs/brick
Options Reconfigured:
transport.address-family: inet
performance.readdir-ahead: on
nfs.disable: on
We are going to take a bunch of snapshots for both these volumes using the create command.
# gluster snapshot create snap1 test_vol no-timestamp
snapshot create: success: Snap snap1 created successfully
# gluster snapshot create snap2 test_vol no-timestamp
snapshot create: success: Snap snap2 created successfully
# gluster snapshot create snap3 test_vol no-timestamp
snapshot create: success: Snap snap3 created successfully
# gluster snapshot create snap4 test_vol1 no-timestamp
snapshot create: success: Snap snap4 created successfully
# gluster snapshot create snap5 test_vol1 no-timestamp
snapshot create: success: Snap snap5 created successfully
# gluster snapshot create snap6 test_vol1 no-timestamp
snapshot create: success: Snap snap6 created successfully
# gluster snapshot list
snap1
snap2
snap3
snap4
snap5
snap6
#
Now we have 3 snapshots for each volume. To delete a snapshot we have to use the delete command along with the snap name.
# gluster snapshot delete snap1
Deleting snap will erase all the information about the snap. Do you still want to continue? (y/n) y
snapshot delete: snap1: snap removed successfully
# gluster snapshot list
snap2
snap3
snap4
snap5
snap6
#
We can also choose to delete all snapshots that belong to a particular volume. Before doing that let's see what snapshots are present for volume "test_vol". Apart from snapshot list, there is also snapshot info command that provides more elaborate details of snapshots. Like snapshot list, snapshot info can also take volume name as an option to show information of snapshots belonging to only that volume.
# gluster snapshot list test_vol
snap2
snap3
# gluster snapshot info volume test_vol
Volume Name : test_vol
Snaps Taken : 2
Snaps Available : 254
Snapshot : snap2
Snap UUID : d17fbfac-1cb1-4276-9b96-0b73b90fb545
Created : 2016-07-15 09:32:07
Status : Stopped
Snapshot : snap3
Snap UUID : 0f319761-eca2-491e-b678-75b56790f3a0
Created : 2016-07-15 09:32:12
Status : Stopped
#
As we can see from both list and info command, test_vol has 2 snapshots snap2, and snap3. Instead of individually deleting these snapshots one by one, we can choose to delete all snapshots that belong to a particular volume, in this case test_vol.
# gluster snapshot delete volume test_vol
Volume (test_vol) contains 2 snapshot(s).
Do you still want to continue and delete them? (y/n) y
snapshot delete: snap2: snap removed successfully
snapshot delete: snap3: snap removed successfully
#
# gluster snapshot list
snap4
snap5
snap6
# gluster snapshot list test_vol
No snapshots present
# gluster snapshot info volume test_vol
Volume Name : test_vol
Snaps Taken : 0
Snaps Available : 256
#
With the above volume option we successfully deleted both the snapshots of test_vol with a single command. Now only 3 snapshots remain, and both belong to volume "test_vol1". Before proceeding further let's create one more snapshot for volume "test_vol".
# gluster snapshot create snap7 test_vol no-timestamp
snapshot create: success: Snap snap7 created successfully
# gluster snapshot list
snap4
snap5
snap6
snap7
#
With this, we have four snapshots belonging, three of which belong to test_vol1, and one belongs to test_vol. Now with the 'delete all' command we will be able to delete all snapshots present irrespective of which volumes they belong to.
# gluster snapshot delete all
System contains 4 snapshot(s).
Do you still want to continue and delete them? (y/n) y
snapshot delete: snap4: snap removed successfully
snapshot delete: snap5: snap removed successfully
snapshot delete: snap6: snap removed successfully
snapshot delete: snap7: snap removed successfully
# gluster snapshot list
No snapshots present
#
So that is how you delete GlusterFS snapshots. There are some configurable options for Gluster snapshots, which can be viewed and modified using the snapshot config option.
# gluster snapshot config
Snapshot System Configuration:
snap-max-hard-limit : 256
snap-max-soft-limit : 90%
auto-delete : disable
activate-on-create : disable
Snapshot Volume Configuration:
Volume : test_vol
snap-max-hard-limit : 256
Effective snap-max-hard-limit : 256
Effective snap-max-soft-limit : 230 (90%)
Volume : test_vol1
snap-max-hard-limit : 256
Effective snap-max-hard-limit : 256
Effective snap-max-soft-limit : 230 (90%)
#
Just running the config option, as shown above displays the current configuration in the system. What we are looking at are the default configuration values. There are four different configurable parameters. Let's go through them one by one.- snap-max-hard-limit: Set by default as 256, the snap-max-hard-limit is the maximum number of snapshots that can be present in the system. Once a volume reaches this limit, in terms of the number of snapshots it has, we are not allowed to create any more snapshot, unless we either delete a snapshot, or increase this limit.
# gluster snapshot config test_vol snap-max-hard-limit 2
Changing snapshot-max-hard-limit will limit the creation of new snapshots if they exceed the new limit.
Do you want to continue? (y/n) y
snapshot config: snap-max-hard-limit for test_vol set successfully
# gluster snapshot config
Snapshot System Configuration:
snap-max-hard-limit : 256
snap-max-soft-limit : 90%
auto-delete : disable
activate-on-create : disable
Snapshot Volume Configuration:
Volume : test_vol
snap-max-hard-limit : 2
Effective snap-max-hard-limit : 2
Effective snap-max-soft-limit : 1 (90%)
Volume : test_vol1
snap-max-hard-limit : 256
Effective snap-max-hard-limit : 256
Effective snap-max-soft-limit : 230 (90%)
#
#
# gluster snapshot info volume test_vol
Volume Name : test_vol
Snaps Taken : 0
Snaps Available : 2
## gluster snapshot create snap1 test_vol no-timestamp
snapshot create: success: Snap snap1 created successfully
# gluster snapshot create snap2 test_vol no-timestamp
snapshot create: success: Snap snap2 created successfully
Warning: Soft-limit of volume (test_vol) is reached. Snapshot creation is not possible once hard-limit is reached.
#
#
# gluster snapshot info volume test_vol
Volume Name : test_vol
Snaps Taken : 2
Snaps Available : 0
Snapshot : snap1
Snap UUID : 2ee5f237-d4d2-47a6-8a0c-53a887b33b26
Created : 2016-07-15 10:12:55
Status : Stopped
Snapshot : snap2
Snap UUID : 2c74925e-4c75-4824-b39e-7e1e22f3b758
Created : 2016-07-15 10:13:02
Status : Stopped
#
# gluster snapshot create snap3 test_vol no-timestamp
snapshot create: failed: The number of existing snaps has reached the effective maximum limit of 2, for the volume (test_vol). Please delete few snapshots before taking further snapshots.
Snapshot command failed
## gluster snapshot delete snap1
Deleting snap will erase all the information about the snap. Do you still want to continue? (y/n) y
snapshot delete: snap1: snap removed successfully
# gluster snapshot create snap3 test_vol no-timestamp
snapshot create: success: Snap snap3 created successfully
Warning: Soft-limit of volume (test_vol) is reached. Snapshot creation is not possible once hard-limit is reached.
#
# gluster snapshot config test_vol snap-max-hard-limit 3
Changing snapshot-max-hard-limit will limit the creation of new snapshots if they exceed the new limit.
Do you want to continue? (y/n) y
snapshot config: snap-max-hard-limit for test_vol set successfully
# gluster snapshot info volume test_vol
Volume Name : test_vol
Snaps Taken : 2
Snaps Available : 1
Snapshot : snap2
Snap UUID : 2c74925e-4c75-4824-b39e-7e1e22f3b758
Created : 2016-07-15 10:13:02
Status : Stopped
Snapshot : snap3
Snap UUID : bfd080f3-848e-490a-83ed-066858bd96fc
Created : 2016-07-15 10:19:17
Status : Stopped
# gluster snapshot create snap4 test_vol no-timestamp
snapshot create: success: Snap snap4 created successfully
Warning: Soft-limit of volume (test_vol) is reached. Snapshot creation is not possible once hard-limit is reached.
## gluster snapshot config test_vol snap-max-hard-limit 1
Changing snapshot-max-hard-limit will limit the creation of new snapshots if they exceed the new limit.
Do you want to continue? (y/n) y
snapshot config: snap-max-hard-limit for test_vol set successfully
# gluster snapshot config
Snapshot System Configuration:
snap-max-hard-limit : 256
snap-max-soft-limit : 90%
auto-delete : disable
activate-on-create : disable
Snapshot Volume Configuration:
Volume : test_vol
snap-max-hard-limit : 1
Effective snap-max-hard-limit : 1
Effective snap-max-soft-limit : 0 (90%)
Volume : test_vol1
snap-max-hard-limit : 256
Effective snap-max-hard-limit : 256
Effective snap-max-soft-limit : 230 (90%)
# gluster snapshot info volume test_vol
Volume Name : test_vol
Snaps Taken : 3
Snaps Available : 0
Snapshot : snap2
Snap UUID : 2c74925e-4c75-4824-b39e-7e1e22f3b758
Created : 2016-07-15 10:13:02
Status : Stopped
Snapshot : snap3
Snap UUID : bfd080f3-848e-490a-83ed-066858bd96fc
Created : 2016-07-15 10:19:17
Status : Stopped
Snapshot : snap4
Snap UUID : bd9a5297-0eb5-47d1-b250-9b57f4e57427
Created : 2016-07-15 10:20:08
Status : Stopped
#
# gluster snapshot create snap5 test_vol no-timestamp
snapshot create: failed: The number of existing snaps has reached the effective maximum limit of 1, for the volume (test_vol). Please delete few snapshots before taking further snapshots.
Snapshot command failed
#
snap-max-hard-limit is both a system config and a volume config. What it means is we can set this value for indiviudal volumes, and we can also set a system value.# gluster snapshot config snap-max-hard-limit 10
Changing snapshot-max-hard-limit will limit the creation of new snapshots if they exceed the new limit.
Do you want to continue? (y/n) y
snapshot config: snap-max-hard-limit for System set successfully
# gluster snapshot config
Snapshot System Configuration:
snap-max-hard-limit : 10
snap-max-soft-limit : 90%
auto-delete : disable
activate-on-create : disable
Snapshot Volume Configuration:
Volume : test_vol
snap-max-hard-limit : 1
Effective snap-max-hard-limit : 1
Effective snap-max-soft-limit : 0 (90%)
Volume : test_vol1
snap-max-hard-limit : 256
Effective snap-max-hard-limit : 10
Effective snap-max-soft-limit : 9 (90%)
#
For example, we can see that the system snap-max-hard-limit is set to 10. Now, in case of the volume test_vol, the snap-max-hard-limit for the volume is set to 1, which is lower than the system's limit and is hence honored, making the effective snap-max-hard-limit as 1. This effective snap-max-hard-limit is the limit that is taken into consideration during snapshot create, and is displayed as 'Snaps Available' in snapshot info. Similarly, for volume test_vol1, the snap-max-hard-limit is 256, which is higher than the system's limit, and is hence not honored, making the effective snap-max-hard-limit of that volume as 10, which is the system's snap-max-hard-limit. Pretty intuitive huh!!! - snap-max-soft-limit: This option is set as a percentage (of snap-max-hard-limit), and as we have seen in examples above, on crossing this limit, a warning is shown saying the soft-limit is reached. It serves as a reminder to the user, that he is nearing the hard-limit and should do something about it in order to be able to keep on taking snapshots. By default the snap-max-hard-limit is set to 90%, and can be modified using the snapshot config option.
# gluster snapshot config test_vol snap-max-soft-limit 50
Soft limit cannot be set to individual volumes.
Usage: snapshot config [volname] ([snap-max-hard-limit <count>] [snap-max-soft-limit <percent>]) | ([auto-delete <enable|disable>])| ([activate-on-create <enable|disable>])
## gluster snapshot config snap-max-soft-limit 50
If Auto-delete is enabled, snap-max-soft-limit will trigger deletion of oldest snapshot, on the creation of new snapshot, when the snap-max-soft-limit is reached.
Do you want to change the snap-max-soft-limit? (y/n) y
snapshot config: snap-max-soft-limit for System set successfully
# gluster snapshot config
Snapshot System Configuration:
snap-max-hard-limit : 10
snap-max-soft-limit : 50%
auto-delete : disable
activate-on-create : disable
Snapshot Volume Configuration:
Volume : test_vol
snap-max-hard-limit : 1
Effective snap-max-hard-limit : 1
Effective snap-max-soft-limit : 0 (50%)
Volume : test_vol1
snap-max-hard-limit : 256
Effective snap-max-hard-limit : 10
Effective snap-max-soft-limit : 5 (50%)
#
I am sure the keen-eyed observer in you has noticed, the Auto-delete warning in the output above, and it's just as well because it is our third configurable parameter. - auto-delete: This option is tightly tied with snap-max-soft-limit, or rather effective snap-max-soft-limit of individual volumes. It is however a system option and cannot be set for individual volumes. On enabling this option, once we exceed the effective snap-max-soft-limit, of a particular volume, we automatically delete the oldest snapshot for this volume, making sure the total number of snapshots don't increase the effective snap-max-soft-limit, and never reach the effective snap-max-hard-limit, enabling you to keep taking snapshots without hassle.
NOTE: Extreme Caution Should Be Exercised When Enabling This Option, As It Automatically Deletes The Oldest Snapshot Of A Volume, When The Number Of Snapshots For That Volume Exceeds The Effective snap-max-soft-limit Of That Volume.# gluster snapshot config auto-delete enable
snapshot config: auto-delete successfully set
# gluster snapshot config
Snapshot System Configuration:
snap-max-hard-limit : 10
snap-max-soft-limit : 50%
auto-delete : enable
activate-on-create : disable
Snapshot Volume Configuration:
Volume : test_vol
snap-max-hard-limit : 1
Effective snap-max-hard-limit : 1
Effective snap-max-soft-limit : 0 (50%)
Volume : test_vol1
snap-max-hard-limit : 256
Effective snap-max-hard-limit : 10
Effective snap-max-soft-limit : 5 (50%)
#
# gluster snapshot list
snap2
snap3
snap4
# gluster snapshot delete all
System contains 3 snapshot(s).
Do you still want to continue and delete them? (y/n) y
snapshot delete: snap2: snap removed successfully
snapshot delete: snap3: snap removed successfully
snapshot delete: snap4: snap removed successfully
# gluster snapshot create snap1 test_vol1 no-timestamp
snapshot create: success: Snap snap1 created successfully
# gluster snapshot create snap2 test_vol1 no-timestamp
snapshot create: success: Snap snap2 created successfully
# gluster snapshot create snap3 test_vol1 no-timestamp
snapshot create: success: Snap snap3 created successfully
# gluster snapshot create snap4 test_vol1 no-timestamp
snapshot create: success: Snap snap4 created successfully
# gluster snapshot create snap5 test_vol1 no-timestamp
snapshot create: success: Snap snap5 created successfully# gluster snapshot create snap6 test_vol1 no-timestamp
snapshot create: success: Snap snap6 created successfully
#
# gluster snapshot list volume test_vol1
snap2
snap3
snap4
snap5
snap6
# - activate-on-create: As we discussed during creation of snapshot, a snapshot on creation is in deactivated state by default, and needs to be activated to be used. On enabling this option in snapshot config, every snapshot created thereafter, will be activated by default. This too is a system option, and cannot be set for individual volumes.
# gluster snapshot status snap6
Snap Name : snap6
Snap UUID : 7fc0a0e7-950d-4c1b-913d-caea6037e633
Brick Path : VM2:/var/run/gluster/snaps/db383315d5a448d6973f71ae3e45573e/brick1/brick
Volume Group : snap_lvgrp
Brick Running : No
Brick PID : N/A
Data Percentage : 1.80
LV Size : 616.00m
#
# gluster snapshot config activate-on-create enable
snapshot config: activate-on-create successfully set
# gluster snapshot config
Snapshot System Configuration:
snap-max-hard-limit : 10
snap-max-soft-limit : 50%
auto-delete : enable
activate-on-create : enable
Snapshot Volume Configuration:
Volume : test_vol
snap-max-hard-limit : 1
Effective snap-max-hard-limit : 1
Effective snap-max-soft-limit : 0 (50%)
Volume : test_vol1
snap-max-hard-limit : 256
Effective snap-max-hard-limit : 10
Effective snap-max-soft-limit : 5 (50%)
# gluster snapshot create snap7 test_vol1 no-timestamp
snapshot create: success: Snap snap7 created successfully
# gluster snapshot status snap7
Snap Name : snap7
Snap UUID : b1864a86-1fa4-4d42-b20a-3d95c2f9e277
Brick Path : VM2:/var/run/gluster/snaps/38b1d9a2f3d24b0eb224f142ae5d33ca/brick1/brick
Volume Group : snap_lvgrp
Brick Running : Yes
Brick PID : 6731
Data Percentage : 1.80
LV Size : 616.00m
#
5 comments:
Thanks for your series on glusterfs snapshotting. Much appreciated :-)
Great information! Thank you! Are you planning on describing "User Serviceable Snapshots" in the future?
Yes John, I am planning to wrap up the remaining snapshot commands, and follow it up with user serviceable snapshots.
Would be nice to do another post with snapshot restore and so on. I'm testing GlusterFS for a future implementation in Production but I don't understand why my bricks path have changed when I restored the snapshot...
thanks
Nice post... Is it possible to copy the snapshot volume to another machine?
Post a Comment