定期更新计划
更新优先级分类
# 安全更新优先级示例(基于Ubuntu/Debian)
apt-get update
apt-get upgrade --only-upgrade security
bash
sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
bash
sudo yum install yum-cron
sudo systemctl enable --now yum-cron
conf
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
};
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";
预生产环境测试
# 创建测试容器
docker run -it --name patch-test ubuntu:latest
# 在容器内应用更新并测试关键服务
更新后检查清单
systemctl list-units --type=service --state=running
uname -r
apt list --installed | grep security
或 yum updateinfo list installed
快照备份
# LVM快照示例
lvcreate -s -n root_snapshot -L 5G /dev/vg00/root
包管理回滚
apt-get install package=version
yum history undo <transaction_id>
安全通告订阅
cve-search
工具合规报告生成
# 生成更新报告示例
apt-get update && apt-get upgrade -s | grep ^Inst > pending_updates.txt
内核实时补丁(无需重启)
sudo apt install canonical-livepatch
yum install kpatch
容器化工作负载更新
# 容器镜像更新流程
docker-compose pull && docker-compose up -d --force-recreate
遵循这些实践可显著降低安全风险,同时保持系统稳定性。记住平衡安全需求与业务连续性要求,关键系统更新前务必进行影响评估。