推广 热搜: ACF胶  回收ACF  收购ACF  200*16防溢裙板  济宁防溢裙板  求购ACF  挡尘帘  @2022已最新(今日/知乎)  AH0.6/12矿用按钮箱  GLD2200/7.5/S甲带给煤机 

zfs文件系统的简单介绍

   日期:2023-04-07     浏览:49    评论:0    
核心提示:什么是 ZFS?ZFS 文件系统是一种革新性的新文件系统,可从根本上改变文件系统的管理方式,并具有目前面市的其他任何文件系统所没有的功能和优点。ZFS 强健可靠、可伸缩、易于管理。ZFS 池存储ZFS

什么是 ZFS?

ZFS 文件系统是一种革新性的新文件系统,可从根本上改变文件系统的管理方式,并具有目前面市的其他任何文件系统所没有的功能和优点。ZFS 强健可靠、可伸缩、易于管理。

ZFS 池存储ZFS 使用存储池的概念来管理物理存储。以前,文件系统是在单个物理设备的基础上构造的。为了利用多个设备和提供数据冗余性,引入了卷管理器的概念来提供单个设备的表示,以便无需修改文件系统即可利用多个设备。此设计增加了更多复杂性,并最终阻碍了特定文件系统的继续发展,因为这类文件系统无法控制数据在虚拟卷上的物理放置。

ZFS 可完全避免使用卷管理。ZFS 将设备聚集到存储池中,而不是强制要求创建虚拟卷。存储池说明了存储的物理特征(设备布局、数据冗余等),并充当可以从其创建文件系统的任意数据存储库。文件系统不再仅限于单个设备,从而可与池中的所有文件系统共享磁盘空间。您不再需要预先确定文件系统的大小,因为文件系统会在分配给存储池的磁盘空间内自动增长。添加新存储器后,无需执行其他操作,池中的所有文件系统即可立即使用所增加的磁盘空间。在许多方面,存储池与虚拟内存系统相似:将一个内存 DIMM 加入系统时,操作系统并不强迫您运行命令来配置内存并将其指定给个别进程。系统中的所有进程都会自动使用所增加的内存。

事务性语义ZFS 是事务性文件系统,这意味着文件系统状态在磁盘上始终是一致的。传统文件系统可就地覆写数据,这意味着如果系统断电(例如,在分配数据块到将其链接到目录中的时间段内断电),则会使文件系统处于不一致状态。以前,此问题是通过使用fsck命令解决的。此命令负责检查并验证文件系统状态,并尝试在操作过程中修复任何不一致性。这种文件系统不一致问题曾给管理员造成巨大困扰,

fsck命令并不保证能够解决所有可能的问题。最近,文件系统引入了日志记录的概念。日志记录过程在单独的日志中记录操作,在系统发生崩溃时,可以安全地重放该日志。由于数据需要写入两次,因此该过程会引入不必要的开销,而且通常会导致一组新问题,例如在无法正确地重放日志时。

对于事务性文件系统,数据是使用写复制语义管理的。数据永远不会被覆写,并且任何操作序列会全部被提交或全部被忽略。因此,文件系统绝对不会因意外断电或系统崩溃而被损坏。尽管最近写入的数据片段可能丢失,但是文件系统本身将始终是一致的。此外,只有在写入同步数据(使用O_DSYNC标志写入)后才返回,因此同步数据决不会丢失。

校验和与自我修复数据

对于 ZFS,所有数据和元数据都通过用户可选择的校验和算法进行验证。提供校验和验证的传统文件系统出于卷管理层和传统文件系统设计的必要,会逐块执行此操作。在传统设计中,某些故障可能导致数据不正确但没有校验和错误,如向错误位置写入完整的块等。ZFS 校验和的存储方式可确保检测到这些故障并可以正常地从其中进行恢复。所有校验和验证与数据恢复都是在文件系统层 执行的,并且对应用程序是透明的。

此外,ZFS 还会提供自我修复数据。ZFS 支持存储池具有各种级别的数据冗余性。检测到坏的数据块时,ZFS 会从另一个冗余副本中提取正确的数据,而且会用正确的数据替换错误的数据。

