![为什么空闲内存不用作磁盘缓存?](https://linux22.com/image/183551/%E4%B8%BA%E4%BB%80%E4%B9%88%E7%A9%BA%E9%97%B2%E5%86%85%E5%AD%98%E4%B8%8D%E7%94%A8%E4%BD%9C%E7%A3%81%E7%9B%98%E7%BC%93%E5%AD%98%EF%BC%9F.png)
我的文件服务器说:
$ free
total used free shared buff/cache available
Mem: 8023836 5250252 2534480 668 239104 2515488
Swap: 18942984 175616 18767368
正在进行大量磁盘读取(数 TB 的数据),因此我很困惑为什么它保留 2.5 GB 的空闲空间,而仅保留 0.24 GB 作为磁盘缓存。为什么不使用 2.5 GB 的读取缓存?
我可以更改此设置,以便将更多 2.5 GB 用于磁盘缓存吗?
$ uname -a
Linux hpdisk 5.4.0-51-generic #56-Ubuntu SMP Mon Oct 5 14:28:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ zpool status
pool: rpool
state: ONLINE
scan: scrub in progress since Sun Nov 8 00:24:02 2020
4.77T scanned at 6.44M/s, 4.74T issued at 6.39M/s, 13.7T total
0B repaired, 34.50% done, no estimated completion time
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
dm-uuid-CRYPT-LUKS2-b5e46de8249645e882a3985615ac4e7d-crypto-ata-WDC_WD80EMAZ-00WJTA0_1EG575KZ ONLINE 0 0 0
dm-uuid-CRYPT-LUKS2-a095d853c023483994c1f9e34c4d28ab-crypto-ata-WDC_WD80EMAZ-00WJTA0_1EHU5BJZ ONLINE 0 0 0
dm-uuid-CRYPT-LUKS2-3548b790c63746718b03cdbfbcefc80c-crypto-ata-WDC_WD80EMAZ-00WJTA0_2SGGB3JW ONLINE 0 0 0
dm-uuid-CRYPT-LUKS2-bab3c8fe77e84d2abc8cd2b06c4f8957-crypto-ata-WDC_WD80EMAZ-00WJTA0_2YJ5N8WD ONLINE 0 0 0
dm-uuid-CRYPT-LUKS2-99a487a3939c45ceb4cac9cf4bf4fd69-crypto-ata-WDC_WD80EZAZ-11TDBA0_2SG9J57J ONLINE 0 0 0
logs
mirror-1 ONLINE 0 0 0
dm-uuid-part1-CRYPT-LUKS2-c0601a7ef87743888ea6de49046925dc-crypto-scsi-SATA_Crucial_CT525MX3_1711164B7A3E ONLINE 0 0 0
dm-uuid-part1-CRYPT-LUKS2-ba2220b00f8c4702a3ad2d83144f9cef-crypto-scsi-SATA_Crucial_CT525MX3_173818CFFE43 ONLINE 0 0 0
cache
dm-uuid-part2-CRYPT-LUKS2-ba2220b00f8c4702a3ad2d83144f9cef-crypto-scsi-SATA_Crucial_CT525MX3_173818CFFE43 ONLINE 0 0 0
dm-uuid-part2-CRYPT-LUKS2-c0601a7ef87743888ea6de49046925dc-crypto-scsi-SATA_Crucial_CT525MX3_1711164B7A3E ONLINE 0 0 0
errors: No known data errors
答案1
泳池正在进行擦洗。停止清理后,缓存将正常使用(0.24 GB 空闲,其余用作缓存)。
$ sudo zpool scrub -s rpool
[...wait...]
$ free
total used free shared buff/cache available
Mem: 8023836 4043000 241208 680 3739628 3714144
Swap: 18942984 175360 18767624
我不知道为什么清理会导致这种行为,现在我需要 I/O,所以清理必须等待。