大网数据广告活动
服务器运维问答

ZFS Equivalent of lvdisplay snap_percent

· 52CE 我爱测

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 s…

问题原文

原帖链接 · 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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-09-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0 / CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。