Centos 8配置系统自动更新

来自:AFF大佬博客
时间:2020-03-18
阅读:

Centos8发布也有一段时间了,本文主要介绍Centos8如何实现自动更新,由于Centos8系统的变动比较大,所以与Centos7配置系统自动更新有所不同。

1、Centos8由yum全面转变为dnf,实现自动更新主要依靠dnf-automatic软件实现。


[root@uscdn2 ~]# yum search dnf-automatic
Last metadata expiration check: 0:21:44 ago on Wed 04 Dec 2019 09:48:48 PM CST.
================================================ Name Exactly Matched: dnf-automatic =================================================
dnf-automatic.noarch : Package manager - automated upgrades
[root@uscdn2 ~]# dnf install dnf-automatic 
Last metadata expiration check: 0:27:24 ago on Wed 04 Dec 2019 09:48:48 PM CST.
Dependencies resolved.
======================================================================================================================================
 Package                            Arch                        Version                             Repository                   Size
======================================================================================================================================
Installing:
 dnf-automatic                      noarch                      4.0.9.2-5.el8                       BaseOS                      133 k

Transaction Summary
======================================================================================================================================
Install  1 Package

Total download size: 133 k
Installed size: 46 k
Is this ok [y/N]: y
Downloading Packages:
dnf-automatic-4.0.9.2-5.el8.noarch.rpm                                                                112 kB/s | 133 kB     00:01    
--------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                  56 kB/s | 133 kB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                              1/1 
  Installing       : dnf-automatic-4.0.9.2-5.el8.noarch                                                                           1/1 
  Running scriptlet: dnf-automatic-4.0.9.2-5.el8.noarch                                                                           1/1 
  Verifying        : dnf-automatic-4.0.9.2-5.el8.noarch                                                                           1/1 

Installed:
  dnf-automatic-4.0.9.2-5.el8.noarch                                                                                                  

Complete!

2、配置 /etc/dnf/automatic.conf 文件开启自动更新。



[root@uscdn2 ~]# vi  /etc/dnf/automatic.conf

[commands]
#  What kind of upgrade to perform:
# default                            = all avAIlable upgrades
# security                           = only the security upgrades
upgrade_type = default
random_sleep = 0
download_updates = yes
apply_updates = yes

3、启动自动更新并查看自动更新任务列表


[root@uscdn2 ~]# systemctl enable --now dnf-automatic.timer
Created symlink /etc/systemd/system/multi-user.target.wants/dnf-automatic.timer → /usr/lib/systemd/system/dnf-automatic.timer.
[root@uscdn2 ~]# systemctl list-timers *dnf-* --all
NEXT                         LEFT       LAST                         PASSED   UNIT                ACTIVATES
Wed 2019-12-04 23:05:01 CST  44min left n/a                          n/a      dnf-automatic.timer dnf-automatic.service
Wed 2019-12-04 23:11:10 CST  50min left Wed 2019-12-04 22:11:09 CST  9min ago dnf-makecache.timer dnf-makecache.service

2 timers listed.

至此,Centos8配置系统自动更新完成。

返回顶部
顶部