独一无二的可伸缩性

ZFS 文件系统的一个关键设计要素是可伸缩性。该文件系统本身是 128 位的,所允许的存储空间是 256 quadrillion zettabyte (256x1015 ZB)。所有元数据都是动态分配的,因此在首次创建时无需预先分配 inode,否则就会限制文件系统的可伸缩性。所有算法在编写时都考虑到了可伸缩性。目录最多可以包含 248(256 万亿)项,并且对于文件系统数或文件系统中可以包含的文件数不存在限制。

ZFS 快照快照是文件系统或卷的只读副本。可以快速而轻松地创建快照。最初,快照不会占用池中的任何附加磁盘空间。

活动数据集中的数据更改时,快照通过继续引用旧数据来占用磁盘空间。因此,快照可防止将数据释放回池中。

简化的管理最重要的是,ZFS 提供了一种极度简化的管理模型。通过使用分层文件系统布局、属性继承以及自动管理挂载点和 NFS 共享语义,ZFS 可轻松创建和管理文件系统,而无需使用多个命令或编辑配置文件。可以轻松设置配额或预留空间,启用或***用压缩,或者通过单个命令管理许多文件系统的挂载点。您就可以检查或替换设备,而无需学习另外的一套卷管理命令。您可以发送和接收文件系统快照流

ZFS 通过分层结构管理文件系统,该分层结构允许对属性(如配额、预留空间、压缩和挂载点)进行这一简化管理。在此模型中,文件系统是中央控制点。文件系统本身的开销非常小(相当于创建一个新目录),因此鼓励您为每个用户、项目、工作区等创建一个文件系统。通过此设计,可定义细分的管理点。

proxmox ve -- ZFS on Linux 2019-08-30

ZFS是由Sun Microsystems设计的一个文件系统和逻辑卷管理器的组合。从proxmox ve 3.4开始,zfs文件系统的本机Linux内核端口作为可选文件系统引入,并作为根文件系统的附加选择。不需要手动编译ZFS模块-包括所有包。

通过使用zfs,它可以通过低硬件预算花销实现***的企业功能,并且可以通过利用SSD缓存或纯使用SSD来实现高性能系统。ZFS可以通过适度的CPU和内存负载以及简单的管理来取代成本高昂的硬件RAID卡。

General ZFS advantages

ZFS很大程度上依赖于内存,因此至少需要8GB才能启动。在实践中,尽可能多地使用高配置硬件。为了防止数据损坏,我们建议使用高质量的ECC RAM。

如果使用专用缓存和/或日志磁盘,则应使用企业级SSD(例如Intel SSD DC S3700系列)。这可以显著提高整体性能。

If you are experimenting with an installation of Proxmox VE inside a VM (Nested Virtualization), don’t use ttvirtio/tt for disks of that VM, since they are not supported by ZFS. Use IDE or SCSI instead (works also with ttvirtio/tt SCSI controller type).

When you install using the Proxmox VE installer, you can choose ZFS for the root file system. You need to select the RAID type at installation time:

| RAID0

|

Also called “striping”. The capacity of such volume is the sum of the capacities of all disks. But RAID0 does not add any redundancy, so the failure of a single drive makes the volume unusable.

|

| RAID1

|

Also called “mirroring”. Data is written identically to all disks. This mode requires at least 2 disks with the same size. The resulting capacity is that of a single disk.

|

| RAID10

|

A combination of RAID0 and RAID1. Requires at least 4 disks.

|

| RAIDZ-1

|

A variation on RAID-5, single parity. Requires at least 3 disks.

|

| RAIDZ-2

|

A variation on RAID-5, double parity. Requires at least 4 disks.

|

| RAIDZ-3

|

A variation on RAID-5, triple parity. Requires at least 5 disks.

|

The installer ***tomatically partitions the disks, creates a ZFS pool called ttrpool/tt, and installs the root file system on the ZFS subvolume ttrpool/ROOT/pve-1/tt.

Another subvolume called ttrpool/data/tt is created to store VM images. In order to use that with the Proxmox VE tools, the installer creates the following configuration entry in tt/etc/pve/storage.cfg/tt:

prettzfspool: local-zfs

