Zfs
如何限制 RAID1 中 NVME SSD 上的 ZFS 寫入以避免磁碟快速磨損?
目前我在 ZFS 上執行 Proxmox 5.3-7,幾乎沒有空閒的 debian 虛擬機。我在 RAID 1 中使用了兩個 SSDPE2MX450G7 NVME 驅動器。執行此設置 245 天后,SMART 值非常糟糕。
SMART/Health Information (NVMe Log 0x02, NSID 0xffffffff) Critical Warning: 0x00 Temperature: 27 Celsius Available Spare: 98% Available Spare Threshold: 10% Percentage Used: 21% Data Units Read: 29,834,793 [15.2 TB] Data Units Written: 765,829,644 [392 TB] Host Read Commands: 341,748,298 Host Write Commands: 8,048,478,631 Controller Busy Time: 1 Power Cycles: 27 Power On Hours: 5,890 Unsafe Shutdowns: 0 Media and Data Integrity Errors: 0 Error Information Log Entries: 0
我試圖調試消耗這麼多寫命令的東西,但我失敗了。
iotop
顯示 400kB/s 平均寫入和 4MB/s 峰值。我試過執行 zpool iostat ,它看起來也不錯。
zpool iostat rpool 60 capacity operations bandwidth pool alloc free read write read write rpool 342G 74.3G 0 91 10.0K 1.95M rpool 342G 74.3G 0 90 7.80K 1.95M rpool 342G 74.3G 0 107 7.60K 2.91M rpool 342G 74.3G 0 85 22.1K 2.15M rpool 342G 74.3G 0 92 8.47K 2.16M rpool 342G 74.3G 0 90 6.67K 1.71M
我決定通過回顯
1
並/proc/sys/vm/block_dump
查看/var/log/syslog
. 結果如下:Jan 25 16:56:19 proxmox kernel: [505463.283056] z_wr_int_2(438): WRITE block 310505368 on nvme0n1p2 (16 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283058] z_wr_int_0(436): WRITE block 575539312 on nvme1n1p2 (16 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283075] z_wr_int_1(437): WRITE block 315902632 on nvme0n1p2 (32 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283096] z_wr_int_4(562): WRITE block 460141312 on nvme0n1p2 (8 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283108] z_wr_int_4(562): WRITE block 460141328 on nvme0n1p2 (16 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283271] z_null_iss(418): WRITE block 440 on nvme1n1p2 (8 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283315] z_null_iss(418): WRITE block 952 on nvme1n1p2 (8 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283348] z_null_iss(418): WRITE block 878030264 on nvme1n1p2 (8 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283378] z_null_iss(418): WRITE block 878030776 on nvme1n1p2 (8 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283409] z_null_iss(418): WRITE block 440 on nvme0n1p2 (8 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283442] z_null_iss(418): WRITE block 952 on nvme0n1p2 (8 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283472] z_null_iss(418): WRITE block 878030264 on nvme0n1p2 (8 sectors) Jan 25 16:56:19 proxmox kernel: [505463.283502] z_null_iss(418): WRITE block 878030776 on nvme0n1p2 (8 sectors) Jan 25 16:56:19 proxmox kernel: [505463.289562] z_wr_iss(434): WRITE block 460808488 on nvme1n1p2 (24 sectors) Jan 25 16:56:19 proxmox kernel: [505463.289572] z_wr_iss(434): WRITE block 460808488 on nvme0n1p2 (24 sectors) Jan 25 16:56:19 proxmox kernel: [505463.457366] z_wr_iss(430): WRITE block 460808744 on nvme1n1p2 (24 sectors) Jan 25 16:56:19 proxmox kernel: [505463.457382] z_wr_iss(430): WRITE block 460808744 on nvme0n1p2 (24 sectors) Jan 25 16:56:19 proxmox kernel: [505463.459003] z_wr_iss(431): WRITE block 460809000 on nvme1n1p2 (24 sectors)
等等。有沒有辦法限制寫入次數?正如您所看到的那樣,寫入的數據單元太離譜了,我被困住了,因為我不知道如何限制它。
你的真實寫作如此誇張有不同的原因。讓我們標記一些基點:
- 首先,讓我們設置一個基線:從您的
zpool iostat
輸出中,我們可以推斷出一個連續的 ~1.5 MB/s 寫入流到每個鏡像分支。因此,在 245 天內,總共寫入 1.586400245 = 32 TB;recordsize
由於首先寫入 ZIL,然後在 txg_commit(對於小於 的寫入),上述數字已經考慮了 ZFS寫入放大和雙數據寫入zfs_immediate_write_sz
。給出上述內容,以減少 ZFS 引起的寫入放大,您應該:
- 設置一個小
recordsize
(即:16K);- 放
logbias=throughput
- 設置
compression=lz4
(由@poige 建議)編輯:為了更正確地估計寫入放大,請顯示輸出
nvme intel smart-log-add /dev/nvme0