🔗 当缓存未命中过多时该怎么做
正常运行时,Squid 产生的 TCP_SWAPFAIL_MISS 代码非常少(通常远低于 1%),这表示认为对象应在缓存中但未能找到。但偶尔,这种情况会非常非常频繁地发生。当发生大量错误时,问题在于 Squid 缓存的 **索引**(可能位于 Squid 缓存目录结构顶层的类似 swap.state 的文件中)与实际缓存内容不同步。
这是我用来确保这种情况不会发生的一个脚本。它过于谨慎,做了很多不必要的事情,包括每次都丢弃缓存中的内容。但它总是有效的。
🔗 示例脚本
# restart Squid
# (probably after making arbitrary config changes)
echo temporarily stopping Dans Guardian [Squid user]
dansguardian -q
while [[ `ps aux | grep dansguardian | wc -l` -gt 1 ]]; do
sleep 1
done
sleep 2
echo stopping Squid so can make arbitrary changes
squid -k shutdown
while [[ `ps aux | grep squid | wc -l` -gt 1 ]]; do
sleep 1
done
sleep 2
echo flushing-by-deleting old Squid cache including index
rm -rf /var/spool/squid/*
sleep 2
echo creating new Squid disk cache directories and index
squid -z
sleep 2
echo starting Squid again with new configuration
squid
sleep 2
echo starting Dans Guardian [Squid user] again
dansguardian
回到 FAQ 索引
导航: 网站搜索、网站页面、分类、🔼 向上