pool rpool/data

sparse

content images,rootdir/tt/pre

After installation, you can view your ZFS pool status using the ttzpool/tt command:

prett# zpool status

pool: rpool

state: ONLINE

scan: none requested

config:

errors: No known data errors/tt/pre

The ttzfs/tt command is used configure and manage your ZFS file systems. The following command lists all file systems after installation:

prett# zfs list

NAME USED AVAIL REFER MOUNTPOINT

rpool 4.94G 7.68T 96K /rpool

rpool/ROOT 702M 7.68T 96K /rpool/ROOT

rpool/ROOT/pve-1 702M 7.68T 702M /

rpool/data 96K 7.68T 96K /rpool/data

rpool/swap 4.25G 7.69T 64K -/tt/pre

Depending on whether the system is booted in EFI or legacy BIOS mode the Proxmox VE installer sets up either ttgrub/tt or ttsystemd-boot/tt as main bootloader. See the chapter on Proxmox VE host bootladers for details.

This section gives you some usage examples for common tasks. ZFS itself is really powerful and provides many options. The main commands to manage ZFS are ttzfs/tt and ttzpool/tt. Both commands come with great manual pages, which can be read with:

prett# man zpool

To create a new pool, at least one disk is needed. The ttashift/tt should have the same sector-size (2 power of ttashift/tt) or larger as the underlying disk.

prettzpool create -f -o ashift=12 pool device/tt/pre

To activate compression

prettzfs set compression=lz4 pool/tt/pre

Minimum 1 Disk

prettzpool create -f -o ashift=12 pool device1 device2/tt/pre

Minimum 2 Disks

prettzpool create -f -o ashift=12 pool mirror device1 device2/tt/pre

Minimum 4 Disks

prettzpool create -f -o ashift=12 pool mirror device1 device2 mirror device3 device4/tt/pre

Minimum 3 Disks

prettzpool create -f -o ashift=12 pool raidz1 device1 device2 device3/tt/pre

Minimum 4 Disks

prettzpool create -f -o ashift=12 pool raidz2 device1 device2 device3 device4/tt/pre

It is possible to use a dedicated cache drive partition to increase the performance (use SSD).

As ttdevice/tt it is possible to use more devices, like it’s shown in "Create a new pool with RAID*".

prettzpool create -f -o ashift=12 pool device cache cache_device/tt/pre

It is possible to use a dedicated cache drive partition to increase the performance(SSD).

As ttdevice/tt it is possible to use more devices, like it’s shown in "Create a new pool with RAID*".

prettzpool create -f -o ashift=12 pool device log log_device/tt/pre

If you have an pool without cache and log. First partition the SSD in 2 partition with ttparted/tt or ttgdisk/tt

| Alw***s use GPT partition tables. |

The maximum size of a log device should be about half the size of physical memory, so this is usually quite ***all. The rest of the SSD can be used as cache.

prettzpool add -f pool log device-part1 cache device-part2/tt/pre

Changing a failed device

prettzpool replace -f pool old device new device/tt/pre

Changing a failed bootable device when using systemd-boot

prettsgdisk healthy bootable device -R new device

sgdisk -G new device

zpool replace -f pool old zfs partition new zfs partition

pve-efiboot-tool format new disk's ESP

pve-efiboot-tool init new disk's ESP/tt/pre

| ttESP/tt stands for EFI System Partition, which is setup as partition #2 on bootable disks setup by the Proxmox VE installer since version 5.4. For details, see Setting up a new partition for use as synced ESP . |

ZFS comes with an event daemon, which monitors events generated by the ZFS kernel module. The daemon can also send emails on ZFS events like pool errors. Newer ZFS packages ships the daemon in a separate package, and you can install it using ttapt-get/tt:

prett# apt-get install zfs-zed/tt/pre

To activate the daemon it is necessary to edit tt/etc/zfs/zed.d/zed.rc/tt with your favourite editor, and uncomment the ttZED_EMAIL_ADDR/tt setting:

prettZED_EMAIL_ADDR="root"/tt/pre

Please note Proxmox VE forwards mails to ttroot/tt to the email address configured for the root user.

