bash - 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} &
解决方案
推荐阅读
- hyperledger-fabric - 我想构建一个 Hyperledger Fabric 网络,在多个组织的多个主机上运行
- java - 如何将临时授予的 ContentProvider 权限传递给 Service?
- c# - 登录网站并使用 Html Agility Pack 设置用户代理
- swift - 如何使用枚举创建计算函数?
- docker - Dockerfile 的第一行 - 什么操作系统?
- authorization - 为动态角色和属性建模 XACML 策略
- kubernetes - Traefik 入口不适用于集群 IP
- ionic-framework - 如何将我的 Ionic 4 应用程序升级到最新的 Ionic 版本?
- css - 如何使用来自其父级的 ::after 的通用兄弟选择器
- r - 使用 NA 删除行和列但保留 R 中的值