zfs編譯
㈠ ubuntu zfs 怎麼掛裝
下面將指導大家在Ubuntu/linux 上安裝原生的ZFS 文件系統。
測試環境:Linux 2.6.35-24-generic #42-Ubuntu SMP x86_64 GNU/Linux Ubuntu 10.10 ,也適用於Ubuntu 10.04。
確保安裝以下軟體包
build-essential
gawk
zlib1g-dev
uuid-dev
若沒有安裝,使用命令,安裝:
sudo apt-get install build-essential gawk zlib1g-dev uuid-dev
現在准備從http://zfsonlinux.org/安裝SPL和ZFS
sudo cd /usr/src
下載最新版本:
sudo wget http://github.com/downloads/behlendorf/spl/spl-0.5.2.tar.gz
sudo wget http://github.com/downloads/behlendorf/zfs/zfs-0.5.2.tar.gz
構建SPL(編譯ZFS時會用到)
sudo tar -xvzf spl-0.5.2.tar.gz
sudo cd spl-0.5.2/
sudo ./configure
sudo make
sudo make install
構建ZFS
cd ..
sudo tar -xvzf zfs-0.5.2.tar.gz
sudo cd zfs-0.5.2/ sudo ./configure
sudo make
sudo make install
查看一下splat是否工作,ZFS模塊已經裝載:
sudo modprobe splat
sudo splat -a
sudo modprobe zfs
lsmod |grep zfs
OK~~
如果丟失路徑 LD_LIBRARY_PATH,所有的ZFS命令都將出現如下錯誤:
zfs: error while loading shared libraries: libspl.so.0: cannot open shared object file: No such file or directory
可添加環境,加以修正:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
好了~~
㈡ oracle zfs storage vm里怎麼安裝
1、下載安裝Oracle VM VirtualBox。
6、下一步,虛擬機就簡單的創建完成了。
㈢ lfs是什麼意思
LFS──Linux from Scratch,就是一種從網上直接下載源碼,從頭編譯Linux的安裝方式。它不是發行版,只是一個菜譜,告訴你到哪裡去買菜(下載源碼),怎麼把這些生東西( raw code) 作成符合自己口味的菜餚──個性化的Linux,不單單是個性的桌面。
Log-structured file system,是影響近代高效能檔案系統很深遠的設計,有許多效能導向的特殊應用檔案系統,像WAFL,Sprint,ZFS,都以LFS概念為設計的基礎. 因為一般的檔案系統,只能利用10~15%的磁碟頻寬,LFS卻可以提升到80%。
這是因為如今的磁碟機的IO頻寬已經很快,但是受限於磁頭磁軌移動的機械動作加速有限,和磁碟轉動到所需的磁區也需要的時間,讓機械動作比較少的連續磁區讀取,速度遠比需要大量機械動作的隨機讀取快. 但是根據研究,UNIX的檔案系統,約略80%是8K以下小檔,分散在各地的小檔,會造成大量隨機讀取,而讓磁碟I/O明顯變慢. LFS就是想解決這樣的問題。
LFS為了能充份的利用磁碟I/O頻寬,減少隨機讀寫,他定義了Segment為基本的磁碟存取單位,Segment 是由連續的小磁區組成,大小為512KB (1024個磁區). LFS假設系統有足夠大的快取記憶體,讓磁碟機的動作會集中在寫入(因為讀取大多會從快取),因此我們只要把小檔集中起來成為一個個segment 大小再集中寫入,就可以理想上使用100%磁碟頻寬。
顧名思義,LFS本身就是把檔案系統當成一個巨大的log,他的好處是可以很容易處理異常關機產生的問題,只需要檢查最後寫入的磁區就可以. 但相對有個缺點,就是必須保持log尾端有足夠的free space 才能新增/異動檔案. 因此,一但log 滿了,就必須清理log中所有刪除的檔案來釋放空間,並且把空出來的空間往後移,移到尾端再利用,這個動作稱做Segment Clean。
Segment Clean 是一項非常繁重的工作,會佔用絕大多部分的磁碟頻寬,以致於系統效能受到拖累,形成LFS實作非常大的問題。
此外,LFS 雖然把小檔案clusted 起來成為Segment,讓寫入效能大增,但讀取時仍可能需要到各個Segments中讀取小檔,由於Segment是很大的IO單位,造成IO瓶頸. 當快取沒有這些檔案,讀取效率就會變慢。
㈣ 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 <tt>virtio</tt> for disks of that VM, since they are not supported by ZFS. Use IDE or SCSI instead (works also with <tt>virtio</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 rendancy, 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 automatically partitions the disks, creates a ZFS pool called <tt>rpool</tt>, and installs the root file system on the ZFS subvolume <tt>rpool/ROOT/pve-1</tt>.
Another subvolume called <tt>rpool/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>:
<pre><tt>zfspool: local-zfs
pool rpool/data
sparse
content images,rootdir</tt></pre>
After installation, you can view your ZFS pool status using the <tt>zpool</tt> command:
<pre><tt># zpool status
pool: rpool
state: ONLINE
scan: none requested
config:
errors: No known data errors</tt></pre>
The <tt>zfs</tt> command is used configure and manage your ZFS file systems. The following command lists all file systems after installation:
<pre><tt># 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 <tt>grub</tt> or <tt>systemd-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 <tt>zfs</tt> and <tt>zpool</tt>. Both commands come with great manual pages, which can be read with:
<pre><tt># man zpool
To create a new pool, at least one disk is needed. The <tt>ashift</tt> should have the same sector-size (2 power of <tt>ashift</tt>) or larger as the underlying disk.
<pre><tt>zpool create -f -o ashift=12 <pool> <device></tt></pre>
To activate compression
<pre><tt>zfs set compression=lz4 <pool></tt></pre>
Minimum 1 Disk
<pre><tt>zpool create -f -o ashift=12 <pool> <device1> <device2></tt></pre>
Minimum 2 Disks
<pre><tt>zpool create -f -o ashift=12 <pool> mirror <device1> <device2></tt></pre>
Minimum 4 Disks
<pre><tt>zpool create -f -o ashift=12 <pool> mirror <device1> <device2> mirror <device3> <device4></tt></pre>
Minimum 3 Disks
<pre><tt>zpool create -f -o ashift=12 <pool> raidz1 <device1> <device2> <device3></tt></pre>
Minimum 4 Disks
<pre><tt>zpool 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 <tt><device></tt> it is possible to use more devices, like it』s shown in "Create a new pool with RAID*".
<pre><tt>zpool 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 <tt><device></tt> it is possible to use more devices, like it』s shown in "Create a new pool with RAID*".
<pre><tt>zpool 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 <tt>parted</tt> or <tt>gdisk</tt>
| Always 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 small. The rest of the SSD can be used as cache.
<pre><tt>zpool add -f <pool> log <device-part1> cache <device-part2></tt></pre>
Changing a failed device
<pre><tt>zpool replace -f <pool> <old device> <new device></tt></pre>
Changing a failed bootable device when using systemd-boot
<pre><tt>sgdisk <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>
| <tt>ESP</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 mole. 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 <tt>apt-get</tt>:
<pre><tt># 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 <tt>ZED_EMAIL_ADDR</tt> setting:
<pre><tt>ZED_EMAIL_ADDR="root"</tt></pre>
Please note Proxmox VE forwards mails to <tt>root</tt> to the email address configured for the root user.
| The only setting that is required is <tt>ZED_EMAIL_ADDR</tt>. All other settings are optional. |
It is good to use at most 50 percent (which is the default) 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:
<pre><tt>options 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:
<pre><tt>update-initramfs -u</tt></pre>
|
Swap-space created on a zvol may 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:
<pre><tt>sysctl -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:
<pre><tt>vm.swappiness = 10</tt></pre>
<caption class="title">Table 1. Linux kernel <tt>swappiness</tt> parameter values</caption> <colgroup><col style="width:33%;"> <col style="width:66%;"></colgroup>
<tt>vm.swappiness = 0</tt>
|
The kernel will swap only to avoid an out of memory condition
|
|
<tt>vm.swappiness = 1</tt>
|
Minimum amount of swapping without disabling it entirely.
|
|
<tt>vm.swappiness = 10</tt>
|
This value is sometimes recommended to improve performance when sufficient memory exists in a system.
|
|
<tt>vm.swappiness = 60</tt>
|
The default value.
|
|
<tt>vm.swappiness = 100</tt>
|
The kernel will swap aggressively.
|
ZFS on Linux version 0.8.0 introced support for native encryption of datasets. After an upgrade from previous ZFS on Linux versions, the encryption feature can be enabled per pool:
<pre><tt># 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 automatically 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 <tt>zfs load-key</tt>. |
| Establish and test a backup procere before enabling encryption of proction 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 default to child datasets. For example, to create an encrypted dataset <tt>tank/encrypted_data</tt> and configure it as storage in Proxmox VE, run the following commands:
<pre><tt># 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 <tt>zfs load-key</tt>:
<pre><tt># 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 <tt>keylocation</tt> and <tt>keyformat</tt> properties, either at creation time or with <tt>zfs change-key</tt> on existing datasets:
<pre><tt># 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 unauthorized 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 <tt>encryptionroot</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 <tt>encryptionroot</tt>, <tt>encryption</tt>, <tt>keylocation</tt>, <tt>keyformat</tt> and <tt>keystatus</tt> properties, the <tt>zfs load-key</tt>, <tt>zfs unload-key</tt> and <tt>zfs change-key</tt> commands and the <tt>Encryption</tt> section from <tt>man zfs</tt> for more details and advanced usage.