補覺鳴詩

學海無涯


  • 首頁

  • archive

  • 關於我

  • 搜尋

proxmox VE 使用 ZFS

時間: 2019-11-09   |   分類: proxmox VE   | 字數: 847 字 | 閱讀: 2分鐘 | 閱讀次數:

相關手冊

https://pve.proxmox.com/wiki/ZFS_on_Linux
https://manpages.ubuntu.com/manpages/trusty/en/man8/zpool.8.html

 

簡介

ZFS 是 linux 能使用的 soft raid 軟體

其中指令相當”豐富”

可玩性很大,功能也很多

只是這也變成調校是件很重要的事情,在網路上

謠傳調校之後可以增加好幾倍的效能

 

開始建立 ZFS 空間

硬碟初始化

在使用前,先用 fdisk 把硬碟初始化

zfs 重點
務必使用 GPT partition tables

用

fdisk -l

列出你的硬碟

 

我的硬碟清單如下
/dev/sda #HDD1
/dev/sdc #HDD2
/dev/sdd #SSD

這裡我用兩顆硬碟做 RAID1

首先刪除既有的 partition table

fdisk  /dev/sda 

g   #create a new empty GPT partition table

w   #write table to disk and exit


fdisk  /dev/sdc  
g   #create a new empty GPT partition table 
w  #write table to disk and exit

 

建立 RAID

 

我的範例建立 RAID 1 ,其他 RAID 模式請參考手冊

# -f 使用 virtual disk (建議)
# -o ashift=12 所謂的 4K 對齊
# 實例
zpool create -f -o ashift=12 RAID1 mirror /dev/sda /dev/sdc

 

完成後,顯示你的 ZFS zpool 資訊
zpool list

 

掛入 Proxmox Storage 空間

ZFS pool 建立完成後
要用 pvesm – Proxmox VE Storage Manager
掛起來才能夠開始存放 VM 使用

掃描可用的 ZFS pool
pvesm scan zfs

掛入 Proxmox Storage
pvesm add zfspool RAID1storage -pool RAID1

上面的動作其實 web ui 都可以完成

 

ZFS 設定

顯示 ZFS 空間的設定

列出 zfs pool 的詳細參數
zpool get all   RAID1
zfs get all RAID1

 

**查看 pool 模式、HDD 成員
** zpool status

 

**查看 pool 使用狀況
** zpool iostat -v

 

刪除 zfs pool

zpool destroy -f RAID1

  • 刪除後 zfs partition table 不會刪除
    可以用 fdisk
    把 partition table  重建就好

 

使用 SSD 做 cache

首先 ZFS 總共有三種快取設定

首先是第一級的 primary cache (ARC)

他是用電腦的 RAM 作為快取空間,容量預設是一半的 RAM

也就是說,假設你有 32GB 的 RAM ,那有 16 GB 會被他拿來使用

不過當然這是動態的,只有 RAM 是空閒的時候才會被使用

 

然後是二級快取 secondary cache (L2ARC)

跟

ZFS Intent Log (ZIL)

 

  • log  –  設定為寫入快取 (ZIL)
  • cache  – 設定為讀取快取  (L2ARC)

 

你可以在建立的時候直接指定 SSD

或者也可以事後增加

ZFS 中有兩種 cache 設定

  • log  –  設定為寫入快取
  • cache  – 設定為讀取快取

 

在我的情況,我全都要!

首先把 SSD 對半分割

root@pve:~# fdisk /dev/sdd
Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-937703054, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-937703054, default 937703054): 437703054
Created a new partition 1 of type 'Linux filesystem' and of size 208.7 GiB.
Partition #1 contains a zfs_member signature.
Do you want to remove the signature? [Y]es/[N]o: Y
The signature will be removed by a write command.
Command (m for help): n
Partition number (2-128, default 2):
First sector (437703055-937703054, default 437704704):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (437704704-937703054, default 937703054):
Created a new partition 2 of type 'Linux filesystem' and of size 238.4 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

 

然後設定 ZFS

建立新的 zfs pool 並設定 SSD cache 
zpool create -f -o ashift=12 RAID1 mirror /dev/sda /dev/sdc log /dev/sdd1 cache /dev/sdd2




==============================================================================
設定 SSD cache 到現有 zfs pool

zpool add -f RAID1 log /dev/sdd1 cache /dev/sdd2




移除
zpool remove  RAID1 sdd1
zpool remove  RAID1 sdd2

不過實測 只有 cache 比較會用到

log 倒是比較少

 

其他設定

**壓縮功能 compression
** zfs set compression=on/off

重複數據刪除 dedup
zfs set dedup=on/off

提醒硬碟故障、自動更換
更換硬碟

 

comments powered by Disqus >
Owan

Owan

愛貓如癡

131 日誌
29 分類
37 標籤
GitHub
© 2010 - 2022 補覺鳴詩
Powered by - Hugo v0.96.0 / Theme by - NexT
0%