| The only setting that is required is ttZED_EMAIL_ADDR/tt. All other settings are optional. |

It is good to use at most 50 percent (which is the def***lt) of the system memory for ZFS ARC to prevent performance shortage of the host. Use your preferred editor to change the configuration in tt/etc/modprobe.d/zfs.conf/tt and insert:

prettoptions zfs zfs_arc_max=8589934592/tt/pre

This example setting limits the usage to 8GB.

|

If your root file system is ZFS you must update your initramfs every time this value changes:

prettupdate-initramfs -u/tt/pre

|

Swap-space created on a zvol m*** generate some troubles, like blocking the server or generating a high IO load, often seen when starting a Backup to an external Storage.

We strongly recommend to use enough memory, so that you normally do not run into low memory situations. Should you need or want to add swap, it is preferred to create a partition on a physical disk and use it as swapdevice. You can leave some space free for this purpose in the advanced options of the installer. Additionally, you can lower the “swappiness” value. A good value for servers is 10:

prettsysctl -w vm.swappiness=10/tt/pre

To make the swappiness persistent, open tt/etc/sysctl.conf/tt with an editor of your choice and add the following line:

prettvm.swappiness = 10/tt/pre

captionTable 1. Linux kernel ttswappiness/tt parameter values/caption colgroupcol col/colgroup

ttvm.swappiness = 0/tt

|

The kernel will swap only to avoid an out of memory condition

|

|

ttvm.swappiness = 1/tt

|

Minimum amount of swapping without disabling it entirely.

|

|

ttvm.swappiness = 10/tt

|

This value is sometimes recommended to improve performance when sufficient memory exists in a system.

|

|

ttvm.swappiness = 60/tt

|

The def***lt value.

|

|

ttvm.swappiness = 100/tt

|

The kernel will swap aggressively.

|

ZFS on Linux version 0.8.0 introduced support for native encryption of datasets. After an upgrade from previous ZFS on Linux versions, the encryption feature can be enabled per pool:

prett# zpool get feature@encryption tank

NAME PROPERTY VALUE SOURCE

tank feature@encryption disabled local

NAME PROPERTY VALUE SOURCE

tank feature@encryption enabled local/tt/pre

| There is currently no support for booting from pools with encrypted datasets using Grub, and only limited support for ***tomatically unlocking encrypted datasets on boot. Older versions of ZFS without encryption support will not be able to decrypt stored data. |

| It is recommended to either unlock storage datasets manually after booting, or to write a custom unit to pass the key material needed for unlocking on boot to ttzfs load-key/tt. |

| Establish and test a backup procedure before enabling encryption of production data.If the associated key material/passphrase/keyfile has been lost, accessing the encrypted data is no longer possible. |

Encryption needs to be setup when creating datasets/zvols, and is inherited by def***lt to child datasets. For example, to create an encrypted dataset tttank/encrypted_data/tt and configure it as storage in Proxmox VE, run the following commands:

prett# zfs create -o encryption=on -o keyformat=passphrase tank/encrypted_data

Enter passphrase:

Re-enter passphrase:

All guest volumes/disks create on this storage will be encrypted with the shared key material of the parent dataset.

To actually use the storage, the associated key material needs to be loaded with ttzfs load-key/tt:

prett# zfs load-key tank/encrypted_data

Enter passphrase for 'tank/encrypted_data':/tt/pre

It is also possible to use a (random) keyfile instead of prompting for a passphrase by setting the ttkeylocation/tt and ttkeyformat/tt properties, either at creation time or with ttzfs change-key/tt on existing datasets:

prett# dd if=/dev/urandom of=/path/to/keyfile bs=32 count=1

| When using a keyfile, special care needs to be taken to secure the keyfile against un***thorized access or accidental loss. Without the keyfile, it is not possible to access the plaintext data! |

A guest volume created underneath an encrypted dataset will have its ttencryptionroot/tt property set accordingly. The key material only needs to be loaded once per encryptionroot to be available to all encrypted datasets underneath it.

See the ttencryptionroot/tt, ttencryption/tt, ttkeylocation/tt, ttkeyformat/tt and ttkeystatus/tt properties, the ttzfs load-key/tt, ttzfs unload-key/tt and ttzfs change-key/tt commands and the ttEncryption/tt section from ttman zfs/tt for more details and advanced usage.

ZFS文件系统快照和使用方法

ZFS文件系统的快照功能使用非常方便,创建快照几乎秒创建,恢复也很快,且在创建时不会额外消耗存储空间

zfs snapshot xxx@yyy

其中xxx是zfs磁盘名,yyy是快照名

zfs list -t snap

zfs destroy xxx@yyy

zfs rollback -r xxx@yyy

zfs get origin xxx

快照本身创建时并不占用空间,但是随着时间推移,快照会逐渐占用空间。这是因为zfs默认会释放一些文件占用的旧数据空间,但是为了保留快照,必须要把这部分旧数据保留,直到快照删除。因此不宜保留快照很长时间,应该定时进行清理。

如果时间长度固定,只是增加快照频次,不会显著增加快照占用的空间,例如保留1天前的一个快照,与保留1天内每小时一个24个快照,占用的空间差不太多。

ZFS文件格式

很奇怪,文档中在表示“去掉”文件系统时用“Destroy”这个词,但是这个单词应该是“毁灭”的意思,好可怕哦,呵呵,这里暂且延用UFS的umount(卸载)的意思来表达吧。

1、ZFS文件系统用zfs create命令来创建。文件系统的名字类似于UFS中文件的路径,只不过以池的名字开头

格式:pool-name/[filesystem-name/]filesystem-name

如果要在 tank/home 文件系统下创建一个名为 bonwick 文件系统

# zfs create tank/home/bonwick

2、用“zfs destroy”卸载文件系统

# zfs destroy tank/home/tabriz

如果一个文件系统出现不能被卸载的情况,跟UFS的umount类似,用-f选项,例如:

# zfs destroy tank/home/ahrens

cannot unmount ’tank/home/ahrens’: Device busy

# zfs destroy -f tank/home/ahrens

Ubuntu 16.04 下ZFS文件系统怎么启用 TRIM-CSDN论坛

从Ubuntu14.04开始默认为SSD开启了TRIM。TRIMEnabledByDef***ltForSSDsOnUbuntu14.04TrustyTahr.但是为了SSD的工作效率,Ubuntu默认对挂载的文件系统不启用TRIM——mount没有使用discard选项。但同时,Ubuntu使用了cron定时脚本,每周对支持TRIM的磁盘进行一次TRIM。TRIM每周执行一次,由下面的定时脚本控制:/etc/cron.weekly/fstrim如果你是Ubuntu14.04,建议修改一下该文件:修改原因:默认该脚本只为Intel或三星固态硬盘TrimThisonlyrunsonIntelandSamsungSSD***ydef***lt.执行命令,打开文件修改:sudogeditetc/cron.weekly/fstrim将命令execfstrim-all修改为execfstrim-all--no-model-check保存即可。如果你是Ubuntu14.04及以上版本,不用修改上述文件。#顺便提一下,为了降低TRIM执行对SSD的影响。建议mount挂载固态硬盘时,不要使用discard选项——该选项会导致进行文件修改、删除操作后,系统会执行TRIM,过于频繁的TRIM影响SSD的工作效率。查看当前是否有分区启用了discard选项,可以使用下列命令之一:mount|grepdiscard或findmnt-Odiscard如果上述命令没有输出,说明没有分区启用TRIM。如果上述命令有输出,说明有分区启用了TRIM,如果要取消discard。可使用命令:sudomount-oremount,nodiscard/dev/sdxx将/dev/sdxx改为你对应的磁盘若查看当前系统挂载磁盘及分区,可用命令l***lk或sudoblkid

关于zfs文件系统和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

原文链接:http://www.hzciic.com/news/show-19304.html,转载和复制请保留此链接。
以上就是关于zfs文件系统的简单介绍全部的内容,关注我们,带您了解更多相关内容。
 
打赏
 
更多>同类资讯
0相关评论

推荐资讯
网站首页  |  VIP套餐介绍  |  关于我们  |  联系方式  |  使用协议  |  版权隐私  |  手机版  |  SITEMAPS  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报