如何在Ubuntu Linux 16.04 LTS上安装ZFS
时间:2020-01-09 10:39:28 来源:igfitidea点击:
如何在Ubuntu Linux 16.04 LTS服务器上安装Z文件系统(ZFS)并创建RAID-1(镜像)?
Z文件系统(ZFS)最初是由Sun Microsystem设计的。
它是一个高级文件系统和逻辑卷管理器。
它可以在Solaris,FreeBSD,Linux和许多其他操作系统上运行。
ZFS的功能包括防止数据损坏,压缩,卷管理,快照,数据完整性,软件RAID,缓存等。
在Ubuntu 16.04上安装ZFS
Linux的本机OpenZFS管理实用程序位于zfsutils-linux软件包中。
您还可以使用称为zfs的元软件包。
只需执行以下命令:
$ sudo apt update $ sudo apt install zfs
或者
$ sudo apt install zfsutils-linux
输出示例:
Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'zfsutils-linux' instead of 'zfs' The following additional packages will be installed: libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-doc zfs-zed Suggested packages: default-mta | mail-transport-agent samba-common-bin nfs-kernel-server zfs-initramfs The following NEW packages will be installed: libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-doc zfs-zed zfsutils-linux 0 upgraded, 7 newly installed, 0 to remove and 19 not upgraded. Need to get 884 kB of archives. After this operation, 2,822 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 zfs-doc all 0.6.5.6-0ubuntu10 [49.4 kB] Get:2 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libuutil1linux amd64 0.6.5.6-0ubuntu10 [27.4 kB] Get:3 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libnvpair1linux amd64 0.6.5.6-0ubuntu10 [23.5 kB] Get:4 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libzpool2linux amd64 0.6.5.6-0ubuntu10 [385 kB] Get:5 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libzfs2linux amd64 0.6.5.6-0ubuntu10 [106 kB] Get:6 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 zfsutils-linux amd64 0.6.5.6-0ubuntu10 [263 kB] Get:7 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 zfs-zed amd64 0.6.5.6-0ubuntu10 [29.8 kB] Fetched 884 kB in 1s (651 kB/s) Selecting previously unselected package zfs-doc. (Reading database ... 91925 files and directories currently installed.) Preparing to unpack .../zfs-doc_0.6.5.6-0ubuntu10_all.deb ... Unpacking zfs-doc (0.6.5.6-0ubuntu10) ... Selecting previously unselected package libuutil1linux. Preparing to unpack .../libuutil1linux_0.6.5.6-0ubuntu10_amd64.deb ... Unpacking libuutil1linux (0.6.5.6-0ubuntu10) ... Selecting previously unselected package libnvpair1linux. Preparing to unpack .../libnvpair1linux_0.6.5.6-0ubuntu10_amd64.deb ... Unpacking libnvpair1linux (0.6.5.6-0ubuntu10) ... Selecting previously unselected package libzpool2linux. Preparing to unpack .../libzpool2linux_0.6.5.6-0ubuntu10_amd64.deb ... Unpacking libzpool2linux (0.6.5.6-0ubuntu10) ... Selecting previously unselected package libzfs2linux. Preparing to unpack .../libzfs2linux_0.6.5.6-0ubuntu10_amd64.deb ... Unpacking libzfs2linux (0.6.5.6-0ubuntu10) ... Selecting previously unselected package zfsutils-linux. Preparing to unpack .../zfsutils-linux_0.6.5.6-0ubuntu10_amd64.deb ... Unpacking zfsutils-linux (0.6.5.6-0ubuntu10) ... Selecting previously unselected package zfs-zed. Preparing to unpack .../zfs-zed_0.6.5.6-0ubuntu10_amd64.deb ... Unpacking zfs-zed (0.6.5.6-0ubuntu10) ... Processing triggers for libc-bin (2.23-0ubuntu3) ... Processing triggers for initramfs-tools (0.122ubuntu8.1) ... update-initramfs: Generating /boot/initrd.img-4.4.0-28-generic Processing triggers for systemd (229-4ubuntu6) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for man-db (2.7.5-1) ... Setting up zfs-doc (0.6.5.6-0ubuntu10) ... Setting up libuutil1linux (0.6.5.6-0ubuntu10) ... Setting up libnvpair1linux (0.6.5.6-0ubuntu10) ... Setting up libzpool2linux (0.6.5.6-0ubuntu10) ... Setting up libzfs2linux (0.6.5.6-0ubuntu10) ... Setting up zfsutils-linux (0.6.5.6-0ubuntu10) ... zfs-import-cache.service is a disabled or a static unit, not starting it. zfs-import-scan.service is a disabled or a static unit, not starting it. zfs-mount.service is a disabled or a static unit, not starting it. Processing triggers for initramfs-tools (0.122ubuntu8.1) ... update-initramfs: Generating /boot/initrd.img-4.4.0-28-generic Setting up zfs-zed (0.6.5.6-0ubuntu10) ... zed.service is a disabled or a static unit, not starting it. Processing triggers for libc-bin (2.23-0ubuntu3) ... Processing triggers for systemd (229-4ubuntu6) ... Processing triggers for ureadahead (0.100.0-19) ...
什么是ZFS虚拟设备(ZFS VDEV)?
VDEV只是物理磁盘,文件镜像或ZFS软件突袭设备的集合,是ZFS突袭的热备用。
例如:
- /dev/sdb物理磁盘
- /images/200G.img文件镜像
- /dev/sdc1一个分区
什么是ZFS池(zpool)?
zpool就是由VDEVS构成的存储(VDEVS的集合)。
您可以组合两个或多个物理磁盘或文件,或两者结合。
如何创建标准RAID1镜像(zfs镜像)?
使用以下语法
zpool create NAME mirror VDEV1 VDEV2
要创建名为theitroad的ZPool镜像组,请执行:
$ sudo zpool create theitroad mirror /dev/sdb /dev/sdc
查看ZPoll的状态
只需执行以下命令即可查看ZPools的当前运行状况:
$ zpool status
输出示例:
ZPool镜像正在运行
如何检查zpool的大小和使用情况?
执行以下命令:
$ zpool list $ df
如何找到ZPools的I/O统计信息?
执行以下命令:
$ zpool iostat
输出示例:
capacity operations bandwidth pool alloc free read write read write ---------- ----- ----- ----- ----- ----- ---- theitroad 2.64M 888G 0 2 0 6.38K
现在,您可以开始复制数据或将数据存储在/theitroad中:
$ cd /theitroad $ ls $ cp /foo/ .
但是,ZFS允许您创建文件系统。
例如池中名为theitroad的数据或容器文件系统:
$ sudo zfs create theitroad/data $ sudo zfs create theitroad/containers $ zfs list
输出示例:
NAME USED AVAIL REFER MOUNTPOINT theitroad 2.67M 860G 2.59M /theitroad theitroad/containers 19K 860G 19K /theitroad/containers theitroad/data 19K 860G 19K /theitroad/data
如何删除zpool和所有存储在名为theitroad的池中的数据?
$ sudo zpool destroy zpoolNameHere $ sudo zpool destroy theitroad $ zpool status