zoukankan      html  css  js  c++  java
  • 通过yum-cron对linux进行安全更新

    配置yum-cron工具。

    安装

    [root@localhost ~]# yum -y install yum-cron

    配置

    yum-cron有两个配置文件:/etc/yum/yum-cron.conf 和 /etc/yum/yum-cron-hourly.conf。这两个配置文件内容差不多,用于配置每天需要执行的内容和每小时需要执行的内容。

    在配置文件中,提供的更新策略为:

    [root@localhost ~]# vi /etc/yum/yum-cron.conf 
    [commands]
    #  What kind of update to use:
    # default                            = yum upgrade
    # security                           = yum --security upgrade
    # security-severity:Critical         = yum --sec-severity=Critical upgrade
    # minimal                            = yum --bugfix update-minimal
    # minimal-security                   = yum --security update-minimal
    # minimal-security-severity:Critical =  --sec-severity=Critical update-minimal
    default 默认的更新,类似yum update
    security 安全更新, 类似yum --secruity upgrade
    security-severity:Critical 重要的安全更新,类似yum --sec-severity=Critical upgrade
    minimal 最小化更新,类似yum --bugfix update-minimal
    minimal-security 最小化安全更新,类似yum --security update-minimal
    minimal-security-severity:Critical 最小化重要安全更新,类似yum --sec-severity=Critical update-minimal

    通过update-cmd指定相应的更新策略。
    如: 需要配置只需要更新重要的安全更新,则配置为

    update_cmd = security-severity:Critical

    apply_updates设置是否提交相应的安全更新,如果设置为no,则只会检测存在更新,但不会直接更新,如要自动更新,需将apply_updates设置为yes

    apply_updates = yes

    random_sleep设置最大的随机启动时间,设置随机启动是为了解决大量服务器同时启动更新,对服务器环境造成影响。(考虑的很周到呢,不同于我们通过crontab设置一个固定的时间进行更新)
    random_sleep的时间单位为秒。
    系统默认设置为6*60 = 360,即6小时:

    random_sleep = 360

    在生产环境,我们通常不愿意去更新系统的内核,那么,通过exclude和YUM_PARAMETER可以将内核类的更新排除掉.
    在CentOS/RHEL 7.x系统中,加入下面内容排除:

    exclude=kernel*

    在RHEL/CentOS 6.x系统中,加入以下内容排除:

    YUM_PARAMETER=kernel*

    配置参考:

    [root@ttt yum]# cat yum-cron.conf | grep -vE '^#|^$'
    [commands]
    update_cmd = security-severity:Critical
    update_messages = yes
    download_updates = yes
    apply_updates = yes
    random_sleep = 360
    exclude=kernel*
    [emitters]
    system_name = None
    emit_via = stdio
    output_width = 80
    [email]
    email_from = root@localhost
    email_to = root
    email_host = localhost
    [groups]
    group_list = None
    group_package_types = mandatory, default
    [base]
    debuglevel = -2
    mdpolicy = group:main

    配置完成后,需要配置 /etc/yum/yum-cron-hourly.conf 让yum-cron每小时都执行。如果需要让yum-cron每天执行一次,需要配置/etc/cron.daily/0yum-daily.cron。

    [root@ttt yum]# cat /etc/cron.hourly/0yum-hourly.cron 
    #!/bin/bash
    
    # Only run if this flag is set. The flag is created by the yum-cron init
    # script when the service is started -- this allows one to use chkconfig and
    # the standard "service stop|start" commands to enable or disable yum-cron.
    if [[ ! -f /var/lock/subsys/yum-cron ]]; then
      exit 0
    fi
    
    # Action!
    exec /usr/sbin/yum-cron /etc/yum/yum-cron-hourly.conf
    [root@ttt yum]# cat /etc/cron.daily/0yum-daily.cron
    #!/bin/bash
     
    # Only run if this flag is set. The flag is created by the yum-cron init
    # script when the service is started -- this allows one to use chkconfig and
    # the standard "service stop|start" commands to enable or disable yum-cron.
    if [[ ! -f /var/lock/subsys/yum-cron ]]; then
      exit 0
    fi
     
    # Action!
    exec /usr/sbin/yum-cron

    以上就是yum-cron的大概的配置信息。如果需要查看更详细的,可以通过系统的man命令。
    [root@ttt yum]# man yum-cron

  • 相关阅读:
    判断文件是否存在
    peewee模块更改数据-sqlite
    Python操纵数据库:peewee
    PyQt5调用主窗口
    FHQ-Treap学习笔记
    P3047 [USACO12FEB]Nearby Cows G(树形DP)
    P2986 [USACO10MAR]Great Cow Gathering G(树形DP)
    【普及】Codeforces Round #713(Div 3) 1512A~G
    P1272.重建道路(树形背包)
    P273.有线电视网(树上背包)
  • 原文地址:https://www.cnblogs.com/liujunjun/p/12098992.html
Copyright © 2011-2022 走看看