以下是Ubuntu缓存配置的实用技巧,涵盖清理、优化及管理等方面:
sudo apt-get clean:删除所有已下载的软件包文件。sudo apt-get autoclean:删除旧版本软件包文件。sudo apt-get autoremove:删除不再被依赖的孤立软件包。/boot分区使用情况:df -h。sudo apt-get purge linux-image-version。ccache:sudo apt-get install ccache,替换GCC以缓存编译结果。sccache:性能更优,安装后同样替换GCC。memcached:sudo apt-get install memcached,编辑/etc/memcached.conf配置缓存大小(如1GB)。vm.swappiness:设为10-30(默认60),减少交换分区使用。vm.dirty_ratio/vm.dirty_background_ratio:控制脏页比例,优化写入策略。sudo systemctl enable fstrim.timer。noatime选项,减少磁盘访问记录。echo 3 | sudo tee /proc/sys/vm/drop_caches)并设置定时任务。systemctl disable <服务名>,减少后台资源占用。操作前建议备份重要数据,生产环境需谨慎测试。