当前位置: 首页>>技术教程>>正文


如何获得自动升级以在Ubuntu Server上工作?

, ,

问题描述

我在Ubuntu服务器中遵循documentation for enabling automatic upgrades,但是它根本没有更新任何内容。

我的/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 "pupeno@example.com";


// 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:~#

有什么想法我想念吗?

最佳思路

您检查/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";

次佳思路

在此处查看您的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 server guide中的信息是out-of-date。

如果您像BippoSoluvas一样使用Puppet,则可以使用类似这样的方法来自动执行正确的unattended-upgrades配置:

# 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 page以反映这一点。

第三种思路

我没有发现您的/etc/apt/apt.conf.d/50unattended-upgrades有任何问题。我的看上去几乎和您的一样,但我只允许自动应用安全升级,没有别的。我还将其设置为仅将邮件发送到”root”(由Postfix处理其余部分)。

但是:初始化脚本/etc/init.d/unattended-upgrades不适用于运行无人值守的升级。它仅检查无人参与的升级过程是否正在运行,并等待直到退出。我真的不知道为什么需要它,或者为什么要做它(它在以前的Ubuntu版本中甚至不存在),但这不是进行无人值守升级的方法。

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

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

应该说UnattendedUpgradeInterval='1',表明您正确配置了APT以允许无人参与的升级。

Ubuntu每天从cron运行/etc/cron.daily/apt。如果查看该脚本,则会发现它执行了各种APT-related事务,其中包括无人值守的升级。我的猜测是您以某种方式禁用了cron脚本,因此无人值守。

就这样,或多或少,就从我头顶上消失了。如果您尝试了我的想法但没有成功,请发表后续报告。

高温超导

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/9636.html,未经允许,请勿转载。