首页 > 解决方案 > Ubuntu 上的 ZFS 擦洗 - 系统性能黑客

问题描述

带有 ZFS 文件系统 (zfsutils-linux) 的 Ubuntu 在每个月的第二个星期日开始 zfs 清理。擦洗单线位于 /etc/cron.d/zfsutils-linux 文件中。直到由于高 IO 而开始出现性能问题时,我才意识到这种行为。在摸索了一些之后,我不得不编写自己的 BASH 脚本来修改这种行为。ZFS 清理仍然是必要的,但我想一次只清理几个文件系统。脚本贴在下面。有没有人有更优雅的解决方案?它现在有效,但感觉就像一个黑客。

# Declaring the array to store zpools.
declare -a myZpools

# Populating the array with system zpools.
while read line;
do
  myZpools+=($line)
done <<< "$(/sbin/zpool list | awk -F" " '{print $1}' | grep -v NAME)"

# Length of the array is saved in totalPools variable
totalPools="${#myZpools[@]}"
# Dividing total number of zpools into five portions. The hard-coded denominator can be changed to any desired value. Smaller denominator yields bigger zpool portions to scan.
let portion=$totalPools/5 

# If input parameter is not specified, or if it is outside of boundaries of the array length, set it to the beginning of the array.
if ( [ -z $1 ] || [ $1 -ge $totalPools ] )
then
   day=0
else
   day=$1
fi

# Execute the scrubs.
/sbin/zpool scrub ${myZpools[@]:$day:$portion} & 

标签: bashubuntuzfs

解决方案


推荐阅读