如何使 Ubuntu Server 实现自动升级?

如何使 Ubuntu Server 实现自动升级?

我关注了启用自动升级的文档在 Ubuntu 服务器上,但实际上它并没有更新任何内容。

我的 /etc/apt/apt.conf.d/50unattended-upgrades 看起来几乎像默认的。

// Automatically upgrade packages from these (origin, archive) pairs
Unattended-Upgrade::Allowed-Origins {
        "Ubuntu karmic-security";
        "Ubuntu karmic-updates";
};

// List of packages to not update
Unattended-Upgrade::Package-Blacklist {
//      "vim";
//      "libc6";
//      "libc6-dev";
//      "libc6-i686";
};

// Send email to this address for problems or packages upgrades
// If empty or unset then no email is sent, make sure that you
// have a working mail setup on your system. The package 'mailx'
// must be installed or anything that provides /usr/bin/mail.
Unattended-Upgrade::Mail "[email protected]";


// Automatically reboot *WITHOUT CONFIRMATION* if a 
// the file /var/run/reboot-required is found after the upgrade 
//Unattended-Upgrade::Automatic-Reboot "false";

目录 /var/log/unattended-upgrades/ 是空的。运行 /etc/init.d/unattended-upgrades start 不太好:

root@mozart:~# /etc/init.d/unattended-upgrades start
Checking for running unattended-upgrades: root@mozart:~#

好像有什么东西坏了,但我不确定为什么。

我有待处理的更新但尚未应用:

root@mozart:~# aptitude safe-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
The following packages will be upgraded:
  linux-libc-dev 
1 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/743kB of archives. After unpacking 4096B will be used.
Do you want to continue? [Y/n/?]

在我拥有的所有服务器中,无人值守升级似乎已被禁用:

root@mozart:~# apt-config shell UnattendedUpgradeInterval APT::Periodic::Unattended-Upgrade
root@mozart:~#

知道我遗漏了什么吗?

答案1

您检查过 /etc/apt/apt.conf.d/10periodic 吗?

它应该有最后一行

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "1";
APT::Periodic::Unattended-Upgrade "1";

答案2

在这里查看你的 Ubuntu 版本的实际文档:

/usr/share/doc/unattended-upgrades/README.gz

对于 Ubuntu 11.10,要启用它,您可以执行以下操作:

sudo dpkg-reconfigure -plow unattended-upgrades

(这是一个交互式对话框)它将创建/etc/apt/apt.conf.d/20auto-upgrades以下内容:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

因此,Ubuntu 10.04 服务器指南已过期。

如果你使用木偶就像我们比波索卢瓦斯,你可以使用类似这样的方法来自动化无人值守升级配置:

# Unattended upgrades
package { unattended-upgrades: ensure => present }
file { '/etc/apt/apt.conf.d/50unattended-upgrades':
  content => template('bipposerver/50unattended-upgrades'),
  mode    => 0644,
  require => Package['unattended-upgrades'],
}
file { '/etc/apt/apt.conf.d/20auto-upgrades':
  source  => 'puppet:///bipposerver/20auto-upgrades',
  mode    => 0644,
  require => Package['unattended-upgrades'],
}
service { unattended-upgrades:
  enable    => true,
  subscribe => [ Package['unattended-upgrades'],
                 File['/etc/apt/apt.conf.d/50unattended-upgrades',
                      '/etc/apt/apt.conf.d/20auto-upgrades'] ],
}

确保提供模板/文件50unattended-upgrades20auto-upgrades按照您认为合适的方式提供。

我也在更新Ubuntu Wiki 页面来反映这一点。

答案3

我觉得你的没什么问题/etc/apt/apt.conf.d/50unattended-upgrades。我的看起来和你的差不多,但我只允许自动应用安全升级,没有其他操作。我还将其设置为只向“root”发送邮件(Postfix 处理其余部分)。

但是:init 脚本/etc/init.d/unattended-upgrades不用于运行无人值守升级。它只是检查无人值守升级过程是否正在运行,并等待它退出。我真的不知道为什么需要它,也不知道它为什么要这样做(以前的 Ubuntu 版本中甚至没有它),但这不是进行无人值守升级的方法。

相反,在 Ubuntu 上,有一个名为的 Python 程序unnattended-upgrades可以完成这项工作。尝试手动运行它,看看会发生什么。还要检查命令的输出

apt-config shell UnattendedUpgradeInterval APT::Periodic::Unattended-Upgrade 

它应该显示UnattendedUpgradeInterval='1',表明您已正确配置 APT 以允许无人值守升级。

Ubuntu 每天从 cron 运行/etc/cron.daily/apt。如果你查看该脚本,你会发现它执行各种与 APT 相关的事情,其中​​包括无人值守升级。我猜你以某种方式禁用了该 cron 脚本,因此无人值守时什么都没有发生。

差不多就是这样了。如果您尝试了我的想法但没有成功,请发帖跟进。

高血压

相关内容