问题原文
原帖链接 · Joe · CC BY-SA 4.0
I've been using LVM snapshots for backing up MySQL databases.
FLUSH TABLES WITH READ LOCK is issued and then lvcreate --snapshot --size 4G etc. Since the database is live while the snapshot is active the snap_percent (amount of snapshot storage being used to track deltas with the original state of the filesystem at the time the snapshot was taken) starts increasing. This snap_percent is monitored day-over-day and the --size is increased in the event it reaches 80%.
My question is whether or not there is an equivalent statistic or property in ZFS for determining how much space is being consumed by a snapshot as a percentage of space remaining in the pool? Obviously I don't need to pass a --size parameter to zfs snapshot but how can I determine whether the clone based upon that snapshot is nearing the limits of the pool.
Hopefully that makes sense, it sure sounds like a convoluted question now that I read it.
社区高分解答
原帖链接 · ewwhite · CC BY-SA 3.0
ZFS snapshot space is reflected in the filesystem's consumption. You can derive what you're asking for by monitoring the most appropriate fields below.
In the end, you'll watch your filesystem's "avail" space... See how "used"+"avail" is less than "size"?:
root@deore:~# df -h /volumes/vol1/LA_Specialty
Filesystem size used avail capacity Mounted on
vol1/LA_Specialty 800G 391G 254G 61% /volumes/vol1/LA_Specialty
I've filtered the output of zfs get all pool/filesystem below to show the relevant properties. Below, I have an 800GB filesystem (quota) where 545GB is used. 391GB is referenced, meaning that's the size of the real data. 154GB is used by snapshots.
root@deore:/volumes# zfs get all vol1/LA_Specialty
NAME PROPERTY VALUE SOURCE
vol1/LA_Specialty type filesystem -
vol1/LA_Specialty creation Sat Sep 24 18:44 2011 -
vol1/LA_Specialty used 545G -
vol1/LA_Specialty available 255G -
vol1/LA_Specialty referenced 391G -
vol1/LA_Specialty compressratio 2.96x -
vol1/LA_Specialty quota 800G local
vol1/LA_Specialty reservation none default
vol1/LA_Specialty recordsize 16K local
vol1/LA_Specialty mountpoint /volumes/vol1/LA_Specialty inherited from vol1
vol1/LA_Specialty usedbysnapshots 154G -
vol1/LA_Specialty usedbydataset 391G -
vol1/LA_Specialty usedbychildren 0 -
vol1/LA_Specialty usedbyrefreservation 0 -
Then looking at the snapshots... It's possible to see the individual size of the snapshots and the total data size that they reference.
root@deore:/volumes# zfs list -t snapshot
NAME USED AVAIL REFER MOUNTPOINT
vol1/LA_Specialty@snap-daily-1-2013-09-07-020003 57.6G - 389G -
vol1/LA_Specialty@snap-daily-1-2013-09-08-020003 1.95G - 391G -
vol1/LA_Specialty@snap-daily-1-2013-09-09-020008 3.42G - 392G -
vol1/LA_Specialty@snap-daily-1-2013-09-10-020003 3.05G - 391G -
vol1/LA_Specialty@snap-daily-1-2013-09-11-020003 2.81G - 391G -
vol1/LA_Specialty@snap-daily-1-2013-09-12-020004 2.65G - 391G -
vol1/LA_Specialty@snap-daily-1-2013-09-13-020003 2.70G - 391G -
vol1/LA_Specialty@snap-daily-1-2013-09-14-020003 25K - 391G -
vol1/LA_Specialty@snap-daily-1-latest 25K - 391G -
And a du listing of the snapshot directory...
root@deore:/volumes/vol1/LA_Specialty/.zfs/snapshot# du -skh *
389G snap-daily-1-2013-09-07-020003
391G snap-daily-1-2013-09-08-020003
392G snap-daily-1-2013-09-09-020008
391G snap-daily-1-2013-09-10-020003
391G snap-daily-1-2013-09-11-020003
391G snap-daily-1-2013-09-12-020004
391G snap-daily-1-2013-09-13-020003
391G snap-daily-1-2013-09-14-020003
391G snap-daily-1-latest